File: dual.rules

package info (click to toggle)
polymake 4.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,888 kB
  • sloc: cpp: 168,933; perl: 43,407; javascript: 31,575; ansic: 3,007; java: 2,654; python: 632; sh: 268; xml: 117; makefile: 61
file content (173 lines) | stat: -rw-r--r-- 5,158 bytes parent folder | download | duplicates (2)
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
#  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 PURPSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------


# This contains rules for computing/converting properties between a matroid and its dual.

object Matroid {

   # @category Duality
   # The dual matroid.
   property DUAL : self : twin;


   rule DUAL.N_ELEMENTS = N_ELEMENTS;

   rule DUAL.LABELS = LABELS;

   rule DUAL.RANK : N_ELEMENTS, RANK {
      $this->DUAL->RANK = $this->N_ELEMENTS - $this->RANK;
   }
   weight 0.1;

   rule DUAL.BASES : BASES, N_ELEMENTS {
      $this->DUAL->BASES = dual_bases_from_bases($this->N_ELEMENTS, $this->BASES);
   }
   weight 1.10;

   rule DUAL.NON_BASES : NON_BASES, N_ELEMENTS {
      $this->DUAL->NON_BASES = dual_bases_from_bases($this->N_ELEMENTS, $this->NON_BASES);
   }
   weight 1.10;

   rule DUAL.CIRCUITS : BASES, N_ELEMENTS {
      $this->DUAL->CIRCUITS = dual_circuits_from_bases($this->N_ELEMENTS, $this->BASES);
   }
   weight 4.10;

   rule BASES : DUAL.CIRCUITS, N_ELEMENTS {
      $this->BASES = bases_from_dual_circuits($this->N_ELEMENTS, $this->DUAL->CIRCUITS);
   }
   weight 4.10;

   rule BASES : DUAL.CIRCUITS, RANK, N_ELEMENTS {
      $this->BASES = bases_from_dual_circuits_and_rank($this->N_ELEMENTS, $this->RANK, $this->DUAL->CIRCUITS);
   }
   weight 3.10;

   rule DUAL.VECTORS : VECTORS {
      $this->DUAL->VECTORS = transpose(null_space(transpose($this->VECTORS)));
   }
   weight 3.10;
   precondition : RANK, N_ELEMENTS {
      $this->RANK < $this->N_ELEMENTS;
   }

   rule DUAL.VECTORS : VECTORS, N_ELEMENTS {
      $this->DUAL->VECTORS = new Matrix<Rational>($this->N_ELEMENTS, $this->VECTORS->cols != 0);
   }
   weight 0.10;
   precondition : RANK, N_ELEMENTS {
      $this->RANK == $this->N_ELEMENTS;
   }

   rule MATROID_HYPERPLANES : DUAL.CIRCUITS, N_ELEMENTS {
      my $total = sequence(0,$this->N_ELEMENTS);
      $this->MATROID_HYPERPLANES = [ map { $total - $_} @{$this->DUAL->CIRCUITS}];
   }
   weight 1.10;

   rule DUAL.CIRCUITS : MATROID_HYPERPLANES, N_ELEMENTS {
      my $total =  sequence(0,$this->N_ELEMENTS);
      $this->DUAL->CIRCUITS = [ map { $total - $_} @{$this->MATROID_HYPERPLANES}];
   }
   weight 1.10;

   rule SPARSE_PAVING : PAVING, DUAL.PAVING {
      $this->SPARSE_PAVING = $this->PAVING && $this->DUAL->PAVING;
   }
   weight 0.1;

   rule IDENTICALLY_SELF_DUAL : CIRCUITS, DUAL.CIRCUITS {
      $this->IDENTICALLY_SELF_DUAL = defined(find_permutation($this->CIRCUITS, $this->DUAL->CIRCUITS));
   }
   weight 2.10;
   precondition : N_ELEMENTS, RANK {
      2*$this->RANK == $this->N_ELEMENTS;
   }

   rule SELF_DUAL : CIRCUITS, DUAL.CIRCUITS {
      $this->SELF_DUAL = defined(find_row_col_permutation(new IncidenceMatrix($this->CIRCUITS), new IncidenceMatrix($this->DUAL->CIRCUITS)));
   }
   weight 5.10;
   precondition : N_ELEMENTS, RANK {
      2*$this->RANK == $this->N_ELEMENTS;
   }

   rule CONNECTED_COMPONENTS : DUAL.CIRCUITS, N_ELEMENTS{
       $this->CONNECTED_COMPONENTS = connected_components_from_circuits($this->DUAL->CIRCUITS, $this->N_ELEMENTS);
   }
   weight 1.10;  


   rule SELF_DUAL, IDENTICALLY_SELF_DUAL : {
      $this->SELF_DUAL = 0;
      $this->IDENTICALLY_SELF_DUAL = 0;
   }
   weight 0.1;
   precondition : N_ELEMENTS, RANK {
      2*$this->RANK != $this->N_ELEMENTS;
   }
   
   rule SELF_DUAL : IDENTICALLY_SELF_DUAL {
      $this->SELF_DUAL = 1;
   }
   weight 0.1;
   precondition : IDENTICALLY_SELF_DUAL;
   
   rule IDENTICALLY_SELF_DUAL : BASES, DUAL.BASES {
      $this->IDENTICALLY_SELF_DUAL = defined(find_permutation($this->BASES, $this->DUAL->BASES));
   }
   weight 2.10;
   precondition : N_ELEMENTS, RANK {
      2 * $this->RANK == $this->N_ELEMENTS;
   }

   rule SELF_DUAL : BASES, DUAL.BASES {
      $this->SELF_DUAL = defined(find_row_col_permutation(new IncidenceMatrix($this->BASES), new IncidenceMatrix($this->DUAL->BASES)));
   }
   weight 5.10;
   precondition : N_ELEMENTS, RANK {
      2*$this->RANK == $this->N_ELEMENTS;
   }


   rule SPLIT : {
      $this->SPLIT=1;
   }
   precondition : PAVING || DUAL.PAVING;
   weight 0.10;

   # @category Advanced properties
   # Whether the dual of the matroid is transversal,
   # i.e. same as [[DUAL.TRANSVERSAL]]
   user_method COTRANSVERSAL {
      return $_[0]->DUAL->TRANSVERSAL;
   }
   
   # @category Advanced properties
   # Alias for [[COTRANSVERSAL]]
   user_method STRICT_GAMMOID {
      return $_[0]->COTRANSVERSAL();
   }

}

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