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
package/src/judgement.js
CHANGED
|
@@ -31,26 +31,26 @@ class Judgement {
|
|
|
31
31
|
|
|
32
32
|
matchMetavariableNode(metavariableNode) { return this.frame.matchMetavariableNode(metavariableNode); }
|
|
33
33
|
|
|
34
|
-
verify(assignments, stated,
|
|
34
|
+
verify(assignments, stated, context) {
|
|
35
35
|
let verified;
|
|
36
36
|
|
|
37
37
|
const judgementString = this.string; ///
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
context.trace(`Verifying the '${judgementString}' judgement...`);
|
|
40
40
|
|
|
41
|
-
const frameVerified = this.frame.verify(assignments, stated,
|
|
41
|
+
const frameVerified = this.frame.verify(assignments, stated, context);
|
|
42
42
|
|
|
43
43
|
if (frameVerified) {
|
|
44
|
-
const declarationVerified = this.declaration.verify(assignments, stated,
|
|
44
|
+
const declarationVerified = this.declaration.verify(assignments, stated, context);
|
|
45
45
|
|
|
46
46
|
if (declarationVerified) {
|
|
47
47
|
let verifiedWhenStated = false,
|
|
48
48
|
verifiedWhenDerived = false;
|
|
49
49
|
|
|
50
50
|
if (stated) {
|
|
51
|
-
verifiedWhenStated = this.verifyWhenStated(assignments,
|
|
51
|
+
verifiedWhenStated = this.verifyWhenStated(assignments, context);
|
|
52
52
|
} else {
|
|
53
|
-
verifiedWhenDerived = this.verifyWhenDerived(assignments,
|
|
53
|
+
verifiedWhenDerived = this.verifyWhenDerived(assignments, context);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
@@ -60,18 +60,18 @@ class Judgement {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (verified) {
|
|
63
|
-
|
|
63
|
+
context.debug(`...verified the '${judgementString}' judgement.`);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
return verified;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
verifyWhenStated(assignments,
|
|
69
|
+
verifyWhenStated(assignments, context) {
|
|
70
70
|
let verifiedWhenStated;
|
|
71
71
|
|
|
72
72
|
const judgementString = this.string; ///
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
context.trace(`Verifying the '${judgementString}' judgement when stated...`);
|
|
75
75
|
|
|
76
76
|
if (assignments !== null) {
|
|
77
77
|
const judgement = this, ///
|
|
@@ -84,27 +84,27 @@ class Judgement {
|
|
|
84
84
|
verifiedWhenStated = true;
|
|
85
85
|
|
|
86
86
|
if (verifiedWhenStated) {
|
|
87
|
-
|
|
87
|
+
context.debug(`...verified the '${judgementString}' judgement when stated.`);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
return verifiedWhenStated;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
verifyWhenDerived(assignments,
|
|
93
|
+
verifyWhenDerived(assignments, context) {
|
|
94
94
|
let verifiedWhenDerived = false;
|
|
95
95
|
|
|
96
96
|
const judgementString = this.string; ///
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
context.trace(`Verifying the '${judgementString}' judgement when derived...`);
|
|
99
99
|
|
|
100
100
|
if (!verifiedWhenDerived) {
|
|
101
101
|
const reference = this.declaration.getReference(),
|
|
102
|
-
metaLemma =
|
|
103
|
-
metatheorem =
|
|
102
|
+
metaLemma = context.findMetaLemmaByReference(reference),
|
|
103
|
+
metatheorem = context.findMetatheoremByReference(reference),
|
|
104
104
|
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
105
105
|
|
|
106
106
|
if (metaLemmaMetatheorem !== null) {
|
|
107
|
-
const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem,
|
|
107
|
+
const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, context);
|
|
108
108
|
|
|
109
109
|
verifiedWhenDerived = metaLemmaMetatheoremUnified; ///
|
|
110
110
|
}
|
|
@@ -112,27 +112,27 @@ class Judgement {
|
|
|
112
112
|
|
|
113
113
|
if (!verifiedWhenDerived) {
|
|
114
114
|
const reference = this.declaration.getReference(),
|
|
115
|
-
axiom =
|
|
116
|
-
lemma =
|
|
117
|
-
theorem =
|
|
118
|
-
conjecture =
|
|
115
|
+
axiom = context.findAxiomByReference(reference),
|
|
116
|
+
lemma = context.findLemmaByReference(reference),
|
|
117
|
+
theorem = context.findTheoremByReference(reference),
|
|
118
|
+
conjecture = context.findConjectureByReference(reference),
|
|
119
119
|
axiomLemmaTheoremOrConjecture = (axiom || lemma || theorem || conjecture);
|
|
120
120
|
|
|
121
121
|
if (axiomLemmaTheoremOrConjecture !== null) {
|
|
122
|
-
const axiomLemmaTheoremOrConjectureUnified = this.frame.unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture,
|
|
122
|
+
const axiomLemmaTheoremOrConjectureUnified = this.frame.unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture, context);
|
|
123
123
|
|
|
124
124
|
verifiedWhenDerived = axiomLemmaTheoremOrConjectureUnified; ///
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (verifiedWhenDerived) {
|
|
129
|
-
|
|
129
|
+
context.debug(`...verified the '${judgementString}' judgement when derived.`);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
return verifiedWhenDerived;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
static fromJudgementNode(judgementNode,
|
|
135
|
+
static fromJudgementNode(judgementNode, context) {
|
|
136
136
|
let judgement = null;
|
|
137
137
|
|
|
138
138
|
if (judgementNode !== null) {
|
|
@@ -140,9 +140,9 @@ class Judgement {
|
|
|
140
140
|
frameNode = frameNodeQuery(judgementNode),
|
|
141
141
|
declarationNode = declarationNodeQuery(judgementNode),
|
|
142
142
|
node = judgementNode, ///
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
declaration = Declaration.fromDeclarationNode(declarationNode,
|
|
143
|
+
frame = Frame.fromFrameNode(frameNode, context),
|
|
144
|
+
string = context.nodeAsString(node),
|
|
145
|
+
declaration = Declaration.fromDeclarationNode(declarationNode, context);
|
|
146
146
|
|
|
147
147
|
judgement = new Judgement(string, frame, declaration);
|
|
148
148
|
}
|
package/src/label.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
|
+
import intrinsicLevelUnifier from "./unifier/intrinsicLevel";
|
|
5
6
|
|
|
6
7
|
import { nodeQuery } from "./utilities/query";
|
|
7
8
|
import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
|
|
@@ -21,6 +22,19 @@ class Label {
|
|
|
21
22
|
|
|
22
23
|
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
23
24
|
|
|
25
|
+
unifyReference(reference, generalContext, specificContext) {
|
|
26
|
+
const { Substitutions } = shim,
|
|
27
|
+
metavariableNode = this.metavariable.getNode(),
|
|
28
|
+
referenceMetavariable = reference.getMetavariable(),
|
|
29
|
+
referenceMetavariableNode = referenceMetavariable.getNode(),
|
|
30
|
+
metavariableNodeA = referenceMetavariableNode, ///
|
|
31
|
+
metavariableNodeB = metavariableNode, ///
|
|
32
|
+
substitutions = Substitutions.fromNothing(),
|
|
33
|
+
metavariableUnified = intrinsicLevelUnifier.unify(metavariableNodeA, metavariableNodeB, substitutions, generalContext, specificContext);
|
|
34
|
+
|
|
35
|
+
return metavariableUnified;
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
verifyWhenDeclared(fileContext) {
|
|
25
39
|
let verifiedAtTopLevel = false;
|
|
26
40
|
|
package/src/metaType.js
CHANGED
|
@@ -63,7 +63,7 @@ class MetaType {
|
|
|
63
63
|
return metaType;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
static fromMetaTypeNode(metaTypeNode,
|
|
66
|
+
static fromMetaTypeNode(metaTypeNode, context) {
|
|
67
67
|
const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
|
|
68
68
|
metaType = metaTypeFromMetaTypeName(metaTypeName);
|
|
69
69
|
|
package/src/metavariable.js
CHANGED
|
@@ -71,14 +71,14 @@ class Metavariable {
|
|
|
71
71
|
return metavariableNodeMatches;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
unifyFrame(frame, substitutions,
|
|
74
|
+
unifyFrame(frame, substitutions, generalContext, specificContext) {
|
|
75
75
|
let frameUnified = false;
|
|
76
76
|
|
|
77
77
|
const frameNode = frame.getNode(),
|
|
78
78
|
frameString = frame.getString(),
|
|
79
79
|
metavariableString = this.string; ///
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
specificContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
82
82
|
|
|
83
83
|
const metavariableNode = this.node, ///
|
|
84
84
|
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableNode(metavariableNode);
|
|
@@ -93,30 +93,31 @@ class Metavariable {
|
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
95
|
const metavariableNode = this.node, ///
|
|
96
|
-
metavariable = metavariableFromMetavariableNode(metavariableNode,
|
|
97
|
-
frameMetavariable = frameMetavariableFromStatementNode(frameNode,
|
|
96
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext),
|
|
97
|
+
frameMetavariable = frameMetavariableFromStatementNode(frameNode, generalContext, specificContext);
|
|
98
98
|
|
|
99
|
-
if (metavariable === frameMetavariable) {
|
|
99
|
+
if ((metavariable !== null) && (metavariable === frameMetavariable)) {
|
|
100
100
|
frameUnified = true;
|
|
101
101
|
} else {
|
|
102
102
|
const metavariable = this, ///
|
|
103
|
-
|
|
103
|
+
context = specificContext, ///
|
|
104
|
+
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
|
|
104
105
|
substitution = frameForMetavariableSubstitution; ///
|
|
105
106
|
|
|
106
|
-
substitutions.addSubstitution(substitution,
|
|
107
|
+
substitutions.addSubstitution(substitution, context);
|
|
107
108
|
|
|
108
109
|
frameUnified = true;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
if (frameUnified) {
|
|
113
|
-
|
|
114
|
+
specificContext.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
return frameUnified;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
unifyStatement(statement, substitution, substitutions,
|
|
120
|
+
unifyStatement(statement, substitution, substitutions, generalContext, specificContext) {
|
|
120
121
|
let statementUnified = false;
|
|
121
122
|
|
|
122
123
|
const statementString = statement.getString(),
|
|
@@ -125,7 +126,7 @@ class Metavariable {
|
|
|
125
126
|
substitution.getString() :
|
|
126
127
|
EMPTY_STRING;
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
specificContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
129
130
|
|
|
130
131
|
const statementNode = statement.getNode(),
|
|
131
132
|
metavariableNode = this.node, ///
|
|
@@ -143,68 +144,69 @@ class Metavariable {
|
|
|
143
144
|
}
|
|
144
145
|
} else {
|
|
145
146
|
const metavariableNode = this.node, ///
|
|
146
|
-
metavariable = metavariableFromMetavariableNode(metavariableNode,
|
|
147
|
-
statementMetavariable = statementMetavariableFromStatementNode(statementNode,
|
|
147
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext),
|
|
148
|
+
statementMetavariable = statementMetavariableFromStatementNode(statementNode, generalContext, specificContext);
|
|
148
149
|
|
|
149
150
|
if ((metavariable !== null) && (metavariable === statementMetavariable)) {
|
|
150
151
|
statementUnified = true;
|
|
151
152
|
} else {
|
|
152
|
-
const
|
|
153
|
-
|
|
153
|
+
const context = specificContext, ///
|
|
154
|
+
metavariable = this, ///
|
|
155
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context);
|
|
154
156
|
|
|
155
157
|
substitution = statementForMetavariableSubstitution; ///
|
|
156
158
|
|
|
157
|
-
substitutions.addSubstitution(substitution,
|
|
159
|
+
substitutions.addSubstitution(substitution, context);
|
|
158
160
|
|
|
159
161
|
statementUnified = true;
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
if (statementUnified) {
|
|
164
|
-
|
|
166
|
+
specificContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
return statementUnified;
|
|
168
170
|
}
|
|
169
171
|
|
|
170
|
-
unifySubstitution(substitution,
|
|
172
|
+
unifySubstitution(substitution, context) {
|
|
171
173
|
let substitutionUnified = false;
|
|
172
174
|
|
|
173
175
|
const metavariableString = this.string, ///
|
|
174
176
|
substitutionString = substitution.getString();
|
|
175
177
|
|
|
176
|
-
|
|
178
|
+
context.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
|
|
177
179
|
|
|
178
180
|
const metavariableNode = this.node, ///
|
|
179
|
-
judgement =
|
|
181
|
+
judgement = context.findJudgementByMetavariableNode(metavariableNode);
|
|
180
182
|
|
|
181
183
|
if (judgement !== null){
|
|
182
184
|
const declaration = judgement.getDeclaration();
|
|
183
185
|
|
|
184
|
-
substitutionUnified = declaration.unifySubstitution(substitution,
|
|
186
|
+
substitutionUnified = declaration.unifySubstitution(substitution, context);
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
if (substitutionUnified) {
|
|
188
|
-
|
|
190
|
+
context.debug(`...unified the '${substitutionString}' substitution with the '${metavariableString}' metavariable.`);
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
return substitutionUnified;
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
verify(
|
|
196
|
+
verify(context) {
|
|
195
197
|
let verified;
|
|
196
198
|
|
|
197
199
|
const metavariableString = this.string; ///
|
|
198
200
|
|
|
199
|
-
|
|
201
|
+
context.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
200
202
|
|
|
201
203
|
const metavariableNode = this.node,
|
|
202
|
-
metavariablePresent =
|
|
204
|
+
metavariablePresent = context.isMetavariablePresentByMetavariableNode(metavariableNode);
|
|
203
205
|
|
|
204
206
|
verified = metavariablePresent; ///
|
|
205
207
|
|
|
206
208
|
if (verified) {
|
|
207
|
-
|
|
209
|
+
context.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
return verified;
|
|
@@ -227,9 +229,7 @@ class Metavariable {
|
|
|
227
229
|
const termNode = termNodeQuery(this.node);
|
|
228
230
|
|
|
229
231
|
if (termNode !== null) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
this.fileContext.debug(`The '${termString}' term was found when a type should have been present.`);
|
|
232
|
+
this.fileContext.debug(`A term was found in the '${metavariableString}' metavariable when a type should have been present.`);
|
|
233
233
|
} else {
|
|
234
234
|
const typeNode = typeNodeQuery(this.node);
|
|
235
235
|
|
|
@@ -255,16 +255,18 @@ class Metavariable {
|
|
|
255
255
|
return verifiedAtTopLevel;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
verifyGivenMetaType(metaType,
|
|
258
|
+
verifyGivenMetaType(metaType, context) {
|
|
259
259
|
let verifiedGivenMetaType = false;
|
|
260
260
|
|
|
261
261
|
const metavariableString = this.string, ///
|
|
262
262
|
metaTypeString = metaType.getString();
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
context.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
265
265
|
|
|
266
266
|
const metavariableNode = this.node, ///
|
|
267
|
-
|
|
267
|
+
specificContext = context, ///
|
|
268
|
+
generalContext = context, ///
|
|
269
|
+
metavariable = generalContext.findMetavariableByMetavariableNode(metavariableNode, specificContext);
|
|
268
270
|
|
|
269
271
|
if (metavariable !== null) {
|
|
270
272
|
const metaTypeMatches = metavariable.matchMetaType(metaType);
|
|
@@ -273,7 +275,7 @@ class Metavariable {
|
|
|
273
275
|
}
|
|
274
276
|
|
|
275
277
|
if (verifiedGivenMetaType) {
|
|
276
|
-
|
|
278
|
+
context.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
|
|
277
279
|
}
|
|
278
280
|
|
|
279
281
|
return verifiedGivenMetaType;
|
|
@@ -306,17 +308,17 @@ class Metavariable {
|
|
|
306
308
|
return metavariable;
|
|
307
309
|
}
|
|
308
310
|
|
|
309
|
-
static fromMetavariableNode(metavariableNode,
|
|
311
|
+
static fromMetavariableNode(metavariableNode, context) {
|
|
310
312
|
let metavariable = null;
|
|
311
313
|
|
|
312
314
|
if (metavariableNode !== null) {
|
|
313
315
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
314
316
|
node = metavariableNode, ///
|
|
315
317
|
name = metavariableName, ///
|
|
316
|
-
string =
|
|
318
|
+
string = context.nodeAsString(node),
|
|
317
319
|
metaType = null;
|
|
318
320
|
|
|
319
|
-
metavariable = new Metavariable(
|
|
321
|
+
metavariable = new Metavariable(context, string, node, name, metaType);
|
|
320
322
|
}
|
|
321
323
|
|
|
322
324
|
return metavariable;
|
|
@@ -327,12 +329,13 @@ class Metavariable {
|
|
|
327
329
|
metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
328
330
|
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
|
|
329
331
|
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
330
|
-
localContext = LocalContext.fromFileContext(fileContext),
|
|
331
332
|
metavariableString = fileContext.nodeAsString(metavariableNode),
|
|
333
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
334
|
+
context = localContext, ///
|
|
332
335
|
string = metavariableString, ///
|
|
333
336
|
node = metavariableNode, ///
|
|
334
337
|
name = metavariableName, ///
|
|
335
|
-
metaType = MetaType.fromMetaTypeNode(metaTypeNode,
|
|
338
|
+
metaType = MetaType.fromMetaTypeNode(metaTypeNode, context),
|
|
336
339
|
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
337
340
|
|
|
338
341
|
return metavariable;
|
|
@@ -345,31 +348,36 @@ Object.assign(shim, {
|
|
|
345
348
|
|
|
346
349
|
export default Metavariable;
|
|
347
350
|
|
|
348
|
-
function metavariableFromMetavariableNode(metavariableNode,
|
|
349
|
-
const
|
|
351
|
+
function metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext) {
|
|
352
|
+
const context = generalContext, ///
|
|
353
|
+
metavariable = context.findMetavariableByMetavariableNode(metavariableNode, specificContext);
|
|
350
354
|
|
|
351
355
|
return metavariable;
|
|
352
356
|
}
|
|
353
357
|
|
|
354
|
-
function frameMetavariableFromStatementNode(frameNode,
|
|
358
|
+
function frameMetavariableFromStatementNode(frameNode, generalContext, specificContext) {
|
|
355
359
|
let frameMetavariable = null;
|
|
356
360
|
|
|
357
361
|
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
|
|
358
362
|
|
|
359
363
|
if (frameMetavariableNode !== null) {
|
|
360
|
-
|
|
364
|
+
const context = generalContext; ///
|
|
365
|
+
|
|
366
|
+
frameMetavariable = context.findMetavariableByMetavariableNode(frameMetavariableNode, specificContext);
|
|
361
367
|
}
|
|
362
368
|
|
|
363
369
|
return frameMetavariable;
|
|
364
370
|
}
|
|
365
371
|
|
|
366
|
-
function statementMetavariableFromStatementNode(statementNode,
|
|
372
|
+
function statementMetavariableFromStatementNode(statementNode, generalContext, specificContext) {
|
|
367
373
|
let statementMetavariable = null;
|
|
368
374
|
|
|
369
375
|
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
370
376
|
|
|
371
377
|
if (statementMetavariableNode !== null) {
|
|
372
|
-
|
|
378
|
+
const context = generalContext;
|
|
379
|
+
|
|
380
|
+
statementMetavariable = context.findMetavariableByMetavariableNode(statementMetavariableNode, specificContext);
|
|
373
381
|
}
|
|
374
382
|
|
|
375
383
|
return statementMetavariable;
|
|
@@ -4,92 +4,92 @@ import StatementForMetavariableSubstitution from "../../../substitution/statemen
|
|
|
4
4
|
|
|
5
5
|
import { trim } from "../../../utilities/string";
|
|
6
6
|
|
|
7
|
-
function unifyAWithRule(qualifiedStatement, substitutions,
|
|
7
|
+
function unifyAWithRule(qualifiedStatement, substitutions, context) {
|
|
8
8
|
let unifiedWithRule = false;
|
|
9
9
|
|
|
10
10
|
const reference = qualifiedStatement.getReference(),
|
|
11
|
-
rule =
|
|
11
|
+
rule = context.findRuleByReference(reference);
|
|
12
12
|
|
|
13
13
|
if (rule !== null) {
|
|
14
14
|
const referenceString = reference.getString(),
|
|
15
15
|
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
context.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule...`);
|
|
18
18
|
|
|
19
19
|
const statement = qualifiedStatement.getStatement(),
|
|
20
|
-
statementUnified = rule.unifyStatement(statement,
|
|
20
|
+
statementUnified = rule.unifyStatement(statement, context);
|
|
21
21
|
|
|
22
22
|
unifiedWithRule = statementUnified; ///
|
|
23
23
|
|
|
24
24
|
if (unifiedWithRule) {
|
|
25
|
-
|
|
25
|
+
context.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return unifiedWithRule;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function unifyAWithReference(qualifiedStatement, substitutions,
|
|
32
|
+
function unifyAWithReference(qualifiedStatement, substitutions, context) {
|
|
33
33
|
let unifiedWithReference = false;
|
|
34
34
|
|
|
35
35
|
const reference = qualifiedStatement.getReference(),
|
|
36
36
|
metavariableNode = reference.getMetavariableNode(),
|
|
37
|
-
metavariablePresent =
|
|
37
|
+
metavariablePresent = context.isMetavariablePresentByMetavariableNode(metavariableNode);
|
|
38
38
|
|
|
39
39
|
if (metavariablePresent) {
|
|
40
40
|
const statement = qualifiedStatement.getStatement(),
|
|
41
41
|
statementString = statement.getString(),
|
|
42
42
|
referenceString = reference.getString();
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
context.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
|
|
45
45
|
|
|
46
46
|
const metavariable = reference.getMetavariable(),
|
|
47
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable,
|
|
47
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, context),
|
|
48
48
|
substitution = statementForMetavariableSubstitution; ///
|
|
49
49
|
|
|
50
|
-
substitutions.addSubstitution(substitution,
|
|
50
|
+
substitutions.addSubstitution(substitution, context);
|
|
51
51
|
|
|
52
52
|
unifiedWithReference = true;
|
|
53
53
|
|
|
54
54
|
if (unifiedWithReference) {
|
|
55
|
-
|
|
55
|
+
context.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
return unifiedWithReference;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function unifyAWithAxiomLemmaTheoremOrConjecture(qualifiedStatement, substitutions,
|
|
62
|
+
function unifyAWithAxiomLemmaTheoremOrConjecture(qualifiedStatement, substitutions, context) {
|
|
63
63
|
let unifiedWithAxiomLemmaTheoremOrConjecture = false;
|
|
64
64
|
|
|
65
65
|
const reference = qualifiedStatement.getReference(),
|
|
66
|
-
axiom =
|
|
67
|
-
lemma =
|
|
68
|
-
theorem =
|
|
69
|
-
conjecture =
|
|
66
|
+
axiom = context.findAxiomByReference(reference),
|
|
67
|
+
lemma = context.findLemmaByReference(reference),
|
|
68
|
+
theorem = context.findTheoremByReference(reference),
|
|
69
|
+
conjecture = context.findConjectureByReference(reference),
|
|
70
70
|
axiomLemmaTheoremConjecture = (axiom || lemma || theorem || conjecture);
|
|
71
71
|
|
|
72
72
|
if (axiomLemmaTheoremConjecture !== null) {
|
|
73
73
|
const referenceString = reference.getString(),
|
|
74
74
|
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
context.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture...`);
|
|
77
77
|
|
|
78
78
|
const statement = qualifiedStatement.getStatement(),
|
|
79
|
-
statementUnified = axiomLemmaTheoremConjecture.unifyStatement(statement,
|
|
79
|
+
statementUnified = axiomLemmaTheoremConjecture.unifyStatement(statement, context);
|
|
80
80
|
|
|
81
81
|
if (statementUnified) {
|
|
82
82
|
const metavariable = reference.getMetavariable(),
|
|
83
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable,
|
|
83
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, context),
|
|
84
84
|
substitution = statementForMetavariableSubstitution; ///
|
|
85
85
|
|
|
86
|
-
substitutions.addSubstitution(substitution,
|
|
86
|
+
substitutions.addSubstitution(substitution, context);
|
|
87
87
|
|
|
88
88
|
unifiedWithAxiomLemmaTheoremOrConjecture = true;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if (unifiedWithAxiomLemmaTheoremOrConjecture) {
|
|
92
|
-
|
|
92
|
+
context.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture.`);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -8,52 +8,52 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
8
8
|
const definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion"),
|
|
9
9
|
containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion");
|
|
10
10
|
|
|
11
|
-
function resolveAsDefinedAssertion(statement, substitutions,
|
|
11
|
+
function resolveAsDefinedAssertion(statement, substitutions, generalContext, specificContext) {
|
|
12
12
|
let resolvedAsDefinedAssertion = false;
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const context = generalContext, ///
|
|
15
15
|
statementNode = statement.getNode(),
|
|
16
16
|
definedAssertionNode = definedAssertionNodeQuery(statementNode),
|
|
17
|
-
definedAssertion = DefinedAssertion.fromDefinedAssertionNode(definedAssertionNode,
|
|
17
|
+
definedAssertion = DefinedAssertion.fromDefinedAssertionNode(definedAssertionNode, context);
|
|
18
18
|
|
|
19
19
|
if (definedAssertion !== null) {
|
|
20
20
|
const statementString = statement.getString();
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
specificContext.trace(`Resolving the '${statementString}' statement as a defined assertion...`);
|
|
23
23
|
|
|
24
|
-
const localContext =
|
|
24
|
+
const localContext = specificContext, ///
|
|
25
25
|
definedAssertionVerified = definedAssertion.resolve(substitutions, localContext);
|
|
26
26
|
|
|
27
27
|
resolvedAsDefinedAssertion = definedAssertionVerified; ///
|
|
28
28
|
|
|
29
29
|
if (resolvedAsDefinedAssertion) {
|
|
30
|
-
|
|
30
|
+
specificContext.debug(`...resolved the '${statementString}' statement as a defined assertion.`);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return resolvedAsDefinedAssertion;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function resolveAsContainedAssertion(statement, substitutions,
|
|
37
|
+
function resolveAsContainedAssertion(statement, substitutions, generalContext, specificContext) {
|
|
38
38
|
let resolvedAsContainedAssertion = false;
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const context = generalContext, ///
|
|
41
41
|
statementNode = statement.getNode(),
|
|
42
42
|
containedAssertionNode = containedAssertionNodeQuery(statementNode),
|
|
43
|
-
containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode,
|
|
43
|
+
containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode, context);
|
|
44
44
|
|
|
45
45
|
if (containedAssertion !== null) {
|
|
46
46
|
const statementString = statement.getString();
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
specificContext.trace(`Resolving the '${statementString}' statement as a contained assertion...`);
|
|
49
49
|
|
|
50
|
-
const localContext =
|
|
50
|
+
const localContext = specificContext, ///
|
|
51
51
|
containedAssertionVerified = containedAssertion.resolve(substitutions, localContext);
|
|
52
52
|
|
|
53
53
|
resolvedAsContainedAssertion = containedAssertionVerified; ///
|
|
54
54
|
|
|
55
55
|
if (resolvedAsContainedAssertion) {
|
|
56
|
-
|
|
56
|
+
specificContext.debug(`...resolved the '${statementString}' statement as a contained assertion.`);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|