occam-verify-cli 0.0.1089 → 0.0.1091
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/action/verify.js +2 -2
- package/lib/assertion/contained.js +35 -41
- package/lib/assertion/defined.js +24 -24
- package/lib/assertion/subproof.js +24 -24
- package/lib/assertion/type.js +23 -23
- package/lib/assignment/equality.js +4 -10
- package/lib/assignment/judgement.js +4 -4
- package/lib/assignment/variable.js +4 -4
- package/lib/combinator/bracketed.js +3 -3
- package/lib/conclusion.js +11 -13
- package/lib/consequent.js +11 -13
- package/lib/constructor/bracketed.js +3 -3
- package/lib/constructor.js +2 -2
- package/lib/context/file.js +28 -27
- package/lib/context/local.js +31 -32
- package/lib/context/release.js +6 -3
- package/lib/declaration.js +18 -18
- package/lib/derivation.js +3 -3
- package/lib/equality.js +24 -24
- package/lib/equivalence.js +13 -13
- package/lib/frame.js +43 -43
- package/lib/index.js +2 -1
- package/lib/judgement.js +20 -20
- package/lib/label.js +9 -1
- package/lib/metaType.js +2 -2
- package/lib/metavariable.js +40 -39
- package/lib/mixins/statement/qualified/unify.js +19 -19
- package/lib/mixins/statement/resolve.js +11 -11
- package/lib/mixins/statement/unify.js +12 -12
- package/lib/mixins/statement/verify.js +36 -36
- package/lib/mixins/term/verify.js +2 -2
- package/lib/premise.js +31 -40
- package/lib/proof.js +6 -5
- package/lib/proofStep.js +17 -17
- package/lib/reference.js +8 -8
- package/lib/rule.js +21 -21
- package/lib/statement/qualified.js +17 -17
- package/lib/statement/unqualified.js +19 -19
- package/lib/statement.js +52 -54
- package/lib/subDerivation.js +3 -3
- package/lib/subproof.js +6 -5
- package/lib/substitution/frameForMetavariable.js +16 -39
- package/lib/substitution/statementForMetavariable.js +88 -74
- package/lib/substitution/termForVariable.js +15 -41
- package/lib/substitution.js +20 -6
- package/lib/substitutions.js +13 -13
- package/lib/supposition.js +31 -40
- package/lib/term.js +28 -28
- package/lib/topLevelAssertion.js +33 -21
- package/lib/unifier/equality.js +8 -8
- package/lib/unifier/intrinsicLevel.js +149 -0
- package/lib/unifier/metaLevel.js +41 -31
- package/lib/unifier/metavariable.js +14 -8
- package/lib/unifier/statementWithCombinator.js +16 -16
- package/lib/unifier/termWithConstructor.js +6 -6
- package/lib/unifier.js +47 -47
- package/lib/utilities/assignments.js +3 -3
- package/lib/utilities/equivalences.js +14 -14
- package/lib/utilities/json.js +22 -21
- package/lib/utilities/unifier.js +7 -8
- package/lib/variable.js +33 -33
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verifier/termAsConstructor.js +2 -2
- package/package.json +2 -2
- package/src/assertion/contained.js +37 -45
- package/src/assertion/defined.js +25 -25
- package/src/assertion/subproof.js +25 -28
- package/src/assertion/type.js +23 -23
- package/src/assignment/equality.js +4 -6
- package/src/assignment/judgement.js +4 -4
- package/src/assignment/variable.js +4 -4
- package/src/combinator/bracketed.js +2 -2
- package/src/conclusion.js +14 -15
- package/src/consequent.js +14 -15
- package/src/constructor/bracketed.js +2 -2
- package/src/constructor.js +3 -2
- package/src/context/file.js +26 -25
- package/src/context/local.js +21 -23
- package/src/context/release.js +5 -3
- package/src/declaration.js +20 -20
- package/src/derivation.js +2 -2
- package/src/equality.js +26 -26
- package/src/equivalence.js +12 -12
- package/src/frame.js +42 -42
- package/src/index.js +1 -0
- package/src/judgement.js +25 -25
- package/src/label.js +14 -0
- package/src/metaType.js +1 -1
- package/src/metavariable.js +51 -43
- package/src/mixins/statement/qualified/unify.js +21 -21
- package/src/mixins/statement/resolve.js +12 -12
- package/src/mixins/statement/unify.js +11 -11
- package/src/mixins/statement/verify.js +35 -35
- package/src/mixins/term/verify.js +1 -1
- package/src/premise.js +42 -53
- package/src/proof.js +6 -4
- package/src/proofStep.js +21 -21
- package/src/reference.js +12 -11
- package/src/rule.js +20 -20
- package/src/statement/qualified.js +18 -17
- package/src/statement/unqualified.js +19 -18
- package/src/statement.js +63 -66
- package/src/subDerivation.js +2 -3
- package/src/subproof.js +6 -4
- package/src/substitution/frameForMetavariable.js +29 -45
- package/src/substitution/statementForMetavariable.js +136 -86
- package/src/substitution/termForVariable.js +28 -49
- package/src/substitution.js +15 -5
- package/src/substitutions.js +12 -12
- package/src/supposition.js +41 -53
- package/src/term.js +27 -27
- package/src/topLevelAssertion.js +32 -19
- package/src/unifier/equality.js +7 -7
- package/src/unifier/intrinsicLevel.js +61 -0
- package/src/unifier/metaLevel.js +60 -46
- package/src/unifier/metavariable.js +22 -13
- package/src/unifier/statementWithCombinator.js +28 -28
- package/src/unifier/termWithConstructor.js +8 -8
- package/src/unifier.js +55 -55
- package/src/utilities/assignments.js +2 -2
- package/src/utilities/equivalences.js +13 -13
- package/src/utilities/json.js +76 -66
- package/src/utilities/unifier.js +10 -12
- package/src/variable.js +43 -40
- package/src/verifier/statementAsCombinator.js +2 -1
- package/src/verifier/termAsConstructor.js +2 -1
|
@@ -79,7 +79,7 @@ export function findEquivalenceByTermNodes(equivalences, termNodes) {
|
|
|
79
79
|
return equivalence;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function groundedTermsAndDefinedVariablesFromFromEquivalences(equivalences, groundedTerms, definedVariables,
|
|
82
|
+
export function groundedTermsAndDefinedVariablesFromFromEquivalences(equivalences, groundedTerms, definedVariables, context) {
|
|
83
83
|
let groundedEquivalences,
|
|
84
84
|
remainingEquivalences,
|
|
85
85
|
initiallyGroundedEquivalences,
|
|
@@ -89,7 +89,7 @@ export function groundedTermsAndDefinedVariablesFromFromEquivalences(equivalence
|
|
|
89
89
|
|
|
90
90
|
initiallyGroundedEquivalences = [];
|
|
91
91
|
|
|
92
|
-
separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences,
|
|
92
|
+
separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences, context);
|
|
93
93
|
|
|
94
94
|
const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.length;
|
|
95
95
|
|
|
@@ -105,9 +105,9 @@ export function groundedTermsAndDefinedVariablesFromFromEquivalences(equivalence
|
|
|
105
105
|
while (definedVariablesLength > previousDefinedVariablesLength) {
|
|
106
106
|
previousDefinedVariablesLength = definedVariablesLength; ///
|
|
107
107
|
|
|
108
|
-
groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms,
|
|
108
|
+
groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms, context);
|
|
109
109
|
|
|
110
|
-
definedVariablesFromGroundedTerms(groundedTerms, definedVariables,
|
|
110
|
+
definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context);
|
|
111
111
|
|
|
112
112
|
definedVariablesLength = definedVariables.length;
|
|
113
113
|
}
|
|
@@ -118,7 +118,7 @@ export function groundedTermsAndDefinedVariablesFromFromEquivalences(equivalence
|
|
|
118
118
|
|
|
119
119
|
implicitlyGroundedEquivalences = [];
|
|
120
120
|
|
|
121
|
-
separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalences, implicitlyGroundedEquivalences, definedVariables,
|
|
121
|
+
separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalences, implicitlyGroundedEquivalences, definedVariables, context);
|
|
122
122
|
|
|
123
123
|
push(groundedEquivalences, implicitlyGroundedEquivalences);
|
|
124
124
|
|
|
@@ -137,12 +137,12 @@ function typesFromEquivalences(equivalences) {
|
|
|
137
137
|
return types;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
function definedVariablesFromGroundedTerms(groundedTerms, definedVariables,
|
|
140
|
+
function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
|
|
141
141
|
const terms = groundedTerms, ///
|
|
142
142
|
variables = definedVariables; ///
|
|
143
143
|
|
|
144
144
|
terms.forEach((term) => {
|
|
145
|
-
const termVariables = term.getVariables(
|
|
145
|
+
const termVariables = term.getVariables(context);
|
|
146
146
|
|
|
147
147
|
termVariables.forEach((termVariable) => {
|
|
148
148
|
const variablesIncludesTermVariable = variables.includes(termVariable);
|
|
@@ -156,9 +156,9 @@ function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, loca
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
function separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences,
|
|
159
|
+
function separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences, context) {
|
|
160
160
|
separate(equivalences, remainingEquivalences, initiallyGroundedEquivalences, (equivalence) => {
|
|
161
|
-
const equivalenceInitiallyGrounded = equivalence.isInitiallyGrounded(
|
|
161
|
+
const equivalenceInitiallyGrounded = equivalence.isInitiallyGrounded(context);
|
|
162
162
|
|
|
163
163
|
if (!equivalenceInitiallyGrounded) {
|
|
164
164
|
return true;
|
|
@@ -166,9 +166,9 @@ function separateInitiallyGroundedEquivalences(equivalences, remainingEquivalenc
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
function separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalences, implicitlyGroundedEquivalences, definedVariables,
|
|
169
|
+
function separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalences, implicitlyGroundedEquivalences, definedVariables, context) {
|
|
170
170
|
separate(equivalences, remainingEquivalences, implicitlyGroundedEquivalences, (equivalence) => {
|
|
171
|
-
const equivalenceImplicitlyGrounded = equivalence.isImplicitlyGrounded(definedVariables,
|
|
171
|
+
const equivalenceImplicitlyGrounded = equivalence.isImplicitlyGrounded(definedVariables, context);
|
|
172
172
|
|
|
173
173
|
if (!equivalenceImplicitlyGrounded) {
|
|
174
174
|
return true;
|
|
@@ -176,8 +176,8 @@ function separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalen
|
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
function groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms,
|
|
179
|
+
function groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms, context) {
|
|
180
180
|
groundedEquivalences.forEach((groundedEquivalence) => {
|
|
181
|
-
groundedEquivalence.getGroundedTerms(definedVariables, groundedTerms,
|
|
181
|
+
groundedEquivalence.getGroundedTerms(definedVariables, groundedTerms, context);
|
|
182
182
|
});
|
|
183
183
|
}
|
package/src/utilities/json.js
CHANGED
|
@@ -124,9 +124,10 @@ export function unqualifiedStatementFromJSON(json, fileContext) {
|
|
|
124
124
|
export function typesFromJSON(json, types, fileContext) {
|
|
125
125
|
const { types: typesJSON } = json;
|
|
126
126
|
|
|
127
|
+
const { Type } = shim;
|
|
128
|
+
|
|
127
129
|
typesJSON.forEach((typeJSON) => {
|
|
128
|
-
const
|
|
129
|
-
json = typeJSON, ///
|
|
130
|
+
const json = typeJSON, ///
|
|
130
131
|
type = Type.fromJSON(json, fileContext);
|
|
131
132
|
|
|
132
133
|
types.push(type);
|
|
@@ -136,14 +137,15 @@ export function typesFromJSON(json, types, fileContext) {
|
|
|
136
137
|
export function rulesFromJSON(json, fileContext) {
|
|
137
138
|
let { rules } = json;
|
|
138
139
|
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
const { Rule } = shim,
|
|
141
|
+
rulesJSON = rules; ///
|
|
142
|
+
|
|
143
|
+
rules = rulesJSON.map((ruleJSON) => {
|
|
144
|
+
const json = ruleJSON, ///
|
|
145
|
+
rule = Rule.fromJSON(json, fileContext);
|
|
144
146
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
return (rule);
|
|
148
|
+
});
|
|
147
149
|
|
|
148
150
|
return rules;
|
|
149
151
|
}
|
|
@@ -167,14 +169,15 @@ export function labelsFromJSON(json, fileContext) {
|
|
|
167
169
|
export function axiomsFromJSON(json, fileContext) {
|
|
168
170
|
let { axioms } = json;
|
|
169
171
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
const { Axiom } = shim,
|
|
173
|
-
json = axiomJSON, ///
|
|
174
|
-
axiom = Axiom.fromJSON(json, fileContext);
|
|
172
|
+
const { Axiom } = shim,
|
|
173
|
+
axiomsJSON = axioms; ///
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
axioms = axiomsJSON.map((axiomJSON) => {
|
|
176
|
+
const json = axiomJSON, ///
|
|
177
|
+
axiom = Axiom.fromJSON(json, fileContext);
|
|
178
|
+
|
|
179
|
+
return (axiom);
|
|
180
|
+
});
|
|
178
181
|
|
|
179
182
|
return axioms;
|
|
180
183
|
}
|
|
@@ -198,14 +201,15 @@ export function premisesFromJSON(json, fileContext) {
|
|
|
198
201
|
export function theoremsFromJSON(json, fileContext) {
|
|
199
202
|
let { theorems } = json;
|
|
200
203
|
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
const { Theorem } = shim,
|
|
204
|
-
json = theoremJSON, ///
|
|
205
|
-
theorem = Theorem.fromJSON(json, fileContext);
|
|
204
|
+
const { Theorem } = shim,
|
|
205
|
+
theoremsJSON = theorems; ///
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
theorems = theoremsJSON.map((theoremJSON) => {
|
|
208
|
+
const json = theoremJSON, ///
|
|
209
|
+
theorem = Theorem.fromJSON(json, fileContext);
|
|
210
|
+
|
|
211
|
+
return (theorem);
|
|
212
|
+
});
|
|
209
213
|
|
|
210
214
|
return theorems;
|
|
211
215
|
}
|
|
@@ -213,14 +217,15 @@ export function theoremsFromJSON(json, fileContext) {
|
|
|
213
217
|
export function variablesFromJSON(json, fileContext) {
|
|
214
218
|
let { variables } = json;
|
|
215
219
|
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const { Variable } = shim,
|
|
219
|
-
json = variableJSON, ///
|
|
220
|
-
variable = Variable.fromJSON(json, fileContext);
|
|
220
|
+
const { Variable } = shim,
|
|
221
|
+
variablesJSON = variables; ///
|
|
221
222
|
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
variables = variablesJSON.map((variableJSON) => {
|
|
224
|
+
const json = variableJSON, ///
|
|
225
|
+
variable = Variable.fromJSON(json, fileContext);
|
|
226
|
+
|
|
227
|
+
return (variable);
|
|
228
|
+
});
|
|
224
229
|
|
|
225
230
|
return variables;
|
|
226
231
|
}
|
|
@@ -228,14 +233,15 @@ export function variablesFromJSON(json, fileContext) {
|
|
|
228
233
|
export function conjecturesFromJSON(json, fileContext) {
|
|
229
234
|
let { conjectures } = json;
|
|
230
235
|
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
const { Conjecture } = shim,
|
|
237
|
+
conjecturesJSON = conjectures; ///
|
|
238
|
+
|
|
239
|
+
conjectures = conjecturesJSON.map((conjectureJSON) => {
|
|
240
|
+
const json = conjectureJSON, ///
|
|
241
|
+
conjecture = Conjecture.fromJSON(json, fileContext);
|
|
236
242
|
|
|
237
|
-
|
|
238
|
-
|
|
243
|
+
return (conjecture);
|
|
244
|
+
});
|
|
239
245
|
|
|
240
246
|
return conjectures;
|
|
241
247
|
}
|
|
@@ -243,14 +249,15 @@ export function conjecturesFromJSON(json, fileContext) {
|
|
|
243
249
|
export function combinatorsFromJSON(json, fileContext) {
|
|
244
250
|
let { combinators } = json;
|
|
245
251
|
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
const { Combinator } = shim,
|
|
253
|
+
combinatorsJSON = combinators; ///
|
|
254
|
+
|
|
255
|
+
combinators = combinatorsJSON.map((combinatorJSON) => {
|
|
256
|
+
const json = combinatorJSON, ///
|
|
257
|
+
combinator = Combinator.fromJSON(json, fileContext);
|
|
251
258
|
|
|
252
|
-
|
|
253
|
-
|
|
259
|
+
return (combinator);
|
|
260
|
+
});
|
|
254
261
|
|
|
255
262
|
return combinators;
|
|
256
263
|
}
|
|
@@ -258,14 +265,15 @@ export function combinatorsFromJSON(json, fileContext) {
|
|
|
258
265
|
export function constructorsFromJSON(json, fileContext) {
|
|
259
266
|
let { constructors } = json;
|
|
260
267
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
const { Constructor } = shim,
|
|
264
|
-
json = constructorJSON, ///
|
|
265
|
-
constructor = Constructor.fromJSON(json, fileContext);
|
|
268
|
+
const { Constructor } = shim,
|
|
269
|
+
constructorsJSON = constructors; ///
|
|
266
270
|
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
constructors = constructorsJSON.map((constructorJSON) => {
|
|
272
|
+
const json = constructorJSON, ///
|
|
273
|
+
constructor = Constructor.fromJSON(json, fileContext);
|
|
274
|
+
|
|
275
|
+
return (constructor);
|
|
276
|
+
});
|
|
269
277
|
|
|
270
278
|
return constructors;
|
|
271
279
|
}
|
|
@@ -273,14 +281,15 @@ export function constructorsFromJSON(json, fileContext) {
|
|
|
273
281
|
export function metatheoremsFromJSON(json, fileContext) {
|
|
274
282
|
let { metatheorems } = json;
|
|
275
283
|
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
const { Metatheorem } = shim,
|
|
279
|
-
json = metatheoremJSON, ///
|
|
280
|
-
metatheorem = Metatheorem.fromJSON(json, fileContext);
|
|
284
|
+
const { Metatheorem } = shim,
|
|
285
|
+
metatheoremsJSON = metatheorems; ///
|
|
281
286
|
|
|
282
|
-
|
|
283
|
-
|
|
287
|
+
metatheorems = metatheoremsJSON.map((metatheoremJSON) => {
|
|
288
|
+
const json = metatheoremJSON, ///
|
|
289
|
+
metatheorem = Metatheorem.fromJSON(json, fileContext);
|
|
290
|
+
|
|
291
|
+
return (metatheorem);
|
|
292
|
+
});
|
|
284
293
|
|
|
285
294
|
return metatheorems;
|
|
286
295
|
}
|
|
@@ -304,7 +313,7 @@ export function suppositionsFromJSON(json, fileContext) {
|
|
|
304
313
|
export function substitutionsFromJSON(json, fileContext) {
|
|
305
314
|
let { substitutions = [] } = json; ///
|
|
306
315
|
|
|
307
|
-
const { Substitution } = shim,
|
|
316
|
+
const { StatementForMetavariableSubstitution: Substitution } = shim, ///
|
|
308
317
|
substitutionsJSON = substitutions; ///
|
|
309
318
|
|
|
310
319
|
substitutions = substitutionsJSON.map((substitutionJSON) => {
|
|
@@ -320,14 +329,15 @@ export function substitutionsFromJSON(json, fileContext) {
|
|
|
320
329
|
export function metavariablesFromJSON(json, fileContext) {
|
|
321
330
|
let { metavariables } = json;
|
|
322
331
|
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const { Metavariable } = shim,
|
|
326
|
-
json = metavariableJSON, ///
|
|
327
|
-
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
332
|
+
const { Metavariable } = shim,
|
|
333
|
+
metavariablesJSON = metavariables; ///
|
|
328
334
|
|
|
329
|
-
|
|
330
|
-
|
|
335
|
+
metavariables = metavariablesJSON.map((metavariableJSON) => {
|
|
336
|
+
const json = metavariableJSON, ///
|
|
337
|
+
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
338
|
+
|
|
339
|
+
return (metavariable);
|
|
340
|
+
});
|
|
331
341
|
|
|
332
342
|
return metavariables;
|
|
333
343
|
}
|
package/src/utilities/unifier.js
CHANGED
|
@@ -20,26 +20,24 @@ export function terminalNodeMapFromNodes(nodes) {
|
|
|
20
20
|
return terminalNodeMap;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function areTerminalNodeMapsEqual(
|
|
23
|
+
export function areTerminalNodeMapsEqual(generalTerminalNodeMap, specificTerminalNodeMap) {
|
|
24
24
|
let terminalNodeMapsEqual = false;
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
terminalNodeMapKeysMatch = match(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (matches) {
|
|
26
|
+
const generalIndexes = Object.keys(generalTerminalNodeMap), ///
|
|
27
|
+
specificIndexes = Object.keys(specificTerminalNodeMap), ///
|
|
28
|
+
terminalNodeMapKeysMatch = match(generalIndexes, specificIndexes, (generalIndex, specificIndex) => {
|
|
29
|
+
if (generalIndex === specificIndex) {
|
|
32
30
|
return true;
|
|
33
31
|
}
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
if (terminalNodeMapKeysMatch) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
terminalNodeMapValuesMatch = match(
|
|
40
|
-
const
|
|
35
|
+
const generalTerminalNodes = Object.values(generalTerminalNodeMap), ///
|
|
36
|
+
specificTerminalNodes = Object.values(specificTerminalNodeMap), ///
|
|
37
|
+
terminalNodeMapValuesMatch = match(generalTerminalNodes, specificTerminalNodes, (generalTerminalNode, specficTerminalNode) => {
|
|
38
|
+
const generalTerminalNodeMatchesSpecificTerminalNode = generalTerminalNode.match(specficTerminalNode);
|
|
41
39
|
|
|
42
|
-
if (
|
|
40
|
+
if (generalTerminalNodeMatchesSpecificTerminalNode) {
|
|
43
41
|
return true;
|
|
44
42
|
}
|
|
45
43
|
});
|
package/src/variable.js
CHANGED
|
@@ -15,8 +15,8 @@ const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
|
|
|
15
15
|
termVariableNodeQuery = nodeQuery("/term/variable");
|
|
16
16
|
|
|
17
17
|
class Variable {
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
18
|
+
constructor(context, string, node, name, type) {
|
|
19
|
+
this.context = context; ///
|
|
20
20
|
this.string = string;
|
|
21
21
|
this.node = node;
|
|
22
22
|
this.name = name;
|
|
@@ -24,7 +24,7 @@ class Variable {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
getLocalContext() {
|
|
27
|
-
return this.
|
|
27
|
+
return this.context;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
getString() {
|
|
@@ -59,16 +59,16 @@ class Variable {
|
|
|
59
59
|
return variableNodeMatches;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
verify(
|
|
62
|
+
verify(context) {
|
|
63
63
|
let verified;
|
|
64
64
|
|
|
65
65
|
const variableString = this.string; ///
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
context.trace(`Verifying the '${variableString}' variable...`);
|
|
68
68
|
|
|
69
69
|
const variableNode = this.node, ///
|
|
70
70
|
variableName = variableNameFromVariableNode(variableNode),
|
|
71
|
-
variable =
|
|
71
|
+
variable = context.findVariableByVariableName(variableName);
|
|
72
72
|
|
|
73
73
|
if (variable !== null) {
|
|
74
74
|
const type = variable.getType();
|
|
@@ -77,13 +77,13 @@ class Variable {
|
|
|
77
77
|
|
|
78
78
|
verified = true;
|
|
79
79
|
} else {
|
|
80
|
-
|
|
80
|
+
context.debug(`The '${variableString}' variable is not present.`);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (verified) {
|
|
84
84
|
const typeName = this.type.getName();
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
context.debug(`...verified the '${variableString}:${typeName}' variable.`);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return verified;
|
|
@@ -143,13 +143,13 @@ class Variable {
|
|
|
143
143
|
return verifiedAtTopLevel;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
unifyTerm(term, substitutions,
|
|
146
|
+
unifyTerm(term, substitutions, generalContext, specificContext) {
|
|
147
147
|
let termUnified = false;
|
|
148
148
|
|
|
149
149
|
const termString = term.getString(),
|
|
150
150
|
variableString = this.string; ///
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
specificContext.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
|
|
153
153
|
|
|
154
154
|
const termNode = term.getNode(),
|
|
155
155
|
variableName = this.name, ///
|
|
@@ -163,24 +163,25 @@ class Variable {
|
|
|
163
163
|
}
|
|
164
164
|
} else {
|
|
165
165
|
const variableNode = this.node, ///
|
|
166
|
-
variable = variableFromVariableNode(variableNode,
|
|
167
|
-
termVariable = termVariableFromTermNode(termNode,
|
|
166
|
+
variable = variableFromVariableNode(variableNode, generalContext, specificContext),
|
|
167
|
+
termVariable = termVariableFromTermNode(termNode, generalContext, specificContext);
|
|
168
168
|
|
|
169
169
|
if ((variable !== null) && (variable === termVariable)) {
|
|
170
170
|
termUnified = true;
|
|
171
171
|
} else {
|
|
172
|
-
const
|
|
173
|
-
|
|
172
|
+
const context = specificContext, ///
|
|
173
|
+
variable = this, ///
|
|
174
|
+
termForVariableSubstitution = TermForVariableSubstitution.fromTernAndVariable(term, variable, context),
|
|
174
175
|
substitution = termForVariableSubstitution; ///
|
|
175
176
|
|
|
176
|
-
substitutions.addSubstitution(substitution,
|
|
177
|
+
substitutions.addSubstitution(substitution, context);
|
|
177
178
|
|
|
178
179
|
termUnified = true;
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
if (termUnified) {
|
|
183
|
-
|
|
184
|
+
specificContext.trace(`...unified the '${termString}' term with the '${variableString}' variable.`);
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
return termUnified;
|
|
@@ -205,16 +206,16 @@ class Variable {
|
|
|
205
206
|
variableString = string, ///
|
|
206
207
|
variableNode = variableNodeFromVariableString(variableString, lexer, parser),
|
|
207
208
|
variableName = variableNameFromVariableNode(variableNode),
|
|
208
|
-
|
|
209
|
+
context = LocalContext.fromFileContext(fileContext),
|
|
209
210
|
node = variableNode,
|
|
210
211
|
name = variableName, ///
|
|
211
212
|
type = typeFromJSON(json, fileContext),
|
|
212
|
-
variable = new Variable(
|
|
213
|
+
variable = new Variable(context, string, node, name, type);
|
|
213
214
|
|
|
214
215
|
return variable;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
static fromTermNode(termNode,
|
|
218
|
+
static fromTermNode(termNode, context) {
|
|
218
219
|
let variable = null;
|
|
219
220
|
|
|
220
221
|
const termVariableNode = termVariableNodeQuery(termNode);
|
|
@@ -223,42 +224,42 @@ class Variable {
|
|
|
223
224
|
const variableNode = termVariableNode, ///
|
|
224
225
|
variableName = variableNameFromVariableNode(variableNode),
|
|
225
226
|
node = variableNode, ///
|
|
226
|
-
string =
|
|
227
|
+
string = context.nodeAsString(node),
|
|
227
228
|
name = variableName, ///
|
|
228
229
|
type = null;
|
|
229
230
|
|
|
230
|
-
variable = new Variable(
|
|
231
|
+
variable = new Variable(context, string, node, name, type);
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
return variable;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
static fromVariableNode(variableNode,
|
|
237
|
+
static fromVariableNode(variableNode, context) {
|
|
237
238
|
let variable = null;
|
|
238
239
|
|
|
239
240
|
if (variableNode !== null) {
|
|
240
241
|
const node = variableNode, ///
|
|
241
242
|
variableName = variableNameFromVariableNode(variableNode),
|
|
242
|
-
string =
|
|
243
|
+
string = context.nodeAsString(node),
|
|
243
244
|
name = variableName, ///
|
|
244
245
|
type = null;
|
|
245
246
|
|
|
246
|
-
variable = new Variable(
|
|
247
|
+
variable = new Variable(context, string, node, name, type);
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
return variable;
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
static fromVariableNodeAndType(variableNode, type,
|
|
253
|
+
static fromVariableNodeAndType(variableNode, type, context) {
|
|
253
254
|
let variable = null;
|
|
254
255
|
|
|
255
256
|
if (variableNode !== null) {
|
|
256
257
|
const node = variableNode, ///
|
|
257
258
|
variableName = variableNameFromVariableNode(variableNode),
|
|
258
|
-
string =
|
|
259
|
+
string = context.nodeAsString(node),
|
|
259
260
|
name = variableName; ///
|
|
260
261
|
|
|
261
|
-
variable = new Variable(
|
|
262
|
+
variable = new Variable(context, string, node, name, type);
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
return variable;
|
|
@@ -269,13 +270,13 @@ class Variable {
|
|
|
269
270
|
typeNode = typeNodeQuery(variableDeclarationNode),
|
|
270
271
|
variableNode = variableNodeQuery(variableDeclarationNode),
|
|
271
272
|
variableName = variableNameFromVariableNode(variableNode),
|
|
272
|
-
|
|
273
|
+
context = LocalContext.fromFileContext(fileContext),
|
|
273
274
|
variableString = fileContext.nodeAsString(variableNode),
|
|
274
275
|
string = variableString, ///
|
|
275
276
|
node = variableNode, ///
|
|
276
277
|
name = variableName, ///
|
|
277
|
-
type = Type.fromTypeNode(typeNode,
|
|
278
|
-
variable = new Variable(
|
|
278
|
+
type = Type.fromTypeNode(typeNode, context),
|
|
279
|
+
variable = new Variable(context, string, node, name, type);
|
|
279
280
|
|
|
280
281
|
return variable;
|
|
281
282
|
}
|
|
@@ -287,23 +288,25 @@ Object.assign(shim, {
|
|
|
287
288
|
|
|
288
289
|
export default Variable;
|
|
289
290
|
|
|
290
|
-
function
|
|
291
|
+
function variableFromVariableNode(variableNode, generalContext, specificContext) {
|
|
292
|
+
const variableName = variableNameFromVariableNode(variableNode),
|
|
293
|
+
context = generalContext, ///
|
|
294
|
+
variable = context.findVariableByVariableName(variableName);
|
|
295
|
+
|
|
296
|
+
return variable;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function termVariableFromTermNode(termNode, specificContext, generalContext) {
|
|
291
300
|
let termVariable = null;
|
|
292
301
|
|
|
293
302
|
const termVariableNode = termVariableNodeQuery(termNode);
|
|
294
303
|
|
|
295
304
|
if (termVariableNode !== null) {
|
|
296
|
-
const termVariableName = variableNameFromVariableNode(termVariableNode)
|
|
305
|
+
const termVariableName = variableNameFromVariableNode(termVariableNode),
|
|
306
|
+
context = generalContext; ///
|
|
297
307
|
|
|
298
|
-
termVariable =
|
|
308
|
+
termVariable = context.findVariableByVariableName(termVariableName);
|
|
299
309
|
}
|
|
300
310
|
|
|
301
311
|
return termVariable;
|
|
302
312
|
}
|
|
303
|
-
|
|
304
|
-
function variableFromVariableNode(variableNode, localContext) {
|
|
305
|
-
const variableName = variableNameFromVariableNode(variableNode),
|
|
306
|
-
variable = localContext.findVariableByVariableName(variableName);
|
|
307
|
-
|
|
308
|
-
return variable;
|
|
309
|
-
}
|
|
@@ -29,7 +29,8 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
29
29
|
verify: (termNode, fileContext) => {
|
|
30
30
|
const { Term } = shim,
|
|
31
31
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
32
|
-
|
|
32
|
+
context = localContext, ///
|
|
33
|
+
term = Term.fromTermNode(termNode, context),
|
|
33
34
|
termVerified = term.verify(localContext, () => {
|
|
34
35
|
const verifiedAhead = true;
|
|
35
36
|
|
|
@@ -33,7 +33,8 @@ class TermAsConstructorVerifier extends Verifier {
|
|
|
33
33
|
verify: (termNode, fileContext, verifyAhead) => {
|
|
34
34
|
const { Term } = shim,
|
|
35
35
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
36
|
-
|
|
36
|
+
context = localContext, ///
|
|
37
|
+
term = Term.fromTermNode(termNode, context),
|
|
37
38
|
termVerified = term.verify(localContext, verifyAhead);
|
|
38
39
|
|
|
39
40
|
return termVerified;
|