occam-verify-cli 0.0.932 → 0.0.934
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/lib/conclusion.js +4 -4
- package/lib/consequent.js +4 -4
- package/lib/context/local.js +188 -9
- package/lib/declaration.js +2 -2
- package/lib/equality.js +4 -4
- package/lib/equivalence.js +16 -1
- package/lib/metaLemma.js +4 -4
- package/lib/metatheorem.js +4 -4
- package/lib/premise.js +6 -6
- package/lib/proofStep.js +43 -6
- package/lib/shim.js +14 -0
- package/lib/substitution/statementForMetavariable.js +46 -2
- package/lib/substitution/termForVariable.js +15 -1
- package/lib/supposition.js +6 -6
- package/lib/unifier/equality.js +216 -0
- package/lib/unifier/metaLevel.js +235 -0
- package/lib/unifier/statementAgainstCombinator.js +232 -0
- package/lib/unifier/termAgainstConstructor.js +212 -0
- package/lib/unifier.js +201 -0
- package/lib/unify/argumentAgainstArgument.js +24 -0
- package/lib/unify/metavariableAgainstStatement.js +66 -0
- package/lib/unify/statementAgainstMetaType.js +28 -0
- package/lib/unify/statementAtainstStatement.js +52 -0
- package/lib/unify/termAgainstTerm.js +22 -0
- package/lib/unify/termAgainstType.js +26 -0
- package/lib/unify/variableAgainstTerm.js +70 -0
- package/lib/verifier/metaLevel.js +236 -0
- package/lib/verifier/statementAsCombinator.js +236 -0
- package/lib/verifier/termAsConstructor.js +219 -0
- package/lib/verifier.js +182 -0
- package/lib/verify/assertion/contained.js +2 -2
- package/lib/verify/assertion/defined.js +2 -2
- package/lib/verify/declaration.js +18 -18
- package/lib/verify/frame.js +9 -12
- package/lib/verify/proofStep.js +3 -3
- package/lib/verify/statement/qualified.js +61 -10
- package/lib/verify/statement/unqualified.js +62 -50
- package/lib/verify/statement.js +36 -41
- package/lib/verify/statementAsCombinator.js +2 -2
- package/lib/verify/subDerivation.js +8 -2
- package/lib/verify/term.js +8 -7
- package/lib/verify/termAsConstructor.js +2 -2
- package/package.json +2 -2
- package/src/conclusion.js +3 -3
- package/src/consequent.js +3 -3
- package/src/context/local.js +68 -8
- package/src/declaration.js +2 -2
- package/src/equality.js +3 -3
- package/src/equivalence.js +19 -0
- package/src/metaLemma.js +1 -1
- package/src/metatheorem.js +1 -1
- package/src/premise.js +5 -5
- package/src/proofStep.js +57 -4
- package/src/shim.js +5 -0
- package/src/substitution/statementForMetavariable.js +33 -2
- package/src/substitution/termForVariable.js +16 -0
- package/src/supposition.js +5 -5
- package/src/unifier/equality.js +84 -0
- package/src/unifier/metaLevel.js +114 -0
- package/src/unifier/statementAgainstCombinator.js +105 -0
- package/src/unifier/termAgainstConstructor.js +77 -0
- package/src/unifier.js +133 -0
- package/src/unify/argumentAgainstArgument.js +15 -0
- package/src/{verify → unify}/metavariableAgainstStatement.js +18 -18
- package/src/{verify → unify}/statementAgainstMetaType.js +4 -4
- package/src/{verify → unify}/statementAtainstStatement.js +7 -7
- package/src/{verify → unify}/termAgainstTerm.js +5 -5
- package/src/{verify → unify}/termAgainstType.js +7 -7
- package/src/{verify → unify}/variableAgainstTerm.js +6 -6
- package/src/verifier/{node/metaLevel.js → metaLevel.js} +14 -14
- package/src/verifier/{node/statementAsCombinator.js → statementAsCombinator.js} +14 -14
- package/src/verifier/{node/termAsConstructor.js → termAsConstructor.js} +12 -12
- package/src/{verifier/node.js → verifier.js} +19 -1
- package/src/verify/assertion/contained.js +2 -2
- package/src/verify/assertion/defined.js +2 -2
- package/src/verify/declaration.js +20 -23
- package/src/verify/frame.js +10 -13
- package/src/verify/proofStep.js +2 -2
- package/src/verify/statement/qualified.js +95 -10
- package/src/verify/statement/unqualified.js +85 -11
- package/src/verify/statement.js +47 -45
- package/src/verify/statementAsCombinator.js +2 -2
- package/src/verify/subDerivation.js +3 -1
- package/src/verify/term.js +7 -6
- package/src/verify/termAsConstructor.js +2 -2
- package/lib/mixins/context.js +0 -135
- package/lib/mixins/nodesVerifier/intrinsiclevel.js +0 -59
- package/lib/mixins/nodesVerifier/metaLevel.js +0 -40
- package/lib/utilities/verifier.js +0 -80
- package/lib/verifier/node/metaLevel.js +0 -201
- package/lib/verifier/node/statementAsCombinator.js +0 -201
- package/lib/verifier/node/termAsConstructor.js +0 -184
- package/lib/verifier/node.js +0 -157
- package/lib/verifier/nodes/equality.js +0 -176
- package/lib/verifier/nodes/metaLevel.js +0 -191
- package/lib/verifier/nodes/statementAgainstCombinator.js +0 -191
- package/lib/verifier/nodes/termAgainstConstructor.js +0 -171
- package/lib/verifier/nodes.js +0 -175
- package/lib/verify/argumentAgainstArgument.js +0 -24
- package/lib/verify/metavariableAgainstStatement.js +0 -66
- package/lib/verify/statementAgainstMetaType.js +0 -28
- package/lib/verify/statementAtainstStatement.js +0 -52
- package/lib/verify/termAgainstTerm.js +0 -22
- package/lib/verify/termAgainstType.js +0 -26
- package/lib/verify/variableAgainstTerm.js +0 -70
- package/src/mixins/context.js +0 -96
- package/src/mixins/nodesVerifier/intrinsiclevel.js +0 -73
- package/src/mixins/nodesVerifier/metaLevel.js +0 -39
- package/src/utilities/verifier.js +0 -38
- package/src/verifier/nodes/equality.js +0 -84
- package/src/verifier/nodes/metaLevel.js +0 -109
- package/src/verifier/nodes/statementAgainstCombinator.js +0 -105
- package/src/verifier/nodes/termAgainstConstructor.js +0 -76
- package/src/verifier/nodes.js +0 -114
- package/src/verify/argumentAgainstArgument.js +0 -15
package/src/context/local.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import Variable from "../variable";
|
|
4
4
|
import Equivalence from "../equivalence";
|
|
5
|
-
import contextMixins from "../mixins/context";
|
|
6
5
|
|
|
7
6
|
import { last, reverse } from "../utilities/array";
|
|
8
7
|
import { mergeEquivalences, findEquivalenceByTerm, groundedTermsAndDefinedVariablesFromFromEquivalences } from "../utilities/equivalences";
|
|
@@ -89,6 +88,18 @@ class LocalContext {
|
|
|
89
88
|
return lastProofStep;
|
|
90
89
|
}
|
|
91
90
|
|
|
91
|
+
getAxioms() { return this.context.getAxioms(); }
|
|
92
|
+
|
|
93
|
+
getLemmas() { return this.context.getLemmas(); }
|
|
94
|
+
|
|
95
|
+
getTheorems() { return this.context.getTheorems(); }
|
|
96
|
+
|
|
97
|
+
getConjectures() { return this.context.getConjectures(); }
|
|
98
|
+
|
|
99
|
+
getCombinators() { return this.context.getCombinators(); }
|
|
100
|
+
|
|
101
|
+
getConstructors() { return this.context.getConstructors(); }
|
|
102
|
+
|
|
92
103
|
addEquality(equality) {
|
|
93
104
|
let equalityAdded;
|
|
94
105
|
|
|
@@ -217,20 +228,23 @@ class LocalContext {
|
|
|
217
228
|
return metavariableAdded;
|
|
218
229
|
}
|
|
219
230
|
|
|
220
|
-
|
|
231
|
+
unifyStatement(statementNode) {
|
|
221
232
|
let proofSteps = this.getProofSteps();
|
|
222
233
|
|
|
223
234
|
proofSteps = reverse(proofSteps); ///
|
|
224
235
|
|
|
225
|
-
const
|
|
226
|
-
|
|
236
|
+
const localContext = this, ///
|
|
237
|
+
equivalences = this.getEquivalences();
|
|
227
238
|
|
|
228
|
-
|
|
239
|
+
const statementUnified = proofSteps.some((proofStep) => {
|
|
240
|
+
const statementUnified = proofStep.unifyStatement(statementNode, equivalences, localContext);
|
|
241
|
+
|
|
242
|
+
if (statementUnified) {
|
|
229
243
|
return true;
|
|
230
244
|
}
|
|
231
245
|
});
|
|
232
246
|
|
|
233
|
-
return
|
|
247
|
+
return statementUnified;
|
|
234
248
|
}
|
|
235
249
|
|
|
236
250
|
getTermType(term) {
|
|
@@ -305,6 +319,14 @@ class LocalContext {
|
|
|
305
319
|
return judgementPresent;
|
|
306
320
|
}
|
|
307
321
|
|
|
322
|
+
isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
|
|
323
|
+
|
|
324
|
+
isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentByTypeNode(typeNode); }
|
|
325
|
+
|
|
326
|
+
isMetavariablePresentByName(name) { return this.context.isMetavariablePresentByName(name); }
|
|
327
|
+
|
|
328
|
+
isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
329
|
+
|
|
308
330
|
isMetavariablePresentByMetavariableNode(metavariableNode) {
|
|
309
331
|
const metavariable = this.findMetavariableByMetavariableNode(metavariableNode),
|
|
310
332
|
metavariablePresent = (metavariable !== null);
|
|
@@ -354,6 +376,46 @@ class LocalContext {
|
|
|
354
376
|
return metavariable;
|
|
355
377
|
}
|
|
356
378
|
|
|
379
|
+
findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
380
|
+
|
|
381
|
+
findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
382
|
+
|
|
383
|
+
findMetavariableByName(name) { return this.context.findMetavariableByName(name); }
|
|
384
|
+
|
|
385
|
+
findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
386
|
+
|
|
387
|
+
findMetaTypeByMetaTypeNode(metaTypeNode) { return this.context.findMetaTypeByMetaTypeNode(metaTypeNode); }
|
|
388
|
+
|
|
389
|
+
findRuleByMetavariableNode(metavariableNode) { return this.context.findRuleByMetavariableNode(metavariableNode); }
|
|
390
|
+
|
|
391
|
+
findAxiomByMetavariableNode(metavariableNode) { return this.context.findAxiomByMetavariableNode(metavariableNode); }
|
|
392
|
+
|
|
393
|
+
findLemmaByMetavariableNode(metavariableNode) { return this.context.findLemmaByMetavariableNode(metavariableNode); }
|
|
394
|
+
|
|
395
|
+
findTheoremByMetavariableNode(metavariableNode) { return this.context.findTheoremByMetavariableNode(metavariableNode); }
|
|
396
|
+
|
|
397
|
+
findMetaLemmaByMetavariableNode(metavariableNode) { return this.context.findMetaLemmaByMetavariableNode(metavariableNode); }
|
|
398
|
+
|
|
399
|
+
findConjectureByMetavariableNode(metavariableNode) { return this.context.findConjectureByMetavariableNode(metavariableNode); }
|
|
400
|
+
|
|
401
|
+
findMetatheoremByMetavariableNode(metavariableNode) { return this.context.findMetatheoremByMetavariableNode(metavariableNode); }
|
|
402
|
+
|
|
403
|
+
nodeAsString(node) { return this.context.nodeAsString(node); }
|
|
404
|
+
|
|
405
|
+
nodesAsString(node) { return this.context.nodesAsString(node); }
|
|
406
|
+
|
|
407
|
+
trace(node, message) { this.context.trace(node, message); }
|
|
408
|
+
|
|
409
|
+
debug(node, message) { this.context.debug(node, message); }
|
|
410
|
+
|
|
411
|
+
info(node, message) { this.context.info(node, message); }
|
|
412
|
+
|
|
413
|
+
warning(node, message) { this.context.warning(node, message); }
|
|
414
|
+
|
|
415
|
+
error(node, message) { this.context.error(node, message); }
|
|
416
|
+
|
|
417
|
+
fatal(node, message) { this.context.fatal(node, message); }
|
|
418
|
+
|
|
357
419
|
static fromFileContext(fileContext) {
|
|
358
420
|
const context = fileContext, ///
|
|
359
421
|
variables = [],
|
|
@@ -402,6 +464,4 @@ class LocalContext {
|
|
|
402
464
|
}
|
|
403
465
|
}
|
|
404
466
|
|
|
405
|
-
Object.assign(LocalContext.prototype, contextMixins);
|
|
406
|
-
|
|
407
467
|
export default LocalContext;
|
package/src/declaration.js
CHANGED
|
@@ -42,8 +42,8 @@ export default class Declaration {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) {
|
|
45
|
-
const
|
|
46
|
-
statementNode =
|
|
45
|
+
const consequent = metaLemmaMetatheorem.getConsequent(),
|
|
46
|
+
statementNode = consequent.getStatementNode(),
|
|
47
47
|
matches = this.statementNode.match(statementNode),
|
|
48
48
|
matchesMetaLemmaOrMetaTheorem = matches; ///
|
|
49
49
|
|
package/src/equality.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import equalityUnifier from "./unifier/equality";
|
|
4
4
|
|
|
5
5
|
export default class Equality {
|
|
6
6
|
constructor(node, leftTerm, rightTerm) {
|
|
@@ -33,12 +33,12 @@ export default class Equality {
|
|
|
33
33
|
rightTermNode = this.rightTerm.getNode(),
|
|
34
34
|
nonTerminalNodeA = leftTermNode, ///
|
|
35
35
|
nonTerminalNodeB = rightTermNode, ///
|
|
36
|
-
|
|
36
|
+
nonTerminalNodeUnified = equalityUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext, () => {
|
|
37
37
|
const verifiedAhead = true;
|
|
38
38
|
|
|
39
39
|
return verifiedAhead;
|
|
40
40
|
}),
|
|
41
|
-
equal =
|
|
41
|
+
equal = nonTerminalNodeUnified; ///
|
|
42
42
|
|
|
43
43
|
return equal;
|
|
44
44
|
}
|
package/src/equivalence.js
CHANGED
|
@@ -95,6 +95,25 @@ export default class Equivalence {
|
|
|
95
95
|
return matchesTermNode;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
matchVariableNode(variableNode) {
|
|
99
|
+
const variableNodeA = variableNode, ///
|
|
100
|
+
matchesVariableNode = this.terms.some((term) => {
|
|
101
|
+
const termNode = term.getNode(),
|
|
102
|
+
variableNode = variableNodeQuery(termNode);
|
|
103
|
+
|
|
104
|
+
if (variableNode !== null) {
|
|
105
|
+
const variableNodeB = variableNode, ///
|
|
106
|
+
variableNodeAMatchesVariableNodeB = variableNodeA.match(variableNodeB);
|
|
107
|
+
|
|
108
|
+
if (variableNodeAMatchesVariableNodeB) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return matchesVariableNode;
|
|
115
|
+
}
|
|
116
|
+
|
|
98
117
|
matchTermNodes(termNodes) {
|
|
99
118
|
const matchesTermNodes = termNodes.every((termNode) => {
|
|
100
119
|
const matchesTermNode = this.matchTermNode(termNode);
|
package/src/metaLemma.js
CHANGED
|
@@ -5,5 +5,5 @@ import TopLevelAssertion from "./topLevelAssertion";
|
|
|
5
5
|
export default class MetaLemma extends TopLevelAssertion {
|
|
6
6
|
static fromJSONAndFileContext(json, fileContext) { return TopLevelAssertion.fromJSONAndFileContext(MetaLemma, json, fileContext); }
|
|
7
7
|
|
|
8
|
-
static
|
|
8
|
+
static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return MetaLemma.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Metatheorem, labels, suppositions, consequent, substitutions, fileContext); }
|
|
9
9
|
}
|
package/src/metatheorem.js
CHANGED
|
@@ -5,5 +5,5 @@ import TopLevelAssertion from "./topLevelAssertion";
|
|
|
5
5
|
export default class Metatheorem extends TopLevelAssertion {
|
|
6
6
|
static fromJSONAndFileContext(json, fileContext) { return TopLevelAssertion.fromJSONAndFileContext(Metatheorem, json, fileContext); }
|
|
7
7
|
|
|
8
|
-
static
|
|
8
|
+
static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return TopLevelAssertion.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Metatheorem, labels, suppositions, consequent, substitutions, fileContext); }
|
|
9
9
|
}
|
package/src/premise.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import LocalContext from "./context/local";
|
|
4
|
-
import
|
|
4
|
+
import metaLevelUnifier from "./unifier/metaLevel";
|
|
5
5
|
|
|
6
6
|
import { match } from "./utilities/array";
|
|
7
7
|
import { nodeAsString } from "./utilities/string";
|
|
@@ -31,13 +31,13 @@ export default class Premise {
|
|
|
31
31
|
nonTerminalNodeB = statementNode, ///
|
|
32
32
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
33
33
|
localContextB = localContext, ///
|
|
34
|
-
|
|
34
|
+
nonTerminalNodeUnified = metaLevelUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
35
35
|
const verifiedAhead = true;
|
|
36
36
|
|
|
37
37
|
return verifiedAhead;
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
matchesStatementNode =
|
|
40
|
+
matchesStatementNode = nonTerminalNodeUnified; ///
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return matchesStatementNode;
|
|
@@ -64,13 +64,13 @@ export default class Premise {
|
|
|
64
64
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
65
65
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
66
66
|
localContextB = localContext, ///
|
|
67
|
-
|
|
67
|
+
nonTerminalNodeUnified = metaLevelUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
68
|
const verifiedAhead = true;
|
|
69
69
|
|
|
70
70
|
return verifiedAhead;
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
if (
|
|
73
|
+
if (nonTerminalNodeUnified) {
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
});
|
package/src/proofStep.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import metaLevelUnifier from "./unifier/metaLevel";
|
|
4
|
+
|
|
3
5
|
export default class ProofStep {
|
|
4
6
|
constructor(subproofNode, statementNode) {
|
|
5
7
|
this.subproofNode = subproofNode;
|
|
@@ -14,14 +16,30 @@ export default class ProofStep {
|
|
|
14
16
|
return this.statementNode;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
+
unifyStatement(statementNode, equivalences, localContext) {
|
|
20
|
+
let statementUnified = false;
|
|
19
21
|
|
|
20
22
|
if (this.statementNode !== null) {
|
|
21
|
-
|
|
23
|
+
let statementUnifiedAgainstStatement = false;
|
|
24
|
+
|
|
25
|
+
if (!statementUnifiedAgainstStatement) {
|
|
26
|
+
const statementNodeA = statementNode, ///
|
|
27
|
+
statementNodeB = this.statementNode; ///
|
|
28
|
+
|
|
29
|
+
statementUnifiedAgainstStatement = unifyStatementAgainstStatement(statementNodeA, statementNodeB, equivalences, localContext);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!statementUnifiedAgainstStatement) {
|
|
33
|
+
const statementNodeA = statementNode, ///
|
|
34
|
+
statementNodeB = this.statementNode; ///
|
|
35
|
+
|
|
36
|
+
statementUnifiedAgainstStatement = unifyStatementAgainstStatement(statementNodeA, statementNodeB, equivalences, localContext);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
statementUnified = statementUnifiedAgainstStatement; ///
|
|
22
40
|
}
|
|
23
41
|
|
|
24
|
-
return
|
|
42
|
+
return statementUnified;
|
|
25
43
|
}
|
|
26
44
|
|
|
27
45
|
static fromSubproofNode(subproofNode) {
|
|
@@ -38,3 +56,38 @@ export default class ProofStep {
|
|
|
38
56
|
return proofStep;
|
|
39
57
|
}
|
|
40
58
|
}
|
|
59
|
+
|
|
60
|
+
function unifyStatementAgainstStatement(statementNodeA, statementNodeB, equivalences, localContext) {
|
|
61
|
+
let statementUnifiedAgainstStatement = false;
|
|
62
|
+
|
|
63
|
+
const nonTerminalNodeA = statementNodeA, ///
|
|
64
|
+
nonTerminalNodeB = statementNodeB, ///
|
|
65
|
+
substitutions = [],
|
|
66
|
+
localContextA = localContext, ///
|
|
67
|
+
localContextB = localContext, ///
|
|
68
|
+
nonTerminalNodeUnified = metaLevelUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
69
|
+
const verifiedAhead = true;
|
|
70
|
+
|
|
71
|
+
return verifiedAhead;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (nonTerminalNodeUnified) {
|
|
75
|
+
const substitutionsUnified = substitutions.every((substitution) => {
|
|
76
|
+
const substitutionUnified = equivalences.some((equivalence) => {
|
|
77
|
+
const substitutionUnifiedAgainstEquivalence = substitution.unifyAgainstEquivalence(equivalence, substitutions, localContext);
|
|
78
|
+
|
|
79
|
+
if (substitutionUnifiedAgainstEquivalence) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (substitutionUnified) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
statementUnifiedAgainstStatement = substitutionsUnified; ///
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return statementUnifiedAgainstStatement;
|
|
93
|
+
}
|
package/src/shim.js
ADDED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "../shim";
|
|
3
4
|
import Substitution from "../substitution";
|
|
4
5
|
import TermForVariableSubstitution from "./termForVariable";
|
|
5
|
-
import
|
|
6
|
+
import unifyStatementAgainstStatement from "../unify/statementAtainstStatement";
|
|
6
7
|
|
|
8
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
9
|
import { bracketedStatementChildNodeFromStatementNode } from "../utilities/match";
|
|
8
10
|
import { statementNodeFromStatementString, metavariableNodeFromMetavariableString } from "../utilities/node";
|
|
9
11
|
|
|
12
|
+
const metavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
13
|
+
|
|
10
14
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
11
15
|
constructor(metavariableNode, statementNode, substitution) {
|
|
12
16
|
super();
|
|
@@ -56,6 +60,33 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
56
60
|
return matchesMetavariableNode;
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
unifyAgainstEquivalence(equivalence, substitutions, localContext) {
|
|
64
|
+
let unifiedAgainstEquivalence = false; ///
|
|
65
|
+
|
|
66
|
+
const metavariableNode = metavariableNodeQuery(this.statementNode);
|
|
67
|
+
|
|
68
|
+
if (metavariableNode !== null) {
|
|
69
|
+
substitutions = [ ///
|
|
70
|
+
...substitutions
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const { metaLevelUnifier } = shim,
|
|
74
|
+
nonTerminalNodeA = this.metavariableNode, ///
|
|
75
|
+
nonTerminalNodeB = metavariableNode, ///
|
|
76
|
+
localContextA = localContext, ///
|
|
77
|
+
localContextB = localContext, ///
|
|
78
|
+
nonTerminalNodeUnified = metaLevelUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
79
|
+
const verifiedAhead = true;
|
|
80
|
+
|
|
81
|
+
return verifiedAhead;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
unifiedAgainstEquivalence = nonTerminalNodeUnified; ///
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return unifiedAgainstEquivalence;
|
|
88
|
+
}
|
|
89
|
+
|
|
59
90
|
static fromJSONAndFileContext(json, fileContext) {
|
|
60
91
|
const { metavariable, statement } = json,
|
|
61
92
|
metavariableString = metavariable, ///
|
|
@@ -120,7 +151,7 @@ function matchStatementNode(statementNodeA, statementNodeB, substitution, substi
|
|
|
120
151
|
|
|
121
152
|
statementNodeMatches = statementNodeAMatchesStatementNodeB; ///
|
|
122
153
|
} else {
|
|
123
|
-
const statementVerifiedAgainstStatement =
|
|
154
|
+
const statementVerifiedAgainstStatement = unifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
124
155
|
|
|
125
156
|
statementNodeMatches = statementVerifiedAgainstStatement; ///
|
|
126
157
|
}
|
|
@@ -45,6 +45,22 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
45
45
|
return matchesVariableNode;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
unifyAgainstEquivalence(equivalence, substitutions, localContext) {
|
|
49
|
+
let unifiedAgainstEquivalence;
|
|
50
|
+
|
|
51
|
+
const equivalenceMatchesVariableNode = equivalence.matchVariableNode(this.variableNode);
|
|
52
|
+
|
|
53
|
+
if (equivalenceMatchesVariableNode) {
|
|
54
|
+
const equivalenceMatchesTermNode = equivalence.matchTermNode(this.termNode);
|
|
55
|
+
|
|
56
|
+
if (equivalenceMatchesTermNode) {
|
|
57
|
+
unifiedAgainstEquivalence = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return unifiedAgainstEquivalence;
|
|
62
|
+
}
|
|
63
|
+
|
|
48
64
|
static fromSubstitutionNode(substitutionNode) {
|
|
49
65
|
const termNode = termNodeQuery(substitutionNode),
|
|
50
66
|
variableNode = variableNodeQuery(substitutionNode),
|
package/src/supposition.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import LocalContext from "./context/local";
|
|
4
|
-
import
|
|
4
|
+
import metaLevelUnifier from "./unifier/metaLevel";
|
|
5
5
|
|
|
6
6
|
import { match } from "./utilities/array";
|
|
7
7
|
import { nodeAsString } from "./utilities/string";
|
|
@@ -31,13 +31,13 @@ export default class Supposition {
|
|
|
31
31
|
nonTerminalNodeB = statementNode, ///
|
|
32
32
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
33
33
|
localContextB = localContext, ///
|
|
34
|
-
|
|
34
|
+
nonTerminalNodeUnified = metaLevelUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
35
35
|
const verifiedAhead = true;
|
|
36
36
|
|
|
37
37
|
return verifiedAhead;
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
matchesStatementNode =
|
|
40
|
+
matchesStatementNode = nonTerminalNodeUnified; ///
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return matchesStatementNode;
|
|
@@ -64,13 +64,13 @@ export default class Supposition {
|
|
|
64
64
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
65
65
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
66
66
|
localContextB = localContext, ///
|
|
67
|
-
|
|
67
|
+
nonTerminalNodeUnified = metaLevelUnifier.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
68
|
const verifiedAhead = true;
|
|
69
69
|
|
|
70
70
|
return verifiedAhead;
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
if (
|
|
73
|
+
if (nonTerminalNodeUnified) {
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Unifier from "../unifier";
|
|
4
|
+
import unifyTermAgainstTerm from "../unify/termAgainstTerm";
|
|
5
|
+
|
|
6
|
+
import { unify } from "../unifier";
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
|
|
9
|
+
const termNodeQuery = nodeQuery("/term!"),
|
|
10
|
+
nonTerminalNodeQuery = nodeQuery("/*");
|
|
11
|
+
|
|
12
|
+
class EqualityUnifier extends Unifier {
|
|
13
|
+
unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext, unifyAhead) {
|
|
14
|
+
let nonTerminalNodUnified;
|
|
15
|
+
|
|
16
|
+
const nodeQueryMaps = [
|
|
17
|
+
{
|
|
18
|
+
nodeQueryA: termNodeQuery,
|
|
19
|
+
nodeQueryB: termNodeQuery,
|
|
20
|
+
unify: (nodeA, nodeB, localContext, unifyAhead) => {
|
|
21
|
+
let nonTerminalNodUnified;
|
|
22
|
+
|
|
23
|
+
const termNodeA = nodeA, ///
|
|
24
|
+
termNodeB = nodeB, ///
|
|
25
|
+
termNodUnifiedAgainstTermNode =
|
|
26
|
+
|
|
27
|
+
this.unifyTermNodeAgainstTermNode(termNodeA, termNodeB, localContext, unifyAhead);
|
|
28
|
+
|
|
29
|
+
nonTerminalNodUnified = termNodUnifiedAgainstTermNode; ///
|
|
30
|
+
|
|
31
|
+
return nonTerminalNodUnified;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
nodeQueryA: nonTerminalNodeQuery,
|
|
36
|
+
nodeQueryB: nonTerminalNodeQuery,
|
|
37
|
+
unify: (nodeA, nodeB, localContext, unifyAhead) => {
|
|
38
|
+
let nonTerminalNodUnified;
|
|
39
|
+
|
|
40
|
+
const nonTerminalNodeA = nodeA, ///
|
|
41
|
+
nonTerminalNodeB = nodeB; ///
|
|
42
|
+
|
|
43
|
+
nonTerminalNodUnified =
|
|
44
|
+
|
|
45
|
+
super.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext, unifyAhead);
|
|
46
|
+
|
|
47
|
+
return nonTerminalNodUnified;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const nodesVerified = unify(nodeQueryMaps, nonTerminalNodeA, nonTerminalNodeB, localContext, unifyAhead);
|
|
53
|
+
|
|
54
|
+
nonTerminalNodUnified = nodesVerified; ///
|
|
55
|
+
|
|
56
|
+
return nonTerminalNodUnified;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
unifyTermNodeAgainstTermNode(termNodeA, termNodeB, localContext, unifyAhead) {
|
|
60
|
+
let termNodUnifiedAgainstTermNode;
|
|
61
|
+
|
|
62
|
+
const termVerifiedAgainstTerm = unifyTermAgainstTerm(termNodeA, termNodeB, localContext, unifyAhead);
|
|
63
|
+
|
|
64
|
+
if (termVerifiedAgainstTerm) {
|
|
65
|
+
termNodUnifiedAgainstTermNode = true;
|
|
66
|
+
} else {
|
|
67
|
+
const nonTerminalNodeA = termNodeA, ///
|
|
68
|
+
nonTerminalNodeB = termNodeB, ///
|
|
69
|
+
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
70
|
+
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
71
|
+
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
72
|
+
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
73
|
+
childNodesVerified = this.unifyChildNodes(childNodesA, childNodesB, localContext, unifyAhead);
|
|
74
|
+
|
|
75
|
+
termNodUnifiedAgainstTermNode = childNodesVerified; ///
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return termNodUnifiedAgainstTermNode;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const equalityUnifier = new EqualityUnifier();
|
|
83
|
+
|
|
84
|
+
export default equalityUnifier;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import shim from "../shim";
|
|
4
|
+
import Unifier from "../unifier";
|
|
5
|
+
import unifyVariableAgainstTerm from "../unify/variableAgainstTerm";
|
|
6
|
+
import unifyMetavariableAgainstStatement from "../unify/metavariableAgainstStatement";
|
|
7
|
+
|
|
8
|
+
import { unify } from "../unifier";
|
|
9
|
+
import { nodeQuery } from "../utilities/query";
|
|
10
|
+
|
|
11
|
+
const termNodeQuery = nodeQuery("/term!"),
|
|
12
|
+
statementNodeQuery = nodeQuery("/statement!"),
|
|
13
|
+
nonTerminalNodeQuery = nodeQuery("/*"),
|
|
14
|
+
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
15
|
+
statementSubstitutionNodeQuery = nodeQuery("/statement/substitution!"),
|
|
16
|
+
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
17
|
+
|
|
18
|
+
class MetaLevelUnifier extends Unifier {
|
|
19
|
+
unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, unifyAhead) {
|
|
20
|
+
let nonTerminalNodeUnified;
|
|
21
|
+
|
|
22
|
+
const nodeQueryMaps = [
|
|
23
|
+
{
|
|
24
|
+
nodeQueryA: statementMetavariableNodeQuery,
|
|
25
|
+
nodeQueryB: statementNodeQuery,
|
|
26
|
+
unify: (nodeA, nodeB, substitutions, localContextA, localContextB, unifyAhead) => {
|
|
27
|
+
let nonTerminalNodeUnified;
|
|
28
|
+
|
|
29
|
+
const statementNodeA = nonTerminalNodeA, ///
|
|
30
|
+
statementNodeB = nodeB, ///
|
|
31
|
+
statementMetavariableNodeA = nodeA, ///
|
|
32
|
+
statementSubstitutionNodeA = statementSubstitutionNodeQuery(statementNodeA),
|
|
33
|
+
metavariableNodeUnifiedAgainstStatementNode =
|
|
34
|
+
|
|
35
|
+
this.unifyStatementMetavariableNodeAgainstStatementNode(statementMetavariableNodeA, statementSubstitutionNodeA, statementNodeB, substitutions, localContextA, localContextB, unifyAhead);
|
|
36
|
+
|
|
37
|
+
nonTerminalNodeUnified = metavariableNodeUnifiedAgainstStatementNode; ///
|
|
38
|
+
|
|
39
|
+
return nonTerminalNodeUnified;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
nodeQueryA: termVariableNodeQuery,
|
|
44
|
+
nodeQueryB: termNodeQuery,
|
|
45
|
+
unify: (nodeA, nodeB, substitutions, localContextA, localContextB, unifyAhead) => {
|
|
46
|
+
let nonTerminalNodeUnified;
|
|
47
|
+
|
|
48
|
+
const termNodeB = nodeB, ///
|
|
49
|
+
termVariableNodeA = nodeA, ///
|
|
50
|
+
termVariableNodeUnifiedAgainstTermNode =
|
|
51
|
+
|
|
52
|
+
this.unifyTermVariableNodeAgainstTermNode(termVariableNodeA, termNodeB, substitutions, localContextA, localContextB, unifyAhead);
|
|
53
|
+
|
|
54
|
+
nonTerminalNodeUnified = termVariableNodeUnifiedAgainstTermNode; ///
|
|
55
|
+
|
|
56
|
+
return nonTerminalNodeUnified;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
nodeQueryA: nonTerminalNodeQuery,
|
|
61
|
+
nodeQueryB: nonTerminalNodeQuery,
|
|
62
|
+
unify: (nodeA, nodeB, substitutions, localContextA, localContextB, unifyAhead) => {
|
|
63
|
+
let nonTerminalNodeUnified;
|
|
64
|
+
|
|
65
|
+
const nonTerminalNodeA = nodeA, ///
|
|
66
|
+
nonTerminalNodeB = nodeB; ///
|
|
67
|
+
|
|
68
|
+
nonTerminalNodeUnified =
|
|
69
|
+
|
|
70
|
+
super.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, unifyAhead);
|
|
71
|
+
|
|
72
|
+
return nonTerminalNodeUnified;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const nodesUnified = unify(nodeQueryMaps, nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, unifyAhead);
|
|
78
|
+
|
|
79
|
+
nonTerminalNodeUnified = nodesUnified; ///
|
|
80
|
+
|
|
81
|
+
return nonTerminalNodeUnified;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
unifyStatementMetavariableNodeAgainstStatementNode(statementMetavariableNodeA, statementSubstitutionNodeA, statementNodeB, substitutions, localContextA, localContextB, unifyAhead) {
|
|
85
|
+
let metavariableNodeUnifiedAgainstStatementNode;
|
|
86
|
+
|
|
87
|
+
const substitutionNode = statementSubstitutionNodeA, ///
|
|
88
|
+
metavariableNodeA = statementMetavariableNodeA, ///
|
|
89
|
+
metavariableUnifiedAgainstStatement = unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNode, substitutions, localContextA, localContextB, unifyAhead);
|
|
90
|
+
|
|
91
|
+
metavariableNodeUnifiedAgainstStatementNode = metavariableUnifiedAgainstStatement; ///
|
|
92
|
+
|
|
93
|
+
return metavariableNodeUnifiedAgainstStatementNode;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
unifyTermVariableNodeAgainstTermNode(termVariableNodeA, termNodeB, substitutions, localContextA, localContextB, unifyAhead) {
|
|
97
|
+
let termVariableNodeUnifiedAgainstTermNode;
|
|
98
|
+
|
|
99
|
+
const variableNodeA = termVariableNodeA, ///
|
|
100
|
+
termUnifiedAgainstVariable = unifyVariableAgainstTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB, unifyAhead);
|
|
101
|
+
|
|
102
|
+
termVariableNodeUnifiedAgainstTermNode = termUnifiedAgainstVariable; ///
|
|
103
|
+
|
|
104
|
+
return termVariableNodeUnifiedAgainstTermNode;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const metaLevelUnifier = new MetaLevelUnifier();
|
|
109
|
+
|
|
110
|
+
Object.assign(shim, {
|
|
111
|
+
metaLevelUnifier
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export default metaLevelUnifier;
|