occam-verify-cli 1.0.220 → 1.0.224
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/context/file.js +19 -19
- package/lib/context/local.js +5 -43
- package/lib/context/release.js +11 -11
- package/lib/dom/assertion/contained.js +44 -44
- package/lib/dom/assertion/defined.js +40 -40
- package/lib/dom/assertion/property.js +37 -35
- package/lib/dom/assertion/satisfies.js +26 -25
- package/lib/dom/assertion/subproof.js +16 -16
- package/lib/dom/assertion/type.js +34 -32
- package/lib/dom/axiom.js +52 -52
- package/lib/dom/combinator/bracketed.js +5 -5
- package/lib/dom/combinator.js +6 -6
- package/lib/dom/conclusion.js +10 -10
- package/lib/dom/conjecture.js +5 -5
- package/lib/dom/constructor/bracketed.js +12 -12
- package/lib/dom/constructor.js +9 -9
- package/lib/dom/declaration/combinator.js +11 -11
- package/lib/dom/declaration/complexType.js +133 -63
- package/lib/dom/declaration/constructor.js +17 -17
- package/lib/dom/declaration/metavariable.js +17 -17
- package/lib/dom/declaration/simpleType.js +229 -0
- package/lib/dom/declaration/variable.js +17 -17
- package/lib/dom/declaration.js +54 -52
- package/lib/dom/deduction.js +15 -15
- package/lib/dom/derivation.js +8 -8
- package/lib/dom/equality.js +49 -34
- package/lib/dom/error.js +3 -3
- package/lib/dom/frame.js +38 -38
- package/lib/dom/judgement.js +31 -29
- package/lib/dom/label.js +5 -5
- package/lib/dom/lemma.js +5 -5
- package/lib/dom/metaLemma.js +5 -5
- package/lib/dom/metatheorem.js +5 -5
- package/lib/dom/metavariable.js +55 -55
- package/lib/dom/premise.js +36 -34
- package/lib/dom/procedureCall.js +9 -9
- package/lib/dom/proof.js +6 -6
- package/lib/dom/propertyRelation.js +18 -18
- package/lib/dom/reference.js +28 -28
- package/lib/dom/rule.js +63 -48
- package/lib/dom/signature.js +17 -17
- package/lib/dom/statement.js +36 -36
- package/lib/dom/step.js +32 -35
- package/lib/dom/subDerivation.js +8 -8
- package/lib/dom/subproof.js +27 -30
- package/lib/dom/substitution/statement.js +7 -7
- package/lib/dom/substitution/term.js +2 -16
- package/lib/dom/substitution.js +1 -15
- package/lib/dom/supposition.js +39 -39
- package/lib/dom/term.js +15 -15
- package/lib/dom/theorem.js +5 -5
- package/lib/dom/topLevelAssertion.js +60 -71
- package/lib/dom/topLevelMetaAssertion.js +28 -20
- package/lib/dom/type.js +18 -24
- package/lib/dom/variable.js +16 -16
- package/lib/equivalence.js +54 -33
- package/lib/equivalences.js +57 -101
- package/lib/index.js +2 -2
- package/lib/mixins/statement/verify.js +52 -52
- package/lib/mixins/step/unify.js +79 -61
- package/lib/mixins/term/verify.js +17 -17
- package/lib/substitutions.js +7 -7
- package/lib/unifier/equantional.js +170 -0
- package/lib/unifier/intrinsicLevel.js +8 -8
- package/lib/unifier/metaLevel.js +21 -21
- package/lib/unifier/metavariable.js +9 -9
- package/lib/unifier/statementWithCombinator.js +18 -18
- package/lib/unifier/termWithConstructor.js +10 -10
- package/lib/unifier.js +41 -41
- package/lib/utilities/brackets.js +2 -2
- package/lib/utilities/release.js +18 -17
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/type.js +2 -2
- package/lib/utilities/unification.js +28 -34
- package/lib/verifier/combinator.js +14 -14
- package/lib/verifier/constructor.js +18 -18
- package/lib/verifier/topLevel.js +38 -38
- package/lib/verifier.js +30 -30
- package/package.json +1 -1
- package/src/context/file.js +18 -18
- package/src/context/local.js +5 -48
- package/src/context/release.js +11 -11
- package/src/dom/assertion/contained.js +46 -46
- package/src/dom/assertion/defined.js +41 -41
- package/src/dom/assertion/property.js +37 -35
- package/src/dom/assertion/satisfies.js +26 -25
- package/src/dom/assertion/subproof.js +15 -15
- package/src/dom/assertion/type.js +34 -32
- package/src/dom/axiom.js +56 -54
- package/src/dom/combinator/bracketed.js +4 -4
- package/src/dom/combinator.js +5 -5
- package/src/dom/conclusion.js +9 -9
- package/src/dom/conjecture.js +4 -4
- package/src/dom/constructor/bracketed.js +11 -11
- package/src/dom/constructor.js +8 -8
- package/src/dom/declaration/combinator.js +10 -10
- package/src/dom/declaration/complexType.js +129 -64
- package/src/dom/declaration/constructor.js +16 -16
- package/src/dom/declaration/metavariable.js +16 -16
- package/src/dom/declaration/simpleType.js +179 -0
- package/src/dom/declaration/variable.js +16 -16
- package/src/dom/declaration.js +54 -52
- package/src/dom/deduction.js +14 -14
- package/src/dom/derivation.js +7 -7
- package/src/dom/equality.js +55 -38
- package/src/dom/error.js +2 -2
- package/src/dom/frame.js +38 -38
- package/src/dom/judgement.js +31 -29
- package/src/dom/label.js +4 -4
- package/src/dom/lemma.js +4 -4
- package/src/dom/metaLemma.js +4 -4
- package/src/dom/metatheorem.js +4 -4
- package/src/dom/metavariable.js +54 -54
- package/src/dom/premise.js +35 -33
- package/src/dom/procedureCall.js +8 -8
- package/src/dom/proof.js +5 -5
- package/src/dom/propertyRelation.js +17 -17
- package/src/dom/reference.js +27 -27
- package/src/dom/rule.js +72 -49
- package/src/dom/signature.js +15 -15
- package/src/dom/statement.js +34 -34
- package/src/dom/step.js +42 -48
- package/src/dom/subDerivation.js +7 -7
- package/src/dom/subproof.js +30 -40
- package/src/dom/substitution/statement.js +6 -6
- package/src/dom/substitution/term.js +1 -19
- package/src/dom/substitution.js +0 -13
- package/src/dom/supposition.js +38 -38
- package/src/dom/term.js +14 -14
- package/src/dom/theorem.js +4 -4
- package/src/dom/topLevelAssertion.js +62 -81
- package/src/dom/topLevelMetaAssertion.js +35 -20
- package/src/dom/type.js +23 -33
- package/src/dom/variable.js +16 -15
- package/src/equivalence.js +69 -46
- package/src/equivalences.js +53 -115
- package/src/index.js +1 -1
- package/src/mixins/statement/verify.js +51 -51
- package/src/mixins/step/unify.js +88 -67
- package/src/mixins/term/verify.js +16 -16
- package/src/substitutions.js +5 -6
- package/src/unifier/equantional.js +90 -0
- package/src/unifier/intrinsicLevel.js +7 -7
- package/src/unifier/metaLevel.js +20 -21
- package/src/unifier/metavariable.js +8 -8
- package/src/unifier/statementWithCombinator.js +17 -17
- package/src/unifier/termWithConstructor.js +9 -9
- package/src/unifier.js +40 -40
- package/src/utilities/brackets.js +1 -1
- package/src/utilities/release.js +18 -18
- package/src/utilities/subproof.js +1 -1
- package/src/utilities/type.js +1 -1
- package/src/utilities/unification.js +27 -37
- package/src/verifier/combinator.js +13 -13
- package/src/verifier/constructor.js +17 -17
- package/src/verifier/topLevel.js +41 -41
- package/src/verifier.js +29 -29
- package/lib/dom/declaration/type.js +0 -209
- package/lib/unifier/equality.js +0 -155
- package/src/dom/declaration/type.js +0 -150
- package/src/unifier/equality.js +0 -70
package/src/mixins/step/unify.js
CHANGED
|
@@ -14,7 +14,7 @@ import { equalityFromStatement,
|
|
|
14
14
|
const { backwardsSome } = arrayUtilities;
|
|
15
15
|
|
|
16
16
|
function unifyWithRule(statement, reference, substitutions, context) {
|
|
17
|
-
let
|
|
17
|
+
let unifiesWithRule = false;
|
|
18
18
|
|
|
19
19
|
if (reference !== null) {
|
|
20
20
|
const rule = context.findRuleByReference(reference);
|
|
@@ -26,26 +26,28 @@ function unifyWithRule(statement, reference, substitutions, context) {
|
|
|
26
26
|
context.trace(`Unifying the '${statementString}' statement with the '${ruleString}' rule...`);
|
|
27
27
|
|
|
28
28
|
const stepsOrSubproofs = context.getStepsOrSubproofs(),
|
|
29
|
-
|
|
29
|
+
statementAndStepsUnify = rule.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
if (statementAndStepsUnify) {
|
|
32
|
+
unifiesWithRule = true;
|
|
33
|
+
}
|
|
32
34
|
|
|
33
|
-
if (
|
|
35
|
+
if (unifiesWithRule) {
|
|
34
36
|
context.debug(`...unified the '${statementString}' statement with the '${ruleString}' rule.`);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
return
|
|
41
|
+
return unifiesWithRule;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
function unifyWithReference(statement, reference, substitutions, context) {
|
|
43
|
-
let
|
|
45
|
+
let unifiesWithReference = false;
|
|
44
46
|
|
|
45
47
|
if (reference !== null) {
|
|
46
|
-
const
|
|
48
|
+
const metavariableVerifies = reference.verifyMetavariable(context);
|
|
47
49
|
|
|
48
|
-
if (
|
|
50
|
+
if (metavariableVerifies) {
|
|
49
51
|
const statementString = statement.getString(),
|
|
50
52
|
referenceString = reference.getString();
|
|
51
53
|
|
|
@@ -59,19 +61,19 @@ function unifyWithReference(statement, reference, substitutions, context) {
|
|
|
59
61
|
|
|
60
62
|
substitutions.addSubstitution(substitution, specificContext);
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
unifiesWithReference = true;
|
|
63
65
|
|
|
64
|
-
if (
|
|
66
|
+
if (unifiesWithReference) {
|
|
65
67
|
context.debug(`...unified the '${statementString}' statement with the '${referenceString}' reference.`);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
return
|
|
72
|
+
return unifiesWithReference;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
function unifyAsSatisfiesAssertion(statement, reference, substitutions, context) {
|
|
74
|
-
let
|
|
76
|
+
let unifiesAsSatisfiesAssertion = false;
|
|
75
77
|
|
|
76
78
|
const satisfiesAssertion = satisfiesAssertionFromStatement(statement, context);
|
|
77
79
|
|
|
@@ -88,10 +90,10 @@ function unifyAsSatisfiesAssertion(statement, reference, substitutions, context)
|
|
|
88
90
|
if (reference === null) {
|
|
89
91
|
const stepsOrSubproofs = context.getStepsOrSubproofs();
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
+
unifiesAsSatisfiesAssertion = backwardsSome(stepsOrSubproofs, (stepsOrSubproof) => {
|
|
94
|
+
const satisfiedAssertionUnifies = stepsOrSubproof.unifySatisfiesAssertion(satisfiesAssertion, context);
|
|
93
95
|
|
|
94
|
-
if (
|
|
96
|
+
if (satisfiedAssertionUnifies) {
|
|
95
97
|
return true;
|
|
96
98
|
}
|
|
97
99
|
});
|
|
@@ -105,27 +107,29 @@ function unifyAsSatisfiesAssertion(statement, reference, substitutions, context)
|
|
|
105
107
|
|
|
106
108
|
if (axiom !== null) {
|
|
107
109
|
const substitutions = Substitutions.fromNothing(),
|
|
108
|
-
|
|
110
|
+
axiomLemmaTheoremConjectureUnifies = axiom.unifyAxiomLemmaTheoremConjecture(axiomLemmaTheoremConjecture, substitutions, context);
|
|
109
111
|
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
+
if (axiomLemmaTheoremConjectureUnifies) {
|
|
113
|
+
const substitutionsCorrelates = satisfiesAssertion.correlateSubstitutions(substitutions, context);
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
if (substitutionsCorrelates) {
|
|
116
|
+
unifiesAsSatisfiesAssertion = true;
|
|
117
|
+
}
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
if (
|
|
123
|
+
if (unifiesAsSatisfiesAssertion) {
|
|
120
124
|
context.debug(`...unified the '${statementString}' statement as a satisfies assertion.`);
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
return
|
|
128
|
+
return unifiesAsSatisfiesAssertion;
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
function unifyWithAxiomLemmaTheoremOrConjecture(statement, reference, substitutions, context) {
|
|
128
|
-
let
|
|
132
|
+
let unifiesWithAxiomLemmaTheoremOrConjecture = false;
|
|
129
133
|
|
|
130
134
|
if (reference !== null) {
|
|
131
135
|
const axiomLemmaTheoremConjecture = context.findAxiomLemmaTheoremConjectureByReference(reference),
|
|
@@ -141,9 +145,9 @@ function unifyWithAxiomLemmaTheoremOrConjecture(statement, reference, substituti
|
|
|
141
145
|
|
|
142
146
|
substitutions = Substitutions.fromNothing();
|
|
143
147
|
|
|
144
|
-
const
|
|
148
|
+
const statementAndStepsUnify = axiomLemmaTheoremConjecture.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context);
|
|
145
149
|
|
|
146
|
-
if (
|
|
150
|
+
if (statementAndStepsUnify) {
|
|
147
151
|
const { StatementSubstitution } = dom,
|
|
148
152
|
metavariable = reference.getMetavariable(),
|
|
149
153
|
specificContext = context, ///
|
|
@@ -154,20 +158,20 @@ function unifyWithAxiomLemmaTheoremOrConjecture(statement, reference, substituti
|
|
|
154
158
|
|
|
155
159
|
substitutions.addSubstitution(substitution, specificContext);
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
unifiesWithAxiomLemmaTheoremOrConjecture = true;
|
|
158
162
|
}
|
|
159
163
|
|
|
160
|
-
if (
|
|
164
|
+
if (unifiesWithAxiomLemmaTheoremOrConjecture) {
|
|
161
165
|
context.debug(`...unified the '${statementString}' statement with the '${axiomLemmaTheoremConjectureString}' axiom, lemma, theorem or conjecture.`);
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
|
|
166
|
-
return
|
|
170
|
+
return unifiesWithAxiomLemmaTheoremOrConjecture;
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
function
|
|
170
|
-
let
|
|
173
|
+
function unifyAEquality(statement, reference, substitutions, context) {
|
|
174
|
+
let unifiesAEquality = false;
|
|
171
175
|
|
|
172
176
|
if (reference === null) {
|
|
173
177
|
const equality = equalityFromStatement(statement, context);
|
|
@@ -177,17 +181,23 @@ function unifyAsEquality(statement, reference, substitutions, context) {
|
|
|
177
181
|
|
|
178
182
|
context.trace(`Unifying the '${statementString}' statement as an equality...`);
|
|
179
183
|
|
|
180
|
-
|
|
184
|
+
const equalityEqual = equality.isEqual(context);
|
|
185
|
+
|
|
186
|
+
if (equalityEqual) {
|
|
187
|
+
unifiesAEquality = true;
|
|
188
|
+
}
|
|
181
189
|
|
|
182
|
-
|
|
190
|
+
if (unifiesAEquality) {
|
|
191
|
+
context.debug(`...unified the '${statementString}' statement as an equality.`);
|
|
192
|
+
}
|
|
183
193
|
}
|
|
184
194
|
}
|
|
185
195
|
|
|
186
|
-
return
|
|
196
|
+
return unifiesAEquality;
|
|
187
197
|
}
|
|
188
198
|
|
|
189
199
|
function unifyAsJudgement(statement, reference, substitutions, context) {
|
|
190
|
-
let
|
|
200
|
+
let unifiesAsJudgement = false;
|
|
191
201
|
|
|
192
202
|
if (reference === null) {
|
|
193
203
|
const judgement = judgementFromStatement(statement, context);
|
|
@@ -197,17 +207,19 @@ function unifyAsJudgement(statement, reference, substitutions, context) {
|
|
|
197
207
|
|
|
198
208
|
context.trace(`Unifying the '${statementString}' statement as a judgement...`);
|
|
199
209
|
|
|
200
|
-
|
|
210
|
+
unifiesAsJudgement = true;
|
|
201
211
|
|
|
202
|
-
|
|
212
|
+
if (unifiesAsJudgement) {
|
|
213
|
+
context.debug(`...unified the '${statementString}' statement as a judgement.`);
|
|
214
|
+
}
|
|
203
215
|
}
|
|
204
216
|
}
|
|
205
217
|
|
|
206
|
-
return
|
|
218
|
+
return unifiesAsJudgement;
|
|
207
219
|
}
|
|
208
220
|
|
|
209
221
|
function unifyAsTypeAssertion(statement, reference, substitutions, context) {
|
|
210
|
-
let
|
|
222
|
+
let unifiesAsTypeAssertion = false;
|
|
211
223
|
|
|
212
224
|
if (reference === null) {
|
|
213
225
|
const typeAssertion = typeAssertionFromStatement(statement, context);
|
|
@@ -217,17 +229,17 @@ function unifyAsTypeAssertion(statement, reference, substitutions, context) {
|
|
|
217
229
|
|
|
218
230
|
context.trace(`Unifying the '${statementString}' statement as a type assertion...`);
|
|
219
231
|
|
|
220
|
-
|
|
232
|
+
unifiesAsTypeAssertion = true;
|
|
221
233
|
|
|
222
234
|
context.debug(`...unified the '${statementString}' statement as a type assertion.`);
|
|
223
235
|
}
|
|
224
236
|
}
|
|
225
237
|
|
|
226
|
-
return
|
|
238
|
+
return unifiesAsTypeAssertion;
|
|
227
239
|
}
|
|
228
240
|
|
|
229
241
|
function unifyAsPropertyAssertion(statement, reference, substitutions, context) {
|
|
230
|
-
let
|
|
242
|
+
let unifiesAsPropertyAssertion = false;
|
|
231
243
|
|
|
232
244
|
if (reference === null) {
|
|
233
245
|
const propertyAssertion = propertyAssertionFromStatement(statement, context);
|
|
@@ -241,7 +253,7 @@ function unifyAsPropertyAssertion(statement, reference, substitutions, context)
|
|
|
241
253
|
equivalence = context.findEquivalenceByTerm(term);
|
|
242
254
|
|
|
243
255
|
if (equivalence !== null) {
|
|
244
|
-
|
|
256
|
+
const propertyAssertionMatches = equivalence.someOtherTerm(term, (term) => { ///
|
|
245
257
|
const propertyRelation = propertyAssertion.getPropertyRelation(),
|
|
246
258
|
propertyAssertionMatches = context.matchTermAndPropertyRelation(term, propertyRelation);
|
|
247
259
|
|
|
@@ -249,32 +261,23 @@ function unifyAsPropertyAssertion(statement, reference, substitutions, context)
|
|
|
249
261
|
return true;
|
|
250
262
|
}
|
|
251
263
|
});
|
|
264
|
+
|
|
265
|
+
if (propertyAssertionMatches) {
|
|
266
|
+
unifiesAsPropertyAssertion = true;
|
|
267
|
+
}
|
|
252
268
|
}
|
|
253
269
|
|
|
254
|
-
if (
|
|
270
|
+
if (unifiesAsPropertyAssertion) {
|
|
255
271
|
context.debug(`...unified the '${statementString}' statement as a property assertion.`);
|
|
256
272
|
}
|
|
257
273
|
}
|
|
258
274
|
}
|
|
259
275
|
|
|
260
|
-
return
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function unifyWithStepsOrSubproofs(statement, reference, substitutions, context) {
|
|
264
|
-
let unifiedWithStepOrSubproofs = false;
|
|
265
|
-
|
|
266
|
-
if (reference === null) {
|
|
267
|
-
const stepsOrSubproofs = context.getStepsOrSubproofs(),
|
|
268
|
-
statementUnifiedWithSteps = statement.unifyWithStepsOrSubproofs(stepsOrSubproofs, context);
|
|
269
|
-
|
|
270
|
-
unifiedWithStepOrSubproofs = statementUnifiedWithSteps; ///
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return unifiedWithStepOrSubproofs;
|
|
276
|
+
return unifiesAsPropertyAssertion;
|
|
274
277
|
}
|
|
275
278
|
|
|
276
279
|
function unifyWithSatisfiesAssertion(statement, reference, substitutions, context) {
|
|
277
|
-
let
|
|
280
|
+
let unifiesWithSatisfiesAssertion = false;
|
|
278
281
|
|
|
279
282
|
const stepsOrSubproofs = context.getStepsOrSubproofs(),
|
|
280
283
|
satisfiesAssertions = stepsOrSubproofs.reduce((satisfiesAssertions, stepOrSubproof) => {
|
|
@@ -293,17 +296,35 @@ function unifyWithSatisfiesAssertion(statement, reference, substitutions, contex
|
|
|
293
296
|
}
|
|
294
297
|
|
|
295
298
|
return satisfiesAssertions;
|
|
296
|
-
}, [])
|
|
299
|
+
}, []),
|
|
300
|
+
statementUnifies = backwardsSome(satisfiesAssertions, (satisfiesAssertion) => {
|
|
301
|
+
const statementUnifies = satisfiesAssertion.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context);
|
|
302
|
+
|
|
303
|
+
if (statementUnifies) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
if (statementUnifies) {
|
|
309
|
+
unifiesWithSatisfiesAssertion = true;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return unifiesWithSatisfiesAssertion;
|
|
313
|
+
}
|
|
297
314
|
|
|
298
|
-
|
|
299
|
-
|
|
315
|
+
function equateWithStepsOrSubproofs(statement, reference, substitutions, context) {
|
|
316
|
+
let unifiesWithStepOrSubproofs = false;
|
|
300
317
|
|
|
301
|
-
|
|
302
|
-
|
|
318
|
+
if (reference === null) {
|
|
319
|
+
const stepsOrSubproofs = context.getStepsOrSubproofs(),
|
|
320
|
+
statementUnifiesWithSteps = statement.equateWithStepsOrSubproofs(stepsOrSubproofs, context);
|
|
321
|
+
|
|
322
|
+
if (statementUnifiesWithSteps) {
|
|
323
|
+
unifiesWithStepOrSubproofs = true;
|
|
303
324
|
}
|
|
304
|
-
}
|
|
325
|
+
}
|
|
305
326
|
|
|
306
|
-
return
|
|
327
|
+
return unifiesWithStepOrSubproofs;
|
|
307
328
|
}
|
|
308
329
|
|
|
309
330
|
const unifyMixins = [
|
|
@@ -311,12 +332,12 @@ const unifyMixins = [
|
|
|
311
332
|
unifyWithReference,
|
|
312
333
|
unifyAsSatisfiesAssertion,
|
|
313
334
|
unifyWithAxiomLemmaTheoremOrConjecture,
|
|
314
|
-
|
|
335
|
+
unifyAEquality,
|
|
315
336
|
unifyAsJudgement,
|
|
316
337
|
unifyAsTypeAssertion,
|
|
317
338
|
unifyAsPropertyAssertion,
|
|
318
|
-
|
|
319
|
-
|
|
339
|
+
unifyWithSatisfiesAssertion,
|
|
340
|
+
equateWithStepsOrSubproofs
|
|
320
341
|
];
|
|
321
342
|
|
|
322
343
|
export default unifyMixins;
|
|
@@ -3,34 +3,34 @@
|
|
|
3
3
|
import dom from "../../dom";
|
|
4
4
|
|
|
5
5
|
function unifyWithBracketedConstructor(term, context, verifyAhead) {
|
|
6
|
-
let
|
|
6
|
+
let unifiesWithBracketedConstructor;
|
|
7
7
|
|
|
8
8
|
const { BracketedConstructor } = dom,
|
|
9
9
|
bracketedConstructor = BracketedConstructor.fromNothing();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
unifiesWithBracketedConstructor = bracketedConstructor.unifyTerm(term, context, verifyAhead);
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return unifiesWithBracketedConstructor;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function unifyWithConstructors(term, context, verifyAhead) {
|
|
17
|
-
let
|
|
17
|
+
let unifiesWithConstructors;
|
|
18
18
|
|
|
19
19
|
const constructors = context.getConstructors();
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const
|
|
21
|
+
unifiesWithConstructors = constructors.some((constructor) => {
|
|
22
|
+
const unifiesWithConstructor = constructor.unifyTerm(term, context, verifyAhead);
|
|
23
23
|
|
|
24
|
-
if (
|
|
24
|
+
if (unifiesWithConstructor) {
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return unifiesWithConstructors;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function verifyTermAsVariable(term, localContext, verifyAhead) {
|
|
33
|
-
let
|
|
33
|
+
let termVerifiesAsVariable = false;
|
|
34
34
|
|
|
35
35
|
const { Variable } = dom,
|
|
36
36
|
context = localContext, ///
|
|
@@ -44,10 +44,10 @@ function verifyTermAsVariable(term, localContext, verifyAhead) {
|
|
|
44
44
|
|
|
45
45
|
localContext.trace(`Verifying the '${termString}' term as a variable...`);
|
|
46
46
|
|
|
47
|
-
const
|
|
47
|
+
const variableVerifies = variable.verify(localContext);
|
|
48
48
|
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
49
|
+
if (variableVerifies) {
|
|
50
|
+
let verifiesAhead;
|
|
51
51
|
|
|
52
52
|
const variableName = variable.getName();
|
|
53
53
|
|
|
@@ -57,17 +57,17 @@ function verifyTermAsVariable(term, localContext, verifyAhead) {
|
|
|
57
57
|
|
|
58
58
|
term.setType(type);
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
verifiesAhead = verifyAhead();
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
termVerifiesAsVariable = verifiesAhead; ///
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
if (
|
|
65
|
+
if (termVerifiesAsVariable) {
|
|
66
66
|
localContext.debug(`...verified the '${termString}' term as a variable.`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
return
|
|
70
|
+
return termVerifiesAsVariable;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const verifyMixins = [
|
package/src/substitutions.js
CHANGED
|
@@ -200,20 +200,19 @@ export default class Substitutions {
|
|
|
200
200
|
specificContext.trace(`Removed the ${substitutionString} substitution.`);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
correlateSubstitutions(substitutions) {
|
|
204
204
|
const array = substitutions.getArray(),
|
|
205
205
|
arrayA = array, ///
|
|
206
206
|
arrayB = this.array, ///
|
|
207
207
|
correlates = correlate(arrayA, arrayB, (substitutionA, substitutionB) => {
|
|
208
|
-
const
|
|
208
|
+
const substitutionAIsEQualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
209
209
|
|
|
210
|
-
if (
|
|
210
|
+
if (substitutionAIsEQualToSubstitutionB) {
|
|
211
211
|
return true;
|
|
212
212
|
}
|
|
213
|
-
})
|
|
214
|
-
match = correlates; ///
|
|
213
|
+
});
|
|
215
214
|
|
|
216
|
-
return
|
|
215
|
+
return correlates;
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
removeTrivialSubstitutions() {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Unifier from "../unifier";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "../utilities/query";
|
|
6
|
+
|
|
7
|
+
const termNodeQuery = nodeQuery("/term");
|
|
8
|
+
|
|
9
|
+
class EquationalUnifier extends Unifier {
|
|
10
|
+
equateTerms(leftTermNode, rightTermNode, context) {
|
|
11
|
+
let termsEquate;
|
|
12
|
+
|
|
13
|
+
const generalNonTerminalNode = leftTermNode, ///
|
|
14
|
+
specificNonTerminalNode = rightTermNode, ///
|
|
15
|
+
nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, context);
|
|
16
|
+
|
|
17
|
+
termsEquate = nonTerminalNodeUnifies; ///
|
|
18
|
+
|
|
19
|
+
return termsEquate;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
equateStatements(statementANode, statementBNode, context) {
|
|
23
|
+
let statementsEquate;
|
|
24
|
+
|
|
25
|
+
const generalNonTerminalNode = statementANode, ///
|
|
26
|
+
specificNonTerminalNode = statementBNode, ///
|
|
27
|
+
nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, context);
|
|
28
|
+
|
|
29
|
+
statementsEquate = nonTerminalNodeUnifies; ///
|
|
30
|
+
|
|
31
|
+
return statementsEquate;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
static maps = [
|
|
35
|
+
{
|
|
36
|
+
generalNodeQuery: termNodeQuery, ///
|
|
37
|
+
specificNodeQuery: termNodeQuery, ///
|
|
38
|
+
unify: (leftTermNode, rightTermNode, context) => {
|
|
39
|
+
let termUnifies = false;
|
|
40
|
+
|
|
41
|
+
if (!termUnifies) {
|
|
42
|
+
const depth = Infinity,
|
|
43
|
+
leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode, depth);
|
|
44
|
+
|
|
45
|
+
if (leftTermNodeMatchesRightTermNode) {
|
|
46
|
+
termUnifies = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!termUnifies) {
|
|
51
|
+
const equivalences = context.getEquivalences(),
|
|
52
|
+
termNodes = [
|
|
53
|
+
leftTermNode,
|
|
54
|
+
rightTermNode
|
|
55
|
+
],
|
|
56
|
+
equivalence = equivalences.findEquivalenceByTermNodes(termNodes);
|
|
57
|
+
|
|
58
|
+
if (equivalence !== null) {
|
|
59
|
+
termUnifies = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!termUnifies) {
|
|
64
|
+
const depth = 1,
|
|
65
|
+
leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode, depth);
|
|
66
|
+
|
|
67
|
+
if (leftTermNodeMatchesRightTermNode) {
|
|
68
|
+
const leftNonTerminalNode = leftTermNode, ///
|
|
69
|
+
rightNonTerminalNode = rightTermNode, ///
|
|
70
|
+
leftNonTerminalNodeChildNodes = leftNonTerminalNode.getChildNodes(),
|
|
71
|
+
rightNonTerminalNodeChildNodes = rightNonTerminalNode.getChildNodes(),
|
|
72
|
+
leftChildNodes = leftNonTerminalNodeChildNodes, ///
|
|
73
|
+
rightChildNodes = rightNonTerminalNodeChildNodes, ///
|
|
74
|
+
childNodesUnify = equationalUnifier.unifyChildNodes(leftChildNodes, rightChildNodes, context);
|
|
75
|
+
|
|
76
|
+
if (childNodesUnify) {
|
|
77
|
+
termUnifies = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return termUnifies;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const equationalUnifier = new EquationalUnifier();
|
|
89
|
+
|
|
90
|
+
export default equationalUnifier;
|
|
@@ -10,13 +10,13 @@ const termNodeQuery = nodeQuery("/term"),
|
|
|
10
10
|
|
|
11
11
|
class IntrinsicLevelUnifier extends Unifier {
|
|
12
12
|
unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
|
|
13
|
-
let
|
|
13
|
+
let unifiesAtIntrinsicLevel;
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
unifiesAtIntrinsicLevel = nonTerminalNodeUnifies; ///
|
|
18
18
|
|
|
19
|
-
return
|
|
19
|
+
return unifiesAtIntrinsicLevel;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
static maps = [
|
|
@@ -24,7 +24,7 @@ class IntrinsicLevelUnifier extends Unifier {
|
|
|
24
24
|
generalNodeQuery: termVariableNodeQuery,
|
|
25
25
|
specificNodeQuery: termNodeQuery,
|
|
26
26
|
unify: (generalTermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
|
|
27
|
-
let
|
|
27
|
+
let termUnifies;
|
|
28
28
|
|
|
29
29
|
const { Term, Variable } = dom,
|
|
30
30
|
termNode = specificTermNode, ///
|
|
@@ -40,9 +40,9 @@ class IntrinsicLevelUnifier extends Unifier {
|
|
|
40
40
|
|
|
41
41
|
const term = Term.fromTermNode(termNode, context);
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
termUnifies = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
44
44
|
|
|
45
|
-
return
|
|
45
|
+
return termUnifies;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
];
|