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/supposition.js
CHANGED
|
@@ -28,33 +28,36 @@ class Supposition {
|
|
|
28
28
|
|
|
29
29
|
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
30
30
|
|
|
31
|
-
resolveIndependently(substitutions,
|
|
31
|
+
resolveIndependently(substitutions, context) {
|
|
32
32
|
let resolvedIndependently;
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
35
|
+
generalContext = localContext, ///
|
|
36
|
+
specificContext = context; ///
|
|
35
37
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
39
|
-
|
|
40
|
-
const localContextA = localContext; ///
|
|
38
|
+
const supposition = this, ///
|
|
39
|
+
suppositionString = supposition.getString();
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
specificContext.trace(`Resolving the '${suppositionString}' supposition independently...`);
|
|
43
42
|
|
|
44
|
-
const unqualifiedStatementResolvedIndependently = this.unqualifiedStatement.resolveIndependently(substitutions,
|
|
43
|
+
const unqualifiedStatementResolvedIndependently = this.unqualifiedStatement.resolveIndependently(substitutions, generalContext, specificContext);
|
|
45
44
|
|
|
46
45
|
resolvedIndependently = unqualifiedStatementResolvedIndependently; ///
|
|
47
46
|
|
|
48
47
|
if (resolvedIndependently) {
|
|
49
|
-
|
|
48
|
+
specificContext.trace(`...resolved the '${suppositionString}' supposition independently.`);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
return resolvedIndependently;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
unifyProofStep(proofStep, substitutions,
|
|
54
|
+
unifyProofStep(proofStep, substitutions, context) {
|
|
56
55
|
let proofStepUnified = false;
|
|
57
56
|
|
|
57
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
58
|
+
generalContext = localContext, ///
|
|
59
|
+
specificContext = context; ///
|
|
60
|
+
|
|
58
61
|
const subproof = proofStep.getSubproof(),
|
|
59
62
|
statement = proofStep.getStatement();
|
|
60
63
|
|
|
@@ -66,54 +69,47 @@ class Supposition {
|
|
|
66
69
|
if (false) {
|
|
67
70
|
///
|
|
68
71
|
} else if (subproof !== null) {
|
|
69
|
-
subproofUnified = this.unifySubproof(subproof, substitutions,
|
|
72
|
+
subproofUnified = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
70
73
|
} else if (statement !== null) {
|
|
71
|
-
statementUnified = this.unifyStatement(statement, substitutions,
|
|
74
|
+
statementUnified = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
if (subproofUnified || statementUnified) {
|
|
75
|
-
const
|
|
78
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
79
|
+
generalContext = localContext, ///
|
|
80
|
+
specificContext = context; ///
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const localContextA = localContext; ///
|
|
80
|
-
|
|
81
|
-
substitutions.resolve(localContextA, localContextB);
|
|
82
|
+
substitutions.resolve(generalContext, specificContext);
|
|
82
83
|
|
|
83
84
|
proofStepUnified = true;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
proofStepUnified ?
|
|
87
88
|
substitutions.continue() :
|
|
88
|
-
substitutions.rollback(
|
|
89
|
+
substitutions.rollback(context);
|
|
89
90
|
|
|
90
91
|
return proofStepUnified;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
unifyStatement(statement, substitutions,
|
|
94
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
94
95
|
let statementUnified;
|
|
95
96
|
|
|
96
|
-
const
|
|
97
|
-
suppositionString =
|
|
98
|
-
|
|
99
|
-
const localContextB = localContext; ///
|
|
100
|
-
|
|
101
|
-
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
102
|
-
|
|
103
|
-
const localContextA = localContext; ///
|
|
97
|
+
const supposition = this, ///
|
|
98
|
+
suppositionString = supposition.getString(),
|
|
99
|
+
statementString = statement.getString();
|
|
104
100
|
|
|
105
|
-
|
|
101
|
+
specificContext.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
|
|
106
102
|
|
|
107
|
-
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions,
|
|
103
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
108
104
|
|
|
109
105
|
if (statementUnified) {
|
|
110
|
-
|
|
106
|
+
specificContext.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
return statementUnified;
|
|
114
110
|
}
|
|
115
111
|
|
|
116
|
-
unifySubproof(subproof, substitutions,
|
|
112
|
+
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
117
113
|
let subproofUnified = false;
|
|
118
114
|
|
|
119
115
|
const supposition = this, ///
|
|
@@ -121,59 +117,51 @@ class Supposition {
|
|
|
121
117
|
suppositionStatement = supposition.getStatement(),
|
|
122
118
|
suppositionStatementString = suppositionStatement.getString();
|
|
123
119
|
|
|
124
|
-
const localContextB = localContext; ///
|
|
125
|
-
|
|
126
120
|
const statement = this.unqualifiedStatement.getStatement(),
|
|
127
|
-
|
|
128
|
-
context = this.fileContext, ///
|
|
129
|
-
tokens = statementTokens; ///
|
|
130
|
-
|
|
131
|
-
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
132
|
-
|
|
133
|
-
const localContextA = localContext; ///
|
|
121
|
+
statementNode = statement.getNode();
|
|
134
122
|
|
|
135
|
-
|
|
123
|
+
specificContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
136
124
|
|
|
137
|
-
const
|
|
138
|
-
subproofAssertion = SubproofAssertion.fromStatementNode(statementNode,
|
|
125
|
+
const context = specificContext, ///
|
|
126
|
+
subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, context);
|
|
139
127
|
|
|
140
128
|
if (subproofAssertion !== null) {
|
|
141
|
-
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions,
|
|
129
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
142
130
|
}
|
|
143
131
|
|
|
144
132
|
if (subproofUnified) {
|
|
145
|
-
|
|
133
|
+
specificContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
|
|
146
134
|
}
|
|
147
135
|
|
|
148
136
|
return subproofUnified;
|
|
149
137
|
}
|
|
150
138
|
|
|
151
|
-
verify(
|
|
139
|
+
verify(context) {
|
|
152
140
|
let verified = false;
|
|
153
141
|
|
|
154
142
|
const suppositionString = this.getString(); ///
|
|
155
143
|
|
|
156
|
-
|
|
144
|
+
context.trace(`Verifying the '${suppositionString}' supposition...`);
|
|
157
145
|
|
|
158
146
|
const stated = true,
|
|
159
147
|
assignments = [],
|
|
160
|
-
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated,
|
|
148
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, context);
|
|
161
149
|
|
|
162
150
|
if (unqualifiedStatementVerified) {
|
|
163
|
-
const assignmentsAssigned = assignAssignments(assignments,
|
|
151
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
164
152
|
|
|
165
153
|
if (assignmentsAssigned) {
|
|
166
154
|
const { ProofStep } = shim,
|
|
167
155
|
proofStep = ProofStep.fromUnqualifiedStatement(this.unqualifiedStatement);
|
|
168
156
|
|
|
169
|
-
|
|
157
|
+
context.addProofStep(proofStep);
|
|
170
158
|
|
|
171
159
|
verified = true;
|
|
172
160
|
}
|
|
173
161
|
}
|
|
174
162
|
|
|
175
163
|
if (verified) {
|
|
176
|
-
|
|
164
|
+
context.debug(`...verified the '${suppositionString}' supposition.`);
|
|
177
165
|
}
|
|
178
166
|
|
|
179
167
|
return verified;
|
package/src/term.js
CHANGED
|
@@ -42,7 +42,7 @@ class Term {
|
|
|
42
42
|
this.type = type;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
getVariable(
|
|
45
|
+
getVariable(context) {
|
|
46
46
|
let variable = null;
|
|
47
47
|
|
|
48
48
|
const variableNode = variableNodeQuery(this.node);
|
|
@@ -50,19 +50,19 @@ class Term {
|
|
|
50
50
|
if (variableNode !== null) {
|
|
51
51
|
const variableName = variableNameFromVariableNode(variableNode);
|
|
52
52
|
|
|
53
|
-
variable =
|
|
53
|
+
variable = context.findVariableByVariableName(variableName);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
return variable;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
getVariables(
|
|
59
|
+
getVariables(context) {
|
|
60
60
|
const variables = [],
|
|
61
61
|
variableNodes = variableNodesQuery(this.node);
|
|
62
62
|
|
|
63
63
|
variableNodes.forEach((variableNode) => {
|
|
64
64
|
const variableName = variableNameFromVariableNode(variableNode),
|
|
65
|
-
variable =
|
|
65
|
+
variable = context.findVariableByVariableName(variableName),
|
|
66
66
|
variablesIncludesVariable = variables.includes(variable);
|
|
67
67
|
|
|
68
68
|
if (!variablesIncludesVariable) {
|
|
@@ -73,8 +73,8 @@ class Term {
|
|
|
73
73
|
return variables;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
isGrounded(definedVariables,
|
|
77
|
-
const variables = this.getVariables(
|
|
76
|
+
isGrounded(definedVariables, context) {
|
|
77
|
+
const variables = this.getVariables(context);
|
|
78
78
|
|
|
79
79
|
filter(variables, (variable) => {
|
|
80
80
|
const definedVariablesIncludesVariable = definedVariables.includes(variable);
|
|
@@ -114,32 +114,32 @@ class Term {
|
|
|
114
114
|
return termNodeMatches;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
isInitiallyGrounded(
|
|
118
|
-
const variables = this.getVariables(
|
|
117
|
+
isInitiallyGrounded(context) {
|
|
118
|
+
const variables = this.getVariables(context),
|
|
119
119
|
variablesLength = variables.length,
|
|
120
120
|
initiallyGrounded = (variablesLength === 0);
|
|
121
121
|
|
|
122
122
|
return initiallyGrounded;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
isImplicitlyGrounded(definedVariables,
|
|
126
|
-
const grounded = this.isGrounded(definedVariables,
|
|
125
|
+
isImplicitlyGrounded(definedVariables, context) {
|
|
126
|
+
const grounded = this.isGrounded(definedVariables, context),
|
|
127
127
|
implicitlyGrounded = grounded; ///
|
|
128
128
|
|
|
129
129
|
return implicitlyGrounded;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
verify(
|
|
132
|
+
verify(context, verifyAhead) {
|
|
133
133
|
let verified = false;
|
|
134
134
|
|
|
135
135
|
const term = this, ///
|
|
136
136
|
termString = this.string; ///
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
context.trace(`Verifying the '${termString}' term...`);
|
|
139
139
|
|
|
140
140
|
if (!verified) {
|
|
141
141
|
verified = verifyMixins.some((verifyMixin) => {
|
|
142
|
-
const verified = verifyMixin(term,
|
|
142
|
+
const verified = verifyMixin(term, context, verifyAhead);
|
|
143
143
|
|
|
144
144
|
if (verified) {
|
|
145
145
|
return true;
|
|
@@ -149,7 +149,7 @@ class Term {
|
|
|
149
149
|
|
|
150
150
|
if (!verified) {
|
|
151
151
|
const unified = unifyMixins.some((unifyMixin) => { ///
|
|
152
|
-
const unified = unifyMixin(term,
|
|
152
|
+
const unified = unifyMixin(term, context, verifyAhead);
|
|
153
153
|
|
|
154
154
|
if (unified) {
|
|
155
155
|
return true;
|
|
@@ -160,7 +160,7 @@ class Term {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
if (verified) {
|
|
163
|
-
|
|
163
|
+
context.debug(`...verified the '${termString}' term.`);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
return verified;
|
|
@@ -194,15 +194,15 @@ class Term {
|
|
|
194
194
|
return typeVerified;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
verifyGivenType(type,
|
|
197
|
+
verifyGivenType(type, context) {
|
|
198
198
|
let verifiedGivenType;
|
|
199
199
|
|
|
200
200
|
const typeName = type.getName(),
|
|
201
201
|
termString = this.getString();
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
context.trace(`Verifying the '${termString}' term given the '${typeName}' type...`);
|
|
204
204
|
|
|
205
|
-
const verified = this.verify(
|
|
205
|
+
const verified = this.verify(context, () => {
|
|
206
206
|
let verifiedAhead;
|
|
207
207
|
|
|
208
208
|
const typeEqualToOrSubTypeOfGivenTypeType = this.type.isEqualToOrSubTypeOf(type);
|
|
@@ -217,7 +217,7 @@ class Term {
|
|
|
217
217
|
verifiedGivenType = verified; ///
|
|
218
218
|
|
|
219
219
|
if (verifiedGivenType) {
|
|
220
|
-
|
|
220
|
+
context.debug(`...verified the '${termString}' term given the '${typeName}' type.`);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
return verifiedGivenType;
|
|
@@ -271,12 +271,12 @@ class Term {
|
|
|
271
271
|
return term;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
static fromTermNode(termNode,
|
|
274
|
+
static fromTermNode(termNode, context) {
|
|
275
275
|
let term = null;
|
|
276
276
|
|
|
277
277
|
if (termNode !== null) {
|
|
278
278
|
const node = termNode, ///
|
|
279
|
-
string =
|
|
279
|
+
string = context.nodeAsString(node),
|
|
280
280
|
type = null;
|
|
281
281
|
|
|
282
282
|
term = new Term(string, node, type);
|
|
@@ -285,15 +285,15 @@ class Term {
|
|
|
285
285
|
return term;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
static fromTermNodeAndType(termNode, type,
|
|
288
|
+
static fromTermNodeAndType(termNode, type, context) {
|
|
289
289
|
const node = termNode, ///
|
|
290
|
-
string =
|
|
290
|
+
string = context.nodeAsString(node),
|
|
291
291
|
term = new Term(string, node, type);
|
|
292
292
|
|
|
293
293
|
return term;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
static fromDefinedAssertionNode(definedAssertionNode,
|
|
296
|
+
static fromDefinedAssertionNode(definedAssertionNode, context) {
|
|
297
297
|
let term = null;
|
|
298
298
|
|
|
299
299
|
const termNode = termNodeQuery(definedAssertionNode);
|
|
@@ -303,7 +303,7 @@ class Term {
|
|
|
303
303
|
|
|
304
304
|
if (variableNode !== null) {
|
|
305
305
|
const node = termNode, ///
|
|
306
|
-
string =
|
|
306
|
+
string = context.nodeAsString(node),
|
|
307
307
|
type = null;
|
|
308
308
|
|
|
309
309
|
term = new Term(string, node, type);
|
|
@@ -313,7 +313,7 @@ class Term {
|
|
|
313
313
|
return term;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
static fromContainedAssertionNode(containedAssertionNode,
|
|
316
|
+
static fromContainedAssertionNode(containedAssertionNode, context) {
|
|
317
317
|
let term = null;
|
|
318
318
|
|
|
319
319
|
const termNode = termNodeQuery(containedAssertionNode);
|
|
@@ -323,7 +323,7 @@ class Term {
|
|
|
323
323
|
|
|
324
324
|
if (variableNode !== null) {
|
|
325
325
|
const node = termNode, ///
|
|
326
|
-
string =
|
|
326
|
+
string = context.nodeAsString(node),
|
|
327
327
|
type = null;
|
|
328
328
|
|
|
329
329
|
term = new Term(string, node, type);
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -76,15 +76,27 @@ export default class TopLevelAssertion {
|
|
|
76
76
|
return metavariableNodeMatches;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
unifyReference(reference, generalContext, specificContext) {
|
|
80
|
+
const referenceUnified = this.labels.some((label) => {
|
|
81
|
+
const referenceUnified = label.unifyReference(reference, generalContext, specificContext);
|
|
82
|
+
|
|
83
|
+
if (referenceUnified) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return referenceUnified;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
unifyStatement(statement, context) {
|
|
80
92
|
let statementUnified;
|
|
81
93
|
|
|
82
94
|
const { Substitutions } = shim,
|
|
83
95
|
substitutions = Substitutions.fromNothing(),
|
|
84
|
-
consequentUnified = this.unifyConsequent(statement, substitutions,
|
|
96
|
+
consequentUnified = this.unifyConsequent(statement, substitutions, context);
|
|
85
97
|
|
|
86
98
|
if (consequentUnified) {
|
|
87
|
-
const suppositionsUnified = this.unifySupposition(substitutions,
|
|
99
|
+
const suppositionsUnified = this.unifySupposition(substitutions, context);
|
|
88
100
|
|
|
89
101
|
if (suppositionsUnified) {
|
|
90
102
|
const substitutionsResolved = substitutions.areResolved();
|
|
@@ -96,31 +108,31 @@ export default class TopLevelAssertion {
|
|
|
96
108
|
return statementUnified;
|
|
97
109
|
}
|
|
98
110
|
|
|
99
|
-
unifyConsequent(statement, substitutions,
|
|
111
|
+
unifyConsequent(statement, substitutions, context) {
|
|
100
112
|
let consequentUnified;
|
|
101
113
|
|
|
102
114
|
const consequentString = this.consequent.getString();
|
|
103
115
|
|
|
104
|
-
|
|
116
|
+
context.trace(`Unifying the '${consequentString}' consequent...`);
|
|
105
117
|
|
|
106
|
-
const statementUnified = this.consequent.unifyStatement(statement, substitutions,
|
|
118
|
+
const statementUnified = this.consequent.unifyStatement(statement, substitutions, context); ///
|
|
107
119
|
|
|
108
120
|
consequentUnified = statementUnified; ///
|
|
109
121
|
|
|
110
122
|
if (consequentUnified) {
|
|
111
|
-
|
|
123
|
+
context.debug(`...unified the '${consequentString}' consequent`);
|
|
112
124
|
}
|
|
113
125
|
|
|
114
126
|
return consequentUnified;
|
|
115
127
|
}
|
|
116
128
|
|
|
117
|
-
unifySupposition(substitutions,
|
|
118
|
-
let proofSteps =
|
|
129
|
+
unifySupposition(substitutions, context) {
|
|
130
|
+
let proofSteps = context.getProofSteps();
|
|
119
131
|
|
|
120
132
|
proofSteps = reverse(proofSteps); ///
|
|
121
133
|
|
|
122
134
|
const suppositionsUnified = backwardsEvery(this.suppositions, (supposition) => {
|
|
123
|
-
const suppositionUnified = this.unifyPremise(supposition, proofSteps, substitutions,
|
|
135
|
+
const suppositionUnified = this.unifyPremise(supposition, proofSteps, substitutions, context);
|
|
124
136
|
|
|
125
137
|
if (suppositionUnified) {
|
|
126
138
|
return true;
|
|
@@ -130,25 +142,25 @@ export default class TopLevelAssertion {
|
|
|
130
142
|
return suppositionsUnified;
|
|
131
143
|
}
|
|
132
144
|
|
|
133
|
-
unifyPremise(supposition, proofSteps, substitutions,
|
|
145
|
+
unifyPremise(supposition, proofSteps, substitutions, context) {
|
|
134
146
|
let suppositionUnified =false;
|
|
135
147
|
|
|
136
148
|
const suppositionString = supposition.getString();
|
|
137
149
|
|
|
138
|
-
|
|
150
|
+
context.trace(`Unifying the '${suppositionString}' supposition...`);
|
|
139
151
|
|
|
140
|
-
const suppositionResolvedIndependently = supposition.resolveIndependently(substitutions,
|
|
152
|
+
const suppositionResolvedIndependently = supposition.resolveIndependently(substitutions, context);
|
|
141
153
|
|
|
142
154
|
if (suppositionResolvedIndependently) {
|
|
143
155
|
suppositionUnified = true;
|
|
144
156
|
} else {
|
|
145
157
|
const proofStep = extract(proofSteps, (proofStep) => {
|
|
146
|
-
const proofStepUnified = supposition.unifyProofStep(proofStep, substitutions,
|
|
158
|
+
const proofStepUnified = supposition.unifyProofStep(proofStep, substitutions, context);
|
|
147
159
|
|
|
148
160
|
if (proofStepUnified) {
|
|
149
161
|
return true;
|
|
150
162
|
}
|
|
151
|
-
});
|
|
163
|
+
}) || null;
|
|
152
164
|
|
|
153
165
|
if (proofStep !== null) {
|
|
154
166
|
suppositionUnified = true;
|
|
@@ -156,7 +168,7 @@ export default class TopLevelAssertion {
|
|
|
156
168
|
}
|
|
157
169
|
|
|
158
170
|
if (suppositionUnified) {
|
|
159
|
-
|
|
171
|
+
context.debug(`...unified the '${suppositionString}' supposition.`);
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
return suppositionUnified;
|
|
@@ -175,8 +187,9 @@ export default class TopLevelAssertion {
|
|
|
175
187
|
|
|
176
188
|
if (labelsVerifiedWhenDeclared) {
|
|
177
189
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
190
|
+
context = localContext, ///
|
|
178
191
|
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
179
|
-
const suppositionVerified = supposition.verify(
|
|
192
|
+
const suppositionVerified = supposition.verify(context);
|
|
180
193
|
|
|
181
194
|
if (suppositionVerified) {
|
|
182
195
|
return true;
|
|
@@ -184,13 +197,13 @@ export default class TopLevelAssertion {
|
|
|
184
197
|
});
|
|
185
198
|
|
|
186
199
|
if (suppositionsVerified) {
|
|
187
|
-
const consequentVerified = this.consequent.verify(
|
|
200
|
+
const consequentVerified = this.consequent.verify(context);
|
|
188
201
|
|
|
189
202
|
if (consequentVerified) {
|
|
190
203
|
if (this.proof === null) {
|
|
191
204
|
verified = true;
|
|
192
205
|
} else {
|
|
193
|
-
const proofVerified = this.proof.verify(this.substitutions, this.consequent,
|
|
206
|
+
const proofVerified = this.proof.verify(this.substitutions, this.consequent, context);
|
|
194
207
|
|
|
195
208
|
verified = proofVerified; ///
|
|
196
209
|
}
|
package/src/unifier/equality.js
CHANGED
|
@@ -8,12 +8,12 @@ import { findEquivalenceByTermNodes } from "../utilities/equivalences";
|
|
|
8
8
|
const termNodeQuery = nodeQuery("/term");
|
|
9
9
|
|
|
10
10
|
class EqualityUnifier extends Unifier {
|
|
11
|
-
unify(leftTermNode, rightTermNode,
|
|
11
|
+
unify(leftTermNode, rightTermNode, context) {
|
|
12
12
|
let equalityUnified;
|
|
13
13
|
|
|
14
14
|
const nonTerminalNodeA = leftTermNode, ///
|
|
15
15
|
nonTerminalNodeB = rightTermNode, ///
|
|
16
|
-
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB,
|
|
16
|
+
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context);
|
|
17
17
|
|
|
18
18
|
equalityUnified = nonTerminalNodeUnified; ///
|
|
19
19
|
|
|
@@ -22,9 +22,9 @@ class EqualityUnifier extends Unifier {
|
|
|
22
22
|
|
|
23
23
|
static maps = [
|
|
24
24
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
unify: (termNodeA, termNodeB,
|
|
25
|
+
generalNodeQuery: termNodeQuery,
|
|
26
|
+
specificNodeQuery: termNodeQuery,
|
|
27
|
+
unify: (termNodeA, termNodeB, context) => {
|
|
28
28
|
let termUnifiedWithTerm;
|
|
29
29
|
|
|
30
30
|
const leftTermNode = termNodeA, ///
|
|
@@ -34,7 +34,7 @@ class EqualityUnifier extends Unifier {
|
|
|
34
34
|
if (leftTermNodeMatchesRightTermNode) {
|
|
35
35
|
termUnifiedWithTerm = true;
|
|
36
36
|
} else {
|
|
37
|
-
const equivalences =
|
|
37
|
+
const equivalences = context.getEquivalences(),
|
|
38
38
|
termNodes = [
|
|
39
39
|
leftTermNode,
|
|
40
40
|
rightTermNode
|
|
@@ -51,7 +51,7 @@ class EqualityUnifier extends Unifier {
|
|
|
51
51
|
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
52
52
|
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
53
53
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
54
|
-
childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB,
|
|
54
|
+
childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB, context);
|
|
55
55
|
|
|
56
56
|
termUnifiedWithTerm = childNodesVerified; ///
|
|
57
57
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import shim from "../shim";
|
|
4
|
+
import Unifier from "../unifier";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { variableNameFromVariableNode } from "../utilities/name";
|
|
8
|
+
|
|
9
|
+
const termNodeQuery = nodeQuery("/term"),
|
|
10
|
+
termVariableNodeQuery = nodeQuery("/term/variable!");
|
|
11
|
+
|
|
12
|
+
class IntrinsicLevelUnifier extends Unifier {
|
|
13
|
+
unify(generalNode, specificNode, substitutions, generalContext, specificContext) {
|
|
14
|
+
let unifiedAtMetaLevel;
|
|
15
|
+
|
|
16
|
+
const generalNonTerminalNode = generalNode, ///
|
|
17
|
+
specificNonTerminalNode = specificNode, ///
|
|
18
|
+
nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
19
|
+
|
|
20
|
+
unifiedAtMetaLevel = nonTerminalNodeUnified; ///
|
|
21
|
+
|
|
22
|
+
return unifiedAtMetaLevel;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static maps = [
|
|
26
|
+
{
|
|
27
|
+
generalNodeQuery: termVariableNodeQuery,
|
|
28
|
+
specificNodeQuery: termNodeQuery,
|
|
29
|
+
unify: (generalVermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
|
|
30
|
+
let termUnified = false;
|
|
31
|
+
|
|
32
|
+
const variableNode = generalVermVariableNode, ///
|
|
33
|
+
variableName = variableNameFromVariableNode(variableNode),
|
|
34
|
+
variablePresent = generalContext.isVariablePresentByVariableName(variableName);
|
|
35
|
+
|
|
36
|
+
if (variablePresent) {
|
|
37
|
+
let context;
|
|
38
|
+
|
|
39
|
+
const { Term, Variable } = shim,
|
|
40
|
+
termNode = specificTermNode; ///
|
|
41
|
+
|
|
42
|
+
context = generalContext; ///
|
|
43
|
+
|
|
44
|
+
const variable = Variable.fromVariableNode(variableNode, context);
|
|
45
|
+
|
|
46
|
+
context = specificContext; ///
|
|
47
|
+
|
|
48
|
+
const term = Term.fromTermNode(termNode, context);
|
|
49
|
+
|
|
50
|
+
termUnified = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return termUnified;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const intrinsicLevelUnifier = new IntrinsicLevelUnifier();
|
|
60
|
+
|
|
61
|
+
export default intrinsicLevelUnifier;
|