File: toric_divisor.rules

package info (click to toggle)
polymake 4.15-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,892 kB
  • sloc: cpp: 168,945; perl: 43,410; javascript: 31,575; ansic: 3,007; java: 2,654; python: 632; sh: 268; xml: 117; makefile: 61
file content (244 lines) | stat: -rw-r--r-- 8,338 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#  Copyright (c) 1997-2024
#  Ewgenij Gawrilow, Michael Joswig, and the polymake team
#  Technische Universität Berlin, Germany
#  https://polymake.org
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------

object TDivisor {

   rule INTEGRAL : COEFFICIENTS {
      $this->INTEGRAL = (eliminate_denominators($this->COEFFICIENTS) - $this->COEFFICIENTS == zero_vector($this->COEFFICIENTS->dim));
   }

   rule CARTIER :  {
      $this->CARTIER = 1;
   }
   precondition : PRINCIPAL;

   rule Q_CARTIER : {
      $this->Q_CARTIER = 1;
   }
   precondition : CARTIER;

   rule VERY_AMPLE = SECTION_POLYTOPE.VERY_AMPLE;
   precondition : AMPLE;

   rule VERY_AMPLE : {
      $this->VERY_AMPLE = false;
   }
   precondition : !AMPLE;

   rule VERY_AMPLE : {
      $this->VERY_AMPLE = false;
   }
   precondition : !CARTIER;
   
   rule VERY_AMPLE : {
      $this->VERY_AMPLE = false;
   }
   precondition : !NEF;

}

object NormalToricVariety {

   rule DIVISOR.COEFFICIENTS : RaysPerm.PERMUTATION, RaysPerm.DIVISOR.COEFFICIENTS {
      my $old = $this->RaysPerm->DIVISOR->COEFFICIENTS;
      my $perm = $this->RaysPerm->PERMUTATION;
      $this->DIVISOR->COEFFICIENTS = permuted($old, $perm);
   }

   rule DIVISOR.SECTION_POLYTOPE.INEQUALITIES : RAYS, DIVISOR.COEFFICIENTS {
      my $a = $this->DIVISOR->COEFFICIENTS;
      my $rays = primitive($this->RAYS);		
      my $ineq = $a | convert_to<Rational>($rays);
      $this->DIVISOR->SECTION_POLYTOPE->INEQUALITIES = $ineq;
   }

   rule DIVISOR.PRINCIPAL : RAYS, DIVISOR.COEFFICIENTS {
      my $c = $this->DIVISOR->COEFFICIENTS;
      my $eq = -$c | convert_to<Rational>(primitive($this->RAYS));
      my $bla = new Polytope<Rational>(INEQUALITIES => unit_vector<Rational>($eq->cols,0), EQUATIONS => $eq);
      $bla->VERTICES;
      my $sol = grep($_->[0]==1, @{$bla->LATTICE_POINTS});
      $this->DIVISOR->PRINCIPAL=($sol > 0);
   }

   # [[AMPLE]] implies [[NEF]]
   rule DIVISOR.NEF : {
      $this->DIVISOR->NEF = 1;
   }
   weight 0.1;
   precondition : DIVISOR.AMPLE;

   # [[CARTIER]] implies [[Q_CARTIER]]
   rule DIVISOR.CARTIER : {
      $this->DIVISOR->CARTIER = 0;
   }
   weight 0.1;
   precondition : !DIVISOR.Q_CARTIER;

   # On a smooth ntv every Weil divisor is Cartier.
   rule DIVISOR.CARTIER : {
      $this->DIVISOR->CARTIER = 1;
   }
   precondition : DIVISOR.INTEGRAL;
   precondition : SMOOTH_FAN;

   # On a simplicial ntv every Weil divisor has a multiple which is Cartier.
   rule DIVISOR.Q_CARTIER : {
      $this->DIVISOR->Q_CARTIER = 1;
   }
   precondition : DIVISOR.INTEGRAL;
   precondition : SIMPLICIAL;



   # This rule implements Theorem 4.2.8 of Cox,Little,Schenck:Toric Varieties.
   # The Cartier data determined is exactly the set of the m_\sigma for all
   # maximal cones.
   rule DIVISOR.Q_CARTIER, DIVISOR.CARTIER_DATA : RAYS, DIVISOR.COEFFICIENTS, MAXIMAL_CONES, LINEALITY_SPACE {
      my $maxcones = $this->MAXIMAL_CONES;
      my $map = new Map<Set<Int>,Vector>;
      my $rays = primitive($this->RAYS);
      my $lin = primitive($this->LINEALITY_SPACE);
      $lin = zero_vector($lin->rows) | convert_to<Rational>($lin);
      my $coefficients = $this->DIVISOR->COEFFICIENTS;
      foreach my $s (@$maxcones){
         my $eq = $coefficients->slice($s) | convert_to<Rational>($rays->minor($s,All));
         my $ns=new Matrix;
         if ( $lin->rows ) {
            $ns = null_space($eq/$lin);
         } else {
            $ns = null_space($eq);
         }
         die "too many solutions for Cartier data\n" if $ns->rows > 1;
         if ( $ns->rows == 0 ) {
            $this->DIVISOR->Q_CARTIER = 0;
            return;
         }
         my $v = $ns->row(0);
         $map->{$s} = $v/$v->[0];
      }
      $this->DIVISOR->Q_CARTIER = 1;
      $this->DIVISOR->CARTIER_DATA = $map;
   }


   # This rule implements Theorem 4.2.8 of Cox,Little,Schenck:Toric Varieties.
   # We use the vertices m_\sigma according to part (d) of the theorem.
   rule DIVISOR.CARTIER : DIVISOR.CARTIER_DATA, MAXIMAL_CONES {
      my $cd = $this->DIVISOR->CARTIER_DATA;
      my $mc = $this->MAXIMAL_CONES;
      foreach (@{$mc}) {
         if ( $cd->{$_} != primitive($cd->{$_}) ) {
            $this->DIVISOR->CARTIER=0;
            return;
         }
      }
      $this->DIVISOR->CARTIER=1;
   }
   precondition : DIVISOR.Q_CARTIER;
	
   
   rule DIVISOR.BASEPOINT_FREE : DIVISOR.CARTIER_DATA, MAXIMAL_CONES, DIVISOR.SECTION_POLYTOPE {
      my $maxcones = $this->MAXIMAL_CONES;
      my $P = $this->DIVISOR->SECTION_POLYTOPE;
      my $map = $this->DIVISOR->CARTIER_DATA;
      foreach my $s (@$maxcones){
         if (!$P->contains($map->{$s})){
            $this->DIVISOR->BASEPOINT_FREE = 0;
            return;
         }

      }
      $this->DIVISOR->BASEPOINT_FREE = 1;
   }
   precondition : DIVISOR.CARTIER;
   precondition : PURE;
   precondition : FULL_DIM;


   # ampleness implies that  the divisor is Cartier and the fan is complete
   # Hence, [[CARTIER_DATA]] is defined and contains integral points
   # for any two adjacent maximal cones s,s' with intersection t we have to check the following:
   # if m, m' are the vertices corresponding to the cones, and u is a generator of s'/t, then (m-m')*u must be positive
   # (note that any vector u pointing in the right direction in s'/t suffices to check this)
   rule DIVISOR.AMPLE : DIVISOR.COEFFICIENTS, DIVISOR.CARTIER_DATA, RAYS, MAXIMAL_CONES, DUAL_GRAPH.ADJACENCY {
      my $mc = $this->MAXIMAL_CONES;
      my $rays = primitive($this->RAYS);
      my $d =$this->DIVISOR->COEFFICIENTS;
      my $cd = $this->DIVISOR->CARTIER_DATA;
      my $dg = $this->DUAL_GRAPH->ADJACENCY;

      foreach my $i (0..$mc->rows-1) {
         foreach my $adj (@{$dg->adjacent_nodes($i)})  {
            if ( $adj > $i ) {
               my $j = @{($mc->[$adj]-$mc->[$i])}[0];
               if ( ($cd->{$mc->[$i]}-$cd->{$mc->[$adj]})->slice(range_from(1)) * $rays->[$j] <= 0 ) {
                  $this->DIVISOR->AMPLE = 0;
                  return;
               }
            }
         }
      }
      $this->DIVISOR->AMPLE = 1;
   }
   weight 3.10;
   #  precondition : DIVISOR.CARTIER;
   precondition : COMPLETE;


   # computes whether a toric divisor is [[NEF]]
   # algorithm: check whether the divisor is in the nef cone of the variety
   rule DIVISOR.NEF : DIVISOR.COEFFICIENTS, NEF_CONE.FACETS | NEF_CONE.INEQUALITIES, NEF_CONE.LINEAR_SPAN | NEF_CONE.EQUATIONS, RATIONAL_DIVISOR_CLASS_GROUP.PROJECTION {
      my $nef = $this->NEF_CONE;
      my $pd = $this->DIVISOR->COEFFICIENTS * $this->RATIONAL_DIVISOR_CLASS_GROUP->PROJECTION;
      $this->DIVISOR->NEF = $nef->contains($pd);
   }
   weight 1.10;


   # computes whether a toric divisor is [[EFFECTIVE]]
   # algorithm: check whether the divisor is in the effective cone of the variety    
   rule DIVISOR.EFFECTIVE : DIVISOR.COEFFICIENTS, EFFECTIVE_CONE.FACETS | EFFECTIVE_CONE.INEQUALITIES, EFFECTIVE_CONE.LINEAR_SPAN | EFFECTIVE_CONE.EQUATIONS, RATIONAL_DIVISOR_CLASS_GROUP.PROJECTION {
      my $eff = $this->EFFECTIVE_CONE;
      my $pd = $this->DIVISOR->COEFFICIENTS * $this->RATIONAL_DIVISOR_CLASS_GROUP->PROJECTION;
      $this->DIVISOR->EFFECTIVE = $eff->contains($pd);
   }
   weight 1.10;

}


# ---------------------
# user functions
# ---------------------


# @category Combinatorics
# return the polytope defined by an element of the nef or effective cone
# first argument is the fan, second the Vector defining the divisor class
user_function polytope_of_divisor_class(NormalToricVariety, Vector) {
  my ($tv,$d)=@_;
  my $ld = $d*$tv->RATIONAL_DIVISOR_CLASS_GROUP->LIFTING;
  my $div = $tv->DIVISOR(COEFFICIENTS=>$ld, temporary);
  return $div->SECTION_POLYTOPE;
}


# Local Variables:
# mode: perl
# cperl-indent-level: 3
# indent-tabs-mode:nil
# End: