1 | //This file contains functions synthesizing logical formulas and enabling transmission of entangled literals |
---|
2 | |
---|
3 | function syntheticImplNARule(firstArg, secondArg) |
---|
4 | { |
---|
5 | var result = Vector.new(); |
---|
6 | |
---|
7 | if(firstArg[0][0] == 0) |
---|
8 | { |
---|
9 | result.add([3]); |
---|
10 | var i; |
---|
11 | |
---|
12 | for(i = 1; i < firstArg[0].size; i++) |
---|
13 | result[0].add(firstArg[0][i]); |
---|
14 | |
---|
15 | for(i = 0; i < secondArg[0].size; i++) |
---|
16 | result[0].add(secondArg[0][i]); |
---|
17 | |
---|
18 | result.add(deepCopyList(firstArg[1])); |
---|
19 | |
---|
20 | } |
---|
21 | |
---|
22 | return result; |
---|
23 | } |
---|
24 | |
---|
25 | function syntheticImplBRule(firstArg, secondArg) |
---|
26 | { |
---|
27 | var result = Vector.new(); |
---|
28 | result.add([3]); |
---|
29 | |
---|
30 | var i; |
---|
31 | |
---|
32 | for(i = 0; i < firstArg[0].size; i++) |
---|
33 | result[0].add(firstArg[0][i]); |
---|
34 | |
---|
35 | for(i = 0; i < secondArg[0].size; i++) |
---|
36 | result[0].add(secondArg[0][i]); |
---|
37 | |
---|
38 | result.add(deepCopyList(secondArg[1])); |
---|
39 | |
---|
40 | return result; |
---|
41 | } |
---|
42 | |
---|
43 | function syntheticImplANBRule(firstArg, secondArg) |
---|
44 | { |
---|
45 | var result = Vector.new(); |
---|
46 | |
---|
47 | if(secondArg[0][0] == 0) |
---|
48 | { |
---|
49 | result.add([0,3]); |
---|
50 | var i; |
---|
51 | |
---|
52 | for(i = 0; i < firstArg[0].size; i++) |
---|
53 | result[0].add(firstArg[0][i]); |
---|
54 | |
---|
55 | for(i = 1; i < secondArg[0].size; i++) |
---|
56 | result[0].add(secondArg[0][i]); |
---|
57 | |
---|
58 | result.add(deepCopyList(firstArg[1])); |
---|
59 | |
---|
60 | for(i = 0; i < secondArg[1].size; i++) |
---|
61 | { |
---|
62 | //do not let an entangled literal to be repeated |
---|
63 | if(result[1].find(secondArg[1][i]) == -1) |
---|
64 | result[1].add(deepCopyList(secondArg[1][i])); |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | return result; |
---|
69 | } |
---|
70 | |
---|
71 | function syntheticAltARule(firstArg, secondArg) |
---|
72 | { |
---|
73 | var result = Vector.new(); |
---|
74 | result.add([2]); |
---|
75 | |
---|
76 | var i; |
---|
77 | |
---|
78 | for(i = 0; i < firstArg[0].size; i++) |
---|
79 | result[0].add(firstArg[0][i]); |
---|
80 | |
---|
81 | for(i = 0; i < secondArg[0].size; i++) |
---|
82 | result[0].add(secondArg[0][i]); |
---|
83 | |
---|
84 | result.add(deepCopyList(firstArg[1])); |
---|
85 | |
---|
86 | return result; |
---|
87 | } |
---|
88 | |
---|
89 | function syntheticAltBRule(firstArg, secondArg) |
---|
90 | { |
---|
91 | var result = Vector.new(); |
---|
92 | |
---|
93 | result.add([2]); |
---|
94 | |
---|
95 | var i; |
---|
96 | |
---|
97 | for(i = 0; i < firstArg[0].size; i++) |
---|
98 | result[0].add(firstArg[0][i]); |
---|
99 | |
---|
100 | for(i = 0; i < secondArg[0].size; i++) |
---|
101 | result[0].add(secondArg[0][i]); |
---|
102 | |
---|
103 | result.add(deepCopyList(secondArg[1])); |
---|
104 | |
---|
105 | return result; |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | function syntheticAltNANBRule(firstArg, secondArg) |
---|
110 | { |
---|
111 | var result = Vector.new(); |
---|
112 | |
---|
113 | if(firstArg[0][0] == 0 && secondArg[0][0] == 0) |
---|
114 | { |
---|
115 | |
---|
116 | result.add([0,2]); |
---|
117 | |
---|
118 | var i; |
---|
119 | |
---|
120 | for(i = 1; i < firstArg[0].size; i++) |
---|
121 | result[0].add(firstArg[0][i]); |
---|
122 | |
---|
123 | for(i = 1; i < secondArg[0].size; i++) |
---|
124 | result[0].add(secondArg[0][i]); |
---|
125 | |
---|
126 | |
---|
127 | result.add(deepCopyList(firstArg[1])); |
---|
128 | |
---|
129 | for(i = 0; i < secondArg[1].size; i++) |
---|
130 | { |
---|
131 | //do not let an entangled literal to be repeated |
---|
132 | if(result[1].find(secondArg[1][i]) == -1) |
---|
133 | result[1].add(deepCopyList(secondArg[1][i])); |
---|
134 | } |
---|
135 | |
---|
136 | } |
---|
137 | return result; |
---|
138 | } |
---|
139 | |
---|
140 | function syntheticConjNARule(firstArg, secondArg) |
---|
141 | { |
---|
142 | var result = Vector.new(); |
---|
143 | |
---|
144 | |
---|
145 | if(firstArg[0][0] == 0) |
---|
146 | { |
---|
147 | result.add([0,1]); |
---|
148 | var i; |
---|
149 | |
---|
150 | |
---|
151 | for(i = 1; i < firstArg[0].size; i++) |
---|
152 | result[0].add(firstArg[0][i]); |
---|
153 | |
---|
154 | for(i = 0; i < secondArg[0].size; i++) |
---|
155 | result[0].add(secondArg[0][i]); |
---|
156 | |
---|
157 | |
---|
158 | result.add(deepCopyList(firstArg[1])); |
---|
159 | |
---|
160 | } |
---|
161 | return result; |
---|
162 | } |
---|
163 | |
---|
164 | function syntheticConjNBRule(firstArg, secondArg) |
---|
165 | { |
---|
166 | var result = Vector.new(); |
---|
167 | |
---|
168 | if(secondArg[0][0] == 0) |
---|
169 | { |
---|
170 | result.add([0,1]); |
---|
171 | var i; |
---|
172 | |
---|
173 | for(i = 0; i < firstArg[0].size; i++) |
---|
174 | result[0].add(firstArg[0][i]); |
---|
175 | |
---|
176 | for(i = 1; i < secondArg[0].size; i++) |
---|
177 | result[0].add(secondArg[0][i]); |
---|
178 | |
---|
179 | result.add(deepCopyList(secondArg[1])); |
---|
180 | |
---|
181 | } |
---|
182 | return result; |
---|
183 | } |
---|
184 | |
---|
185 | function syntheticConjABRule(firstArg, secondArg) |
---|
186 | { |
---|
187 | var result = Vector.new(); |
---|
188 | result.add([1]); |
---|
189 | |
---|
190 | var i; |
---|
191 | |
---|
192 | for(i = 0; i < firstArg[0].size; i++) |
---|
193 | result[0].add(firstArg[0][i]); |
---|
194 | |
---|
195 | for(i = 0; i < secondArg[0].size; i++) |
---|
196 | result[0].add(secondArg[0][i]); |
---|
197 | |
---|
198 | |
---|
199 | result.add(deepCopyList(firstArg[1])); |
---|
200 | |
---|
201 | for(i = 0; i < secondArg[1].size; i++) |
---|
202 | { |
---|
203 | //do not let an entangled literal to be repeated |
---|
204 | if(result[1].find(secondArg[1][i]) == -1) |
---|
205 | result[1].add(deepCopyList(secondArg[1][i])); |
---|
206 | } |
---|
207 | |
---|
208 | return result; |
---|
209 | } |
---|
210 | |
---|
211 | function syntheticNegRule(arg) |
---|
212 | { |
---|
213 | var result = Vector.new(); |
---|
214 | result.add([0,0]); |
---|
215 | |
---|
216 | var i; |
---|
217 | |
---|
218 | for(i = 0; i < arg[0].size; i++) |
---|
219 | result[0].add(arg[0][i]); |
---|
220 | |
---|
221 | result.add(deepCopyList(arg[1])); |
---|
222 | |
---|
223 | return result; |
---|
224 | } |
---|