occam-verify-cli 0.0.941 → 0.0.943
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 +3 -4
- package/lib/consequent.js +3 -4
- package/lib/constants.js +5 -1
- package/lib/context/file.js +1 -1
- package/lib/context/local.js +15 -5
- package/lib/frame.js +2 -2
- package/lib/metavariable.js +12 -4
- package/lib/premise.js +11 -12
- package/lib/proofStep.js +14 -18
- package/lib/rule.js +6 -32
- package/lib/substitution/statementForMetavariable.js +15 -1
- package/lib/substitution/termForVariable.js +17 -3
- package/lib/substitutions.js +208 -0
- package/lib/supposition.js +11 -12
- package/lib/topLevelAssertion.js +9 -41
- package/lib/unifier/equality.js +6 -8
- package/lib/unifier/metaLevel.js +7 -10
- package/lib/unifier/statementAgainstCombinator.js +6 -9
- package/lib/unifier/termAgainstConstructor.js +5 -5
- package/lib/unifier.js +34 -13
- package/lib/unify/conclusionAgainstStatement.js +34 -0
- package/lib/unify/consequentAgainstStatement.js +34 -0
- package/lib/unify/metavariableAgainstStatement.js +24 -16
- package/lib/unify/premiseAgainstProofStep.js +41 -0
- package/lib/unify/premisesAgainstProofSteps.js +31 -0
- package/lib/unify/statementAgainstMetaType.js +5 -9
- package/lib/unify/suppositionAgainstProofStep.js +41 -0
- package/lib/unify/suppositionsAgainstProofSteps.js +31 -0
- package/lib/unify/termAgainstTerm.js +4 -5
- package/lib/unify/termAgainstType.js +7 -7
- package/lib/unify/variableAgainstTerm.js +12 -28
- package/lib/utilities/arguments.js +27 -0
- package/lib/utilities/array.js +17 -2
- package/lib/utilities/unify.js +19 -0
- package/lib/verifier/metaLevel.js +8 -11
- package/lib/verifier/statementAsCombinator.js +13 -22
- package/lib/verifier/topLevel.js +3 -6
- package/lib/verifier.js +28 -8
- package/lib/verify/assertion/type.js +3 -7
- package/lib/verify/axiom.js +3 -2
- package/lib/verify/conjecture.js +5 -3
- package/lib/verify/declaration/metavariable.js +1 -1
- package/lib/verify/equality.js +3 -7
- package/lib/verify/lemma.js +4 -3
- package/lib/verify/metaLemma.js +3 -2
- package/lib/verify/metatheorem.js +3 -2
- package/lib/verify/metavariable.js +26 -63
- package/lib/verify/rule.js +3 -2
- package/lib/verify/statement/qualified.js +54 -54
- package/lib/verify/statement/unqualified.js +2 -2
- package/lib/verify/statement.js +35 -30
- package/lib/verify/term.js +26 -32
- package/lib/verify/theorem.js +4 -3
- package/lib/verify/variable.js +3 -4
- package/package.json +4 -4
- package/src/conclusion.js +2 -6
- package/src/consequent.js +2 -6
- package/src/constants.js +1 -0
- package/src/context/file.js +5 -5
- package/src/context/local.js +20 -9
- package/src/frame.js +1 -1
- package/src/metavariable.js +1 -1
- package/src/premise.js +18 -24
- package/src/proofStep.js +16 -20
- package/src/rule.js +12 -50
- package/src/substitution/statementForMetavariable.js +16 -0
- package/src/substitution/termForVariable.js +18 -2
- package/src/substitutions.js +143 -0
- package/src/supposition.js +18 -24
- package/src/topLevelAssertion.js +15 -62
- package/src/unifier/equality.js +7 -8
- package/src/unifier/metaLevel.js +6 -10
- package/src/unifier/statementAgainstCombinator.js +9 -9
- package/src/unifier/termAgainstConstructor.js +6 -4
- package/src/unifier.js +35 -11
- package/src/unify/conclusionAgainstStatement.js +34 -0
- package/src/unify/consequentAgainstStatement.js +34 -0
- package/src/unify/metavariableAgainstStatement.js +33 -23
- package/src/unify/premiseAgainstProofStep.js +54 -0
- package/src/unify/premisesAgainstProofSteps.js +23 -0
- package/src/unify/statementAgainstMetaType.js +3 -11
- package/src/unify/suppositionAgainstProofStep.js +54 -0
- package/src/unify/suppositionsAgainstProofSteps.js +23 -0
- package/src/unify/termAgainstTerm.js +3 -7
- package/src/unify/termAgainstType.js +5 -6
- package/src/unify/variableAgainstTerm.js +18 -48
- package/src/utilities/arguments.js +18 -0
- package/src/utilities/array.js +16 -1
- package/src/utilities/unify.js +18 -0
- package/src/verifier/metaLevel.js +7 -11
- package/src/verifier/statementAsCombinator.js +15 -28
- package/src/verifier/topLevel.js +13 -17
- package/src/verifier.js +28 -6
- package/src/verify/assertion/type.js +2 -6
- package/src/verify/axiom.js +2 -1
- package/src/verify/conjecture.js +5 -2
- package/src/verify/declaration/metavariable.js +9 -9
- package/src/verify/equality.js +2 -6
- package/src/verify/lemma.js +3 -2
- package/src/verify/metaLemma.js +2 -1
- package/src/verify/metatheorem.js +2 -1
- package/src/verify/metavariable.js +31 -91
- package/src/verify/rule.js +2 -1
- package/src/verify/statement/qualified.js +53 -53
- package/src/verify/statement/unqualified.js +1 -1
- package/src/verify/statement.js +37 -31
- package/src/verify/term.js +25 -31
- package/src/verify/theorem.js +3 -2
- package/src/verify/variable.js +2 -4
package/src/unifier/metaLevel.js
CHANGED
|
@@ -19,11 +19,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
19
19
|
|
|
20
20
|
const nonTerminalNodeA = nodeA, ///
|
|
21
21
|
nonTerminalNodeB = nodeB, ///
|
|
22
|
-
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB
|
|
23
|
-
const unifiedAhead = true;
|
|
24
|
-
|
|
25
|
-
return unifiedAhead;
|
|
26
|
-
});
|
|
22
|
+
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB);
|
|
27
23
|
|
|
28
24
|
unified = nonTerminalNodeUnified; ///
|
|
29
25
|
|
|
@@ -34,14 +30,14 @@ class MetaLevelUnifier extends Unifier {
|
|
|
34
30
|
{
|
|
35
31
|
nodeQueryA: statementNodeQuery,
|
|
36
32
|
nodeQueryB: statementNodeQuery,
|
|
37
|
-
unify: (statementNodeA, statementNodeB, substitutions, localContextA, localContextB
|
|
33
|
+
unify: (statementNodeA, statementNodeB, substitutions, localContextA, localContextB) => {
|
|
38
34
|
let statementVerifiedAgainstStatement;
|
|
39
35
|
|
|
40
36
|
const metavariableNodeA = metavariableNodeQuery(statementNodeA);
|
|
41
37
|
|
|
42
38
|
if (metavariableNodeA !== null) {
|
|
43
39
|
const substitutionNodeA = substitutionNodeQuery(statementNodeA),
|
|
44
|
-
metavariableUnifiedAgainstStatement = unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB
|
|
40
|
+
metavariableUnifiedAgainstStatement = unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
|
|
45
41
|
|
|
46
42
|
statementVerifiedAgainstStatement = metavariableUnifiedAgainstStatement; ///
|
|
47
43
|
} else {
|
|
@@ -51,7 +47,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
51
47
|
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
52
48
|
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
53
49
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
54
|
-
childNodesVerified = metaLevelUnifier.unifyChildNodes(childNodesA, childNodesB, substitutions, localContextA, localContextB
|
|
50
|
+
childNodesVerified = metaLevelUnifier.unifyChildNodes(childNodesA, childNodesB, substitutions, localContextA, localContextB);
|
|
55
51
|
|
|
56
52
|
statementVerifiedAgainstStatement = childNodesVerified; ///
|
|
57
53
|
}
|
|
@@ -62,9 +58,9 @@ class MetaLevelUnifier extends Unifier {
|
|
|
62
58
|
{
|
|
63
59
|
nodeQueryA: termVariableNodeQuery,
|
|
64
60
|
nodeQueryB: termNodeQuery,
|
|
65
|
-
unify: (termVariableNodeA, termNodeB, substitutions, localContextA, localContextB
|
|
61
|
+
unify: (termVariableNodeA, termNodeB, substitutions, localContextA, localContextB) => {
|
|
66
62
|
const variableNodeA = termVariableNodeA, ///
|
|
67
|
-
variableUnifiedAgainstTerm = unifyVariableAgainstTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB
|
|
63
|
+
variableUnifiedAgainstTerm = unifyVariableAgainstTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB);
|
|
68
64
|
|
|
69
65
|
return variableUnifiedAgainstTerm;
|
|
70
66
|
}
|
|
@@ -17,11 +17,7 @@ class StatementAgainstCombinatorUnifier extends Unifier {
|
|
|
17
17
|
|
|
18
18
|
const nonTerminalNodeA = statementNode, ///
|
|
19
19
|
nonTerminalNodeB = combinatorStatementNode, ///
|
|
20
|
-
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext
|
|
21
|
-
const unifiedAhead = true;
|
|
22
|
-
|
|
23
|
-
return unifiedAhead;
|
|
24
|
-
});
|
|
20
|
+
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext);
|
|
25
21
|
|
|
26
22
|
statementUnifiedAgainstCombinator = nonTerminalNodeUnified; ///
|
|
27
23
|
|
|
@@ -32,8 +28,10 @@ class StatementAgainstCombinatorUnifier extends Unifier {
|
|
|
32
28
|
{
|
|
33
29
|
nodeQueryA: statementNodeQuery,
|
|
34
30
|
nodeQueryB: metaTypeNodeQuery,
|
|
35
|
-
unify: (statementNodeA, metaTypeNodeB, localContext
|
|
36
|
-
const
|
|
31
|
+
unify: (statementNodeA, metaTypeNodeB, localContext) => {
|
|
32
|
+
const metaTypeNode = metaTypeNodeB, ///
|
|
33
|
+
statementNode = statementNodeA, ///
|
|
34
|
+
statementUnifiedAgainstMetaType = unifyStatementAgainstMetaType(statementNode, metaTypeNode, localContext);
|
|
37
35
|
|
|
38
36
|
return statementUnifiedAgainstMetaType;
|
|
39
37
|
}
|
|
@@ -41,8 +39,10 @@ class StatementAgainstCombinatorUnifier extends Unifier {
|
|
|
41
39
|
{
|
|
42
40
|
nodeQueryA: termNodeQuery,
|
|
43
41
|
nodeQueryB: typeNodeQuery,
|
|
44
|
-
unify: (termNodeA, typeNodeB, localContext
|
|
45
|
-
const
|
|
42
|
+
unify: (termNodeA, typeNodeB, localContext) => {
|
|
43
|
+
const termNode = termNodeA, ///
|
|
44
|
+
typeNode = typeNodeB, ///
|
|
45
|
+
termUnifiedAgainstType = unifyTermAgainstType(termNode, typeNode, localContext);
|
|
46
46
|
|
|
47
47
|
return termUnifiedAgainstType;
|
|
48
48
|
}
|
|
@@ -9,12 +9,12 @@ const termNodeQuery = nodeQuery("/term"),
|
|
|
9
9
|
typeNodeQuery = nodeQuery("/type");
|
|
10
10
|
|
|
11
11
|
class TermAgainstConstructorUnifier extends Unifier {
|
|
12
|
-
unify(termNode, constructorTermNode, localContext
|
|
12
|
+
unify(termNode, constructorTermNode, localContext) {
|
|
13
13
|
let termUnifiedAgainstConstructor;
|
|
14
14
|
|
|
15
15
|
const nonTerminalNodeA = termNode, ///
|
|
16
16
|
nonTerminalNodeB = constructorTermNode, ///
|
|
17
|
-
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext
|
|
17
|
+
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext);
|
|
18
18
|
|
|
19
19
|
termUnifiedAgainstConstructor = nonTerminalNodeUnified; ///
|
|
20
20
|
|
|
@@ -25,8 +25,10 @@ class TermAgainstConstructorUnifier extends Unifier {
|
|
|
25
25
|
{
|
|
26
26
|
nodeQueryA: termNodeQuery,
|
|
27
27
|
nodeQueryB: typeNodeQuery,
|
|
28
|
-
unify: (termNodeA, typeNodeB, localContext
|
|
29
|
-
const
|
|
28
|
+
unify: (termNodeA, typeNodeB, localContext) => {
|
|
29
|
+
const termNode = termNodeA, ///
|
|
30
|
+
typeNode = typeNodeB, ///
|
|
31
|
+
termUnifiedAgainstType = unifyTermAgainstType(termNode, typeNode, localContext);
|
|
30
32
|
|
|
31
33
|
return termUnifiedAgainstType;
|
|
32
34
|
}
|
package/src/unifier.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { nodeQuery } from "./utilities/query";
|
|
4
4
|
import { terminalNodeMapFromNodes, areTerminalNodeMapsEqual } from "./utilities/unifier";
|
|
5
|
+
import {isLastRemainingArgumentFunction} from "./utilities/arguments";
|
|
5
6
|
|
|
6
7
|
const nonTerminalNodeQuery = nodeQuery("/*");
|
|
7
8
|
|
|
@@ -55,10 +56,25 @@ export default class Unifier {
|
|
|
55
56
|
terminalNodeMapsEqual = areTerminalNodeMapsEqual(childTerminalNodeMapA, childTerminalNodeMapB);
|
|
56
57
|
|
|
57
58
|
if (terminalNodeMapsEqual) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
|
|
60
|
+
|
|
61
|
+
if (lastRemainingArgumentFunction) {
|
|
62
|
+
const index = 0,
|
|
63
|
+
childNodesUnifiedAhead = this.unifyChildNodesAhead(index, childNodesA, childNodesB,...remainingArguments);
|
|
64
|
+
|
|
65
|
+
childNodesUnified = childNodesUnifiedAhead; ///
|
|
66
|
+
} else {
|
|
67
|
+
childNodesUnified = childNodesA.every((childNodeA, index) => {
|
|
68
|
+
const childNodeB = childNodesB[index],
|
|
69
|
+
nodeA = childNodeA, ///
|
|
70
|
+
nodeB = childNodeB, ///
|
|
71
|
+
nodeUnified = this.unifyNode(nodeA, nodeB, ...remainingArguments);
|
|
72
|
+
|
|
73
|
+
if (nodeUnified) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
|
|
@@ -68,10 +84,18 @@ export default class Unifier {
|
|
|
68
84
|
unifyTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments) { ///
|
|
69
85
|
let terminalNodeUnified;
|
|
70
86
|
|
|
71
|
-
const
|
|
72
|
-
|
|
87
|
+
const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
|
|
88
|
+
|
|
89
|
+
if (lastRemainingArgumentFunction) {
|
|
90
|
+
const unifyAhead = remainingArguments.pop(),
|
|
91
|
+
unifiedAhead = unifyAhead();
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
terminalNodeUnified = unifiedAhead; ///
|
|
94
|
+
|
|
95
|
+
remainingArguments.push(unifiedAhead);
|
|
96
|
+
} else {
|
|
97
|
+
terminalNodeUnified = true;
|
|
98
|
+
}
|
|
75
99
|
|
|
76
100
|
return terminalNodeUnified;
|
|
77
101
|
}
|
|
@@ -134,9 +158,9 @@ export default class Unifier {
|
|
|
134
158
|
childNodesALength = childNodesA.length;
|
|
135
159
|
|
|
136
160
|
if (index === childNodesALength) {
|
|
137
|
-
const
|
|
161
|
+
const unifiedAhead = unifyAhead();
|
|
138
162
|
|
|
139
|
-
childNodesUnified =
|
|
163
|
+
childNodesUnified = unifiedAhead; ///
|
|
140
164
|
} else {
|
|
141
165
|
const childNodeA = childNodesA[index],
|
|
142
166
|
childNodeB = childNodesB[index],
|
|
@@ -146,9 +170,9 @@ export default class Unifier {
|
|
|
146
170
|
remainingArguments.push(unifyAhead); ///
|
|
147
171
|
|
|
148
172
|
const aheadIndex = index + 1,
|
|
149
|
-
|
|
173
|
+
childNodesUnifiedAhead = this.unifyChildNodesAhead(aheadIndex, childNodesA, childNodesB, ...remainingArguments);
|
|
150
174
|
|
|
151
|
-
return
|
|
175
|
+
return childNodesUnifiedAhead;
|
|
152
176
|
});
|
|
153
177
|
|
|
154
178
|
childNodesUnified = nodeUnified; ///
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
|
|
5
|
+
export default function unifyConclusionAgainstStatement(conclusionA, statementNodeB, substitutions, fileContextA, localContextB) {
|
|
6
|
+
let conclusionUnified = false;
|
|
7
|
+
|
|
8
|
+
const conclusionAStatementNode = conclusionA.getStatementNode();
|
|
9
|
+
|
|
10
|
+
if (conclusionAStatementNode !== null) {
|
|
11
|
+
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
12
|
+
statementNodeA = conclusionAStatementNode, ///
|
|
13
|
+
statementStringA = localContextA.nodeAsString(statementNodeA),
|
|
14
|
+
statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
15
|
+
|
|
16
|
+
substitutions.snapshot();
|
|
17
|
+
|
|
18
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement against the conclusion's '${statementStringA}' statement...`, statementNodeB);
|
|
19
|
+
|
|
20
|
+
const statementUnified = conclusionA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
21
|
+
|
|
22
|
+
conclusionUnified = statementUnified; ///
|
|
23
|
+
|
|
24
|
+
conclusionUnified ?
|
|
25
|
+
substitutions.continue() :
|
|
26
|
+
substitutions.rollback(localContextA, localContextB);
|
|
27
|
+
|
|
28
|
+
if (conclusionUnified) {
|
|
29
|
+
localContextB.debug(`...unified the '${statementStringB}' statement against the conclusion's '${statementStringA}' statement.`, statementNodeB);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return conclusionUnified;
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
|
|
5
|
+
export default function unifyConsequentAgainstStatement(consequentA, statementNodeB, substitutions, fileContextA, localContextB) {
|
|
6
|
+
let consequentUnified = false;
|
|
7
|
+
|
|
8
|
+
const consequentAStatementNode = consequentA.getStatementNode();
|
|
9
|
+
|
|
10
|
+
if (consequentAStatementNode !== null) {
|
|
11
|
+
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
12
|
+
statementNodeA = consequentAStatementNode, ///
|
|
13
|
+
statementStringA = localContextA.nodeAsString(statementNodeA),
|
|
14
|
+
statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
15
|
+
|
|
16
|
+
substitutions.snapshot();
|
|
17
|
+
|
|
18
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement against the consequent's '${statementStringA}' statement...`, statementNodeB);
|
|
19
|
+
|
|
20
|
+
const statementUnified = consequentA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
21
|
+
|
|
22
|
+
consequentUnified = statementUnified; ///
|
|
23
|
+
|
|
24
|
+
consequentUnified ?
|
|
25
|
+
substitutions.continue() :
|
|
26
|
+
substitutions.rollback(localContextA, localContextB);
|
|
27
|
+
|
|
28
|
+
if (consequentUnified) {
|
|
29
|
+
localContextB.debug(`...unified the '${statementStringB}' statement against the consequent's '${statementStringA}' statement.`, statementNodeB);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return consequentUnified;
|
|
34
|
+
}
|
|
@@ -4,10 +4,14 @@ import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
|
4
4
|
import unifyStatementAgainstStatement from "../unify/statementAtainstStatement";
|
|
5
5
|
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
|
|
9
|
+
const metavariableNodeQuery = nodeQuery("/statement/metavariable");
|
|
10
|
+
|
|
11
|
+
export default function unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB) {
|
|
8
12
|
let metavariableUnifiedAgainstStatement = false;
|
|
9
13
|
|
|
10
|
-
const substitution = substitutions.
|
|
14
|
+
const substitution = substitutions.findSubstitution((substitution) => {
|
|
11
15
|
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNodeA);
|
|
12
16
|
|
|
13
17
|
if (substitutionMatchesMetavariableNodeA) {
|
|
@@ -27,9 +31,7 @@ export default function unifyMetavariableAgainstStatement(metavariableNodeA, sta
|
|
|
27
31
|
statementUnifiedAgainstStatement = unifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContext, localContext);
|
|
28
32
|
|
|
29
33
|
if (statementUnifiedAgainstStatement) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
metavariableUnifiedAgainstStatement = unifiedAhead; ///
|
|
34
|
+
metavariableUnifiedAgainstStatement = true;
|
|
33
35
|
}
|
|
34
36
|
} else {
|
|
35
37
|
const substitutionSubstitution = substitution.getSubstitution();
|
|
@@ -44,39 +46,47 @@ export default function unifyMetavariableAgainstStatement(metavariableNodeA, sta
|
|
|
44
46
|
statementUnifiedAgainstStatement = unifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContext, localContext);
|
|
45
47
|
|
|
46
48
|
if (statementUnifiedAgainstStatement) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
metavariableUnifiedAgainstStatement = unifiedAhead; ///
|
|
49
|
+
metavariableUnifiedAgainstStatement = true;
|
|
50
50
|
}
|
|
51
51
|
} else {
|
|
52
52
|
const substitutionMatchesStatementNodeB = substitution.matchStatementNode(statementNodeB);
|
|
53
53
|
|
|
54
54
|
if (substitutionMatchesStatementNodeB) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
metavariableUnifiedAgainstStatement = unifiedAhead; ///
|
|
55
|
+
metavariableUnifiedAgainstStatement = true;
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
} else {
|
|
62
|
-
|
|
60
|
+
const metavariableA = localContextA.findMetavariableByMetavariableNode(metavariableNodeA);
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
metavariableNode = metavariableNodeA, ///
|
|
67
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeStatementNodeAndSubstitutionNode(metavariableNode, statementNode, substitutionNode),
|
|
68
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
62
|
+
if (metavariableA !== null) {
|
|
63
|
+
const metavariableB = metavariableFromStatementNode(statementNodeB, localContextB);
|
|
69
64
|
|
|
70
|
-
|
|
65
|
+
if (metavariableA !== metavariableB) {
|
|
66
|
+
const statementNode = statementNodeB, ///
|
|
67
|
+
substitutionNode = substitutionNodeA, ///
|
|
68
|
+
metavariableNode = metavariableNodeA, ///
|
|
69
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeStatementNodeAndSubstitutionNode(metavariableNode, statementNode, substitutionNode),
|
|
70
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
73
|
+
}
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
substitutions.pop();
|
|
75
|
+
metavariableUnifiedAgainstStatement = true;
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
metavariableUnifiedAgainstStatement = unifiedAhead; ///
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
return metavariableUnifiedAgainstStatement;
|
|
82
80
|
}
|
|
81
|
+
|
|
82
|
+
function metavariableFromStatementNode(statementNode, localContext) {
|
|
83
|
+
let metavariable = null;
|
|
84
|
+
|
|
85
|
+
const metavariableNode = metavariableNodeQuery(statementNode)
|
|
86
|
+
|
|
87
|
+
if (metavariableNode !== null) {
|
|
88
|
+
metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return metavariable;
|
|
92
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { subproofNodeAsSubproofString } from "../utilities/unify";
|
|
4
|
+
|
|
5
|
+
export default function unifyPremiseAgainstProofStep(premiseA, proofStepB, substitutions, localContextA, localContextB) {
|
|
6
|
+
let premiseUnified = false;
|
|
7
|
+
|
|
8
|
+
const premiseAStatementNode = premiseA.getStatementNode();
|
|
9
|
+
|
|
10
|
+
if (premiseAStatementNode !== null) {
|
|
11
|
+
const proofStepBSubproofNode = proofStepB.getSubproofNode(),
|
|
12
|
+
proofStepBStatementNode = proofStepB.getStatementNode(),
|
|
13
|
+
subproofNodeB = proofStepBSubproofNode, ///
|
|
14
|
+
statementNodeB = proofStepBStatementNode, ///
|
|
15
|
+
statementNodeA = premiseAStatementNode, ///
|
|
16
|
+
statementStringA = localContextA.nodeAsString(statementNodeA)
|
|
17
|
+
|
|
18
|
+
substitutions.snapshot();
|
|
19
|
+
|
|
20
|
+
if (subproofNodeB !== null) {
|
|
21
|
+
const subproofStringB = subproofNodeAsSubproofString(subproofNodeB, localContextB);
|
|
22
|
+
|
|
23
|
+
localContextB.trace(`Unifying the '${subproofStringB}' subproof against the premise's '${statementStringA}' statement...`, subproofNodeB);
|
|
24
|
+
|
|
25
|
+
const subproofUnified = premiseA.unifySubproof(subproofNodeB, substitutions, localContextA, localContextB);
|
|
26
|
+
|
|
27
|
+
if (subproofUnified) {
|
|
28
|
+
localContextB.debug(`...unified the '${subproofStringB}' subproof against the premise's '${statementStringA}' statement.`, subproofNodeB);
|
|
29
|
+
|
|
30
|
+
premiseUnified = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (statementNodeB !== null) {
|
|
35
|
+
const statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
36
|
+
|
|
37
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement against the premise's '${statementStringA}' statement...`, statementNodeB);
|
|
38
|
+
|
|
39
|
+
const statementUnified = premiseA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
40
|
+
|
|
41
|
+
if (statementUnified) {
|
|
42
|
+
localContextB.debug(`...unified the '${statementStringB}' statement against the premise's '${statementStringA}' statement.`, statementNodeB);
|
|
43
|
+
|
|
44
|
+
premiseUnified = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
premiseUnified ?
|
|
49
|
+
substitutions.continue() :
|
|
50
|
+
substitutions.rollback(localContextA, localContextB);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return premiseUnified;
|
|
54
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
import unifyPremiseAgainstProofStep from "../unify/premiseAgainstProofStep";
|
|
5
|
+
|
|
6
|
+
import { reverse, correlate } from "../utilities/array";
|
|
7
|
+
|
|
8
|
+
export default function unifyPremisesAgainstProofSteps(premisesA, proofStepsB, substitutions, fileContextA, localContextB) {
|
|
9
|
+
premisesA = reverse(premisesA); ///
|
|
10
|
+
|
|
11
|
+
proofStepsB = reverse(proofStepsB); ///
|
|
12
|
+
|
|
13
|
+
const premisesUnified = correlate(premisesA, proofStepsB, (premiseA, proofStepB) => {
|
|
14
|
+
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
15
|
+
premiseUnified = unifyPremiseAgainstProofStep(premiseA, proofStepB, substitutions, localContextA, localContextB);
|
|
16
|
+
|
|
17
|
+
if (premiseUnified) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return premisesUnified;
|
|
23
|
+
}
|
|
@@ -7,27 +7,19 @@ import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
|
7
7
|
|
|
8
8
|
const metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type!");
|
|
9
9
|
|
|
10
|
-
export default function unifyStatementAgainstMetaType(
|
|
10
|
+
export default function unifyStatementAgainstMetaType(statementNode, metaTypeNode, localContext) {
|
|
11
11
|
let statementVerifiedAgainstMetaType = false;
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
13
|
+
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
15
14
|
content = metaTypeTerminalNode.getContent();
|
|
16
15
|
|
|
17
16
|
if (content === STATEMENT_META_TYPE_NAME) {
|
|
18
|
-
let unifiedAhead = false;
|
|
19
|
-
|
|
20
17
|
const { verifyStatement } = shim,
|
|
21
18
|
derived = false,
|
|
22
19
|
assignments = [],
|
|
23
|
-
statementNode = statementNodeA, ///
|
|
24
20
|
statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
unifiedAhead = unifyAhead();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
statementVerifiedAgainstMetaType = unifiedAhead; ///
|
|
22
|
+
statementVerifiedAgainstMetaType = statementVerified;
|
|
31
23
|
}
|
|
32
24
|
|
|
33
25
|
return statementVerifiedAgainstMetaType;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { subproofNodeAsSubproofString } from "../utilities/unify";
|
|
4
|
+
|
|
5
|
+
export default function unifySuppositionAgainstProofStep(suppositionA, proofStepB, substitutions, localContextA, localContextB) {
|
|
6
|
+
let suppositionUnified = false;
|
|
7
|
+
|
|
8
|
+
const suppositionAStatementNode = suppositionA.getStatementNode();
|
|
9
|
+
|
|
10
|
+
if (suppositionAStatementNode !== null) {
|
|
11
|
+
const proofStepBSubproofNode = proofStepB.getSubproofNode(),
|
|
12
|
+
proofStepBStatementNode = proofStepB.getStatementNode(),
|
|
13
|
+
subproofNodeB = proofStepBSubproofNode, ///
|
|
14
|
+
statementNodeB = proofStepBStatementNode, ///
|
|
15
|
+
statementNodeA = suppositionAStatementNode, ///
|
|
16
|
+
statementStringA = localContextA.nodeAsString(statementNodeA)
|
|
17
|
+
|
|
18
|
+
substitutions.snapshot();
|
|
19
|
+
|
|
20
|
+
if (subproofNodeB !== null) {
|
|
21
|
+
const subproofStringB = subproofNodeAsSubproofString(subproofNodeB, localContextB);
|
|
22
|
+
|
|
23
|
+
localContextB.trace(`Unifying the '${subproofStringB}' subproof against the supposition's '${statementStringA}' statement...`, subproofNodeB);
|
|
24
|
+
|
|
25
|
+
const subproofUnified = suppositionA.unifySubproof(subproofNodeB, substitutions, localContextA, localContextB);
|
|
26
|
+
|
|
27
|
+
if (subproofUnified) {
|
|
28
|
+
localContextB.debug(`...unified the '${subproofStringB}' subproof against the supposition's '${statementStringA}' statement.`, subproofNodeB);
|
|
29
|
+
|
|
30
|
+
suppositionUnified = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (statementNodeB !== null) {
|
|
35
|
+
const statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
36
|
+
|
|
37
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement against the supposition's '${statementStringA}' statement...`, statementNodeB);
|
|
38
|
+
|
|
39
|
+
const statementUnified = suppositionA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
40
|
+
|
|
41
|
+
if (statementUnified) {
|
|
42
|
+
localContextB.debug(`...unified the '${statementStringB}' statement against the supposition's '${statementStringA}' statement.`, statementNodeB);
|
|
43
|
+
|
|
44
|
+
suppositionUnified = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
suppositionUnified ?
|
|
49
|
+
substitutions.continue() :
|
|
50
|
+
substitutions.rollback(localContextA, localContextB);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return suppositionUnified;
|
|
54
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
import unifySuppositionAgainstProofStep from "./suppositionAgainstProofStep";
|
|
5
|
+
|
|
6
|
+
import { reverse, correlate } from "../utilities/array";
|
|
7
|
+
|
|
8
|
+
export default function unifySuppositionsAgainstProofSteps(suppositionsA, proofStepsB, substitutions, fileContextA, localContextB) {
|
|
9
|
+
suppositionsA = reverse(suppositionsA); ///
|
|
10
|
+
|
|
11
|
+
proofStepsB = reverse(proofStepsB); ///
|
|
12
|
+
|
|
13
|
+
const suppositionsUnified = correlate(suppositionsA, proofStepsB, (suppositionA, proofStepB) => {
|
|
14
|
+
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
15
|
+
suppositionUnified = unifySuppositionAgainstProofStep(suppositionA, proofStepB, substitutions, localContextA, localContextB);
|
|
16
|
+
|
|
17
|
+
if (suppositionUnified) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return suppositionsUnified;
|
|
23
|
+
}
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { areTermNodesEqual } from "../utilities/equivalences";
|
|
4
4
|
|
|
5
|
-
export default function unifyTermAgainstTerm(
|
|
5
|
+
export default function unifyTermAgainstTerm(leftTermNode, rightTermNode, localContext) {
|
|
6
6
|
let termUnifiedAgainstTerm = false;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
rightTermNode = termNodeB, ///
|
|
10
|
-
equivalences = localContext.getEquivalences(),
|
|
8
|
+
const equivalences = localContext.getEquivalences(),
|
|
11
9
|
termNodesEqual = areTermNodesEqual(leftTermNode, rightTermNode, equivalences);
|
|
12
10
|
|
|
13
11
|
if (termNodesEqual) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
termUnifiedAgainstTerm = unifiedAhead; ///
|
|
12
|
+
termUnifiedAgainstTerm = true;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
return termUnifiedAgainstTerm;
|
|
@@ -4,26 +4,25 @@ import shim from "../shim";
|
|
|
4
4
|
|
|
5
5
|
import { first } from "../utilities/array";
|
|
6
6
|
|
|
7
|
-
export default function unifyTermAgainstType(
|
|
7
|
+
export default function unifyTermAgainstType(termNode, typeNode, localContext) {
|
|
8
8
|
let termUnifiedAgainstType;
|
|
9
9
|
|
|
10
10
|
const { verifyTerm } = shim,
|
|
11
11
|
terms = [],
|
|
12
|
-
termVerified = verifyTerm(
|
|
13
|
-
let
|
|
12
|
+
termVerified = verifyTerm(termNode, terms, localContext, () => {
|
|
13
|
+
let verifiedAhead = false;
|
|
14
14
|
|
|
15
15
|
const firstTerm = first(terms),
|
|
16
16
|
term = firstTerm, ///
|
|
17
17
|
termType = term.getType(),
|
|
18
|
-
typeNode = typeNodeB, ///
|
|
19
18
|
type = localContext.findTypeByTypeNode(typeNode),
|
|
20
19
|
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
21
20
|
|
|
22
21
|
if (termTypeEqualToOrSubTypeOfType) {
|
|
23
|
-
|
|
22
|
+
verifiedAhead = true;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
return
|
|
25
|
+
return verifiedAhead;
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
termUnifiedAgainstType = termVerified; ///
|