occam-verify-cli 1.0.564 → 1.0.570
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/nominal.js +1 -13
- package/lib/context/liminal.js +84 -6
- package/lib/element/assertion/satisfies.js +4 -46
- package/lib/element/assumption.js +49 -69
- package/lib/element/conclusion.js +3 -3
- package/lib/element/frame.js +56 -42
- package/lib/element/judgement.js +2 -2
- package/lib/element/metavariable.js +26 -35
- package/lib/element/proofAssertion/premise.js +26 -29
- package/lib/element/proofAssertion/step.js +4 -44
- package/lib/element/proofAssertion/supposition.js +161 -32
- package/lib/element/proofAssertion.js +5 -5
- package/lib/element/reference.js +9 -2
- package/lib/element/rule.js +21 -55
- package/lib/element/statement.js +5 -5
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +1 -2
- package/lib/element/substitution/reference.js +1 -2
- package/lib/element/substitution/statement.js +3 -46
- package/lib/element/substitution/term.js +1 -2
- package/lib/element/substitution.js +8 -1
- package/lib/element/substitutions.js +1 -53
- package/lib/element/term.js +3 -3
- package/lib/element/topLevelAssertion/axiom.js +25 -15
- package/lib/element/topLevelAssertion/conjecture.js +22 -12
- package/lib/element/topLevelAssertion/lemma.js +27 -12
- package/lib/element/topLevelAssertion/theorem.js +22 -12
- package/lib/element/topLevelAssertion.js +331 -58
- package/lib/element/topLevelMetaAssertion/metaLemma.js +4 -2
- package/lib/element/topLevelMetaAssertion/metatheorem.js +4 -2
- package/lib/element/variable.js +6 -7
- package/lib/node/assumption.js +1 -12
- package/lib/node/frame.js +8 -34
- package/lib/process/assign.js +9 -9
- package/lib/process/instantiate.js +2 -14
- package/lib/process/unify.js +14 -14
- package/lib/process/validate.js +1 -1
- package/lib/utilities/context.js +169 -1
- package/lib/utilities/element.js +18 -7
- package/lib/utilities/unification.js +3 -5
- package/package.json +4 -4
- package/src/context/file/nominal.js +0 -13
- package/src/context/liminal.js +90 -7
- package/src/element/assertion/satisfies.js +2 -5
- package/src/element/assumption.js +62 -86
- package/src/element/conclusion.js +2 -2
- package/src/element/frame.js +72 -45
- package/src/element/judgement.js +2 -1
- package/src/element/metavariable.js +31 -39
- package/src/element/proofAssertion/premise.js +30 -35
- package/src/element/proofAssertion/step.js +4 -4
- package/src/element/proofAssertion/supposition.js +3 -1
- package/src/element/proofAssertion.js +4 -4
- package/src/element/reference.js +13 -3
- package/src/element/rule.js +25 -17
- package/src/element/statement.js +10 -7
- package/src/element/subproof.js +2 -3
- package/src/element/substitution/frame.js +0 -2
- package/src/element/substitution/reference.js +0 -2
- package/src/element/substitution/statement.js +1 -7
- package/src/element/substitution/term.js +0 -2
- package/src/element/substitution.js +11 -0
- package/src/element/substitutions.js +0 -53
- package/src/element/term.js +8 -5
- package/src/element/topLevelAssertion/axiom.js +5 -2
- package/src/element/topLevelAssertion/conjecture.js +5 -2
- package/src/element/topLevelAssertion/lemma.js +6 -3
- package/src/element/topLevelAssertion/theorem.js +5 -2
- package/src/element/topLevelAssertion.js +40 -38
- package/src/element/topLevelMetaAssertion/metaLemma.js +5 -2
- package/src/element/topLevelMetaAssertion/metatheorem.js +5 -2
- package/src/element/variable.js +8 -6
- package/src/node/assumption.js +0 -12
- package/src/node/frame.js +6 -34
- package/src/process/assign.js +16 -16
- package/src/process/instantiate.js +2 -10
- package/src/process/unify.js +14 -14
- package/src/process/validate.js +2 -2
- package/src/utilities/context.js +17 -0
- package/src/utilities/element.js +23 -10
- package/src/utilities/unification.js +3 -7
package/src/element/rule.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
|
-
import elements from "../elements";
|
|
7
|
-
|
|
8
6
|
import { scope } from "../utilities/context";
|
|
9
7
|
import { define } from "../elements";
|
|
10
8
|
import { labelsFromJSON,
|
|
@@ -13,6 +11,7 @@ import { labelsFromJSON,
|
|
|
13
11
|
labelsToLabelsJSON,
|
|
14
12
|
premisesToPremisesJSON,
|
|
15
13
|
conclusionToConclusionJSON } from "../utilities/json";
|
|
14
|
+
import { subproofOrProofAssertionsStringFromSubproofOrProofAssertions } from "../utilities/string";
|
|
16
15
|
|
|
17
16
|
const { reverse, extract, backwardsEvery } = arrayUtilities;
|
|
18
17
|
|
|
@@ -97,8 +96,7 @@ export default define(class Rule extends Element {
|
|
|
97
96
|
if (this.proof === null) {
|
|
98
97
|
proofVerifies = true;
|
|
99
98
|
} else {
|
|
100
|
-
const
|
|
101
|
-
substitutions = Substitutions.fromNothing(context);
|
|
99
|
+
const substitutions = [];
|
|
102
100
|
|
|
103
101
|
proofVerifies = this.proof.verify(substitutions, this.conclusion, context);
|
|
104
102
|
}
|
|
@@ -106,30 +104,38 @@ export default define(class Rule extends Element {
|
|
|
106
104
|
return proofVerifies;
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
unifyStatementWithConclusion(statement,
|
|
107
|
+
unifyStatementWithConclusion(statement, context) {
|
|
110
108
|
let statementUnifiesWithConclusion = false;
|
|
111
109
|
|
|
112
|
-
const
|
|
110
|
+
const ruleString = this.getString(),
|
|
111
|
+
statementString = statement.getString(),
|
|
112
|
+
conclusionString = this.conclusion.getString();
|
|
113
|
+
|
|
114
|
+
context.trace(`Unifying the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion...`);
|
|
115
|
+
|
|
116
|
+
const statementUnifies = this.conclusion.unifyStatement(statement, context);
|
|
113
117
|
|
|
114
118
|
if (statementUnifies) {
|
|
115
119
|
statementUnifiesWithConclusion = true;
|
|
116
120
|
}
|
|
117
121
|
|
|
122
|
+
if (statementUnifiesWithConclusion) {
|
|
123
|
+
context.debug(`...unified the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion.`);
|
|
124
|
+
}
|
|
125
|
+
|
|
118
126
|
return statementUnifiesWithConclusion;
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context) {
|
|
122
130
|
let statementAndSubproofOrProofAssertionsUnify = false;
|
|
123
131
|
|
|
124
|
-
const
|
|
125
|
-
substitutions = Substitutions.fromNothing(context),
|
|
126
|
-
statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, context);
|
|
132
|
+
const statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, context);
|
|
127
133
|
|
|
128
134
|
if (statementUnifiesWithConclusion) {
|
|
129
|
-
const subproofOrProofAssertionsUnifiesWithPremises = this.unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions,
|
|
135
|
+
const subproofOrProofAssertionsUnifiesWithPremises = this.unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, context);
|
|
130
136
|
|
|
131
137
|
if (subproofOrProofAssertionsUnifiesWithPremises) {
|
|
132
|
-
const substitutionsResolved =
|
|
138
|
+
const substitutionsResolved = context.areSubstitutionsResolved();
|
|
133
139
|
|
|
134
140
|
if (substitutionsResolved) {
|
|
135
141
|
statementAndSubproofOrProofAssertionsUnify = true;
|
|
@@ -140,12 +146,12 @@ export default define(class Rule extends Element {
|
|
|
140
146
|
return statementAndSubproofOrProofAssertionsUnify;
|
|
141
147
|
}
|
|
142
148
|
|
|
143
|
-
unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise,
|
|
149
|
+
unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, context) {
|
|
144
150
|
let subproofOrProofAssertionsUnifiesWithPremise = false;
|
|
145
151
|
|
|
146
152
|
if (!subproofOrProofAssertionsUnifiesWithPremise) {
|
|
147
153
|
const subproofOrProofAssertion = extract(subproofOrProofAssertions, (subproofOrProofAssertion) => {
|
|
148
|
-
const subproofOrProofAssertionUnifies = premise.unifySubproofOrProofAssertion(subproofOrProofAssertion,
|
|
154
|
+
const subproofOrProofAssertionUnifies = premise.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
149
155
|
|
|
150
156
|
if (subproofOrProofAssertionUnifies) {
|
|
151
157
|
return true;
|
|
@@ -158,7 +164,7 @@ export default define(class Rule extends Element {
|
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
if (!subproofOrProofAssertionsUnifiesWithPremise) {
|
|
161
|
-
const premiseUnifiesIndependently = premise.unifyIndependently(
|
|
167
|
+
const premiseUnifiesIndependently = premise.unifyIndependently(context);
|
|
162
168
|
|
|
163
169
|
if (premiseUnifiesIndependently) {
|
|
164
170
|
subproofOrProofAssertionsUnifiesWithPremise = true;
|
|
@@ -168,11 +174,13 @@ export default define(class Rule extends Element {
|
|
|
168
174
|
return subproofOrProofAssertionsUnifiesWithPremise;
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions,
|
|
177
|
+
unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, context) {
|
|
178
|
+
let subproofOrProofAssertionsUnifiesWithPremises;
|
|
179
|
+
|
|
172
180
|
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
173
181
|
|
|
174
|
-
|
|
175
|
-
const stepUnifiesWithPremise = this.unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise,
|
|
182
|
+
subproofOrProofAssertionsUnifiesWithPremises = backwardsEvery(this.premises, (premise) => {
|
|
183
|
+
const stepUnifiesWithPremise = this.unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, context);
|
|
176
184
|
|
|
177
185
|
if (stepUnifiesWithPremise) {
|
|
178
186
|
return true;
|
package/src/element/statement.js
CHANGED
|
@@ -17,7 +17,8 @@ export default define(class Statement extends Element {
|
|
|
17
17
|
|
|
18
18
|
isSingular() {
|
|
19
19
|
const node = this.getNode(),
|
|
20
|
-
|
|
20
|
+
statementNode = node, ///
|
|
21
|
+
singular = statementNode.isSingular();
|
|
21
22
|
|
|
22
23
|
return singular;
|
|
23
24
|
}
|
|
@@ -106,10 +107,12 @@ export default define(class Statement extends Element {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
isEqualTo(statement) {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const statementA = this, ///
|
|
111
|
+
statementB = statement, ///
|
|
112
|
+
statementANode = statementA.getNode(),
|
|
113
|
+
statementBNode = statementB.getNode(),
|
|
114
|
+
statementANodeMatchesStatementBNode = statementANode.match(statementBNode),
|
|
115
|
+
equalTo = statementANodeMatchesStatementBNode; ///
|
|
113
116
|
|
|
114
117
|
return equalTo;
|
|
115
118
|
}
|
|
@@ -223,7 +226,7 @@ export default define(class Statement extends Element {
|
|
|
223
226
|
return subproofUnifies;
|
|
224
227
|
}
|
|
225
228
|
|
|
226
|
-
unifyStatement(statement,
|
|
229
|
+
unifyStatement(statement, generalContext, specificContext) {
|
|
227
230
|
let statementUnifies;
|
|
228
231
|
|
|
229
232
|
const context = specificContext, ///
|
|
@@ -234,7 +237,7 @@ export default define(class Statement extends Element {
|
|
|
234
237
|
|
|
235
238
|
context.trace(`Unifying the '${specificStatementString}' statement with the '${generalStatementString}' statement...`);
|
|
236
239
|
|
|
237
|
-
statementUnifies = unifyStatement(generalStatement, specificStatement,
|
|
240
|
+
statementUnifies = unifyStatement(generalStatement, specificStatement, generalContext, specificContext);
|
|
238
241
|
|
|
239
242
|
if (statementUnifies) {
|
|
240
243
|
context.debug(`...unified the '${specificStatementString}' statement with the '${generalStatementString}' statement.`);
|
package/src/element/subproof.js
CHANGED
|
@@ -90,9 +90,8 @@ export default define(class Subproof extends Element {
|
|
|
90
90
|
const axiomSatisfiable = axiom.isSatisfiable();
|
|
91
91
|
|
|
92
92
|
if (axiomSatisfiable) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
substitutions = Substitutions.fromNothing(context),
|
|
93
|
+
const subproof = this, ///
|
|
94
|
+
substitutions = [],
|
|
96
95
|
statementUnifies = axiom.unifySubproof(subproof, substitutions, context);
|
|
97
96
|
|
|
98
97
|
if (statementUnifies) {
|
|
@@ -149,8 +149,6 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
149
149
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context),
|
|
150
150
|
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
151
151
|
|
|
152
|
-
frameSubstitution.validate(context);
|
|
153
|
-
|
|
154
152
|
return frameSubstitution;
|
|
155
153
|
}, context);
|
|
156
154
|
}
|
|
@@ -136,8 +136,6 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
136
136
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
|
|
137
137
|
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
138
138
|
|
|
139
|
-
referenceSubstitution.validate(context);
|
|
140
|
-
|
|
141
139
|
return referenceSubstitution;
|
|
142
140
|
}, context);
|
|
143
141
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import elements from "../../elements";
|
|
4
3
|
import Substitution from "../substitution";
|
|
5
4
|
|
|
6
5
|
import { define } from "../../elements";
|
|
@@ -182,8 +181,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
182
181
|
|
|
183
182
|
context = specificContext; ///
|
|
184
183
|
|
|
185
|
-
const
|
|
186
|
-
substitutions = Substitutions.fromNothing(context);
|
|
184
|
+
const substitutions = [];
|
|
187
185
|
|
|
188
186
|
statementUnifies = this.replacementStatement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
189
187
|
|
|
@@ -294,8 +292,6 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
294
292
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
295
293
|
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
296
294
|
|
|
297
|
-
statementSubstitution.validate(context);
|
|
298
|
-
|
|
299
295
|
return statementSubstitution;
|
|
300
296
|
}, context);
|
|
301
297
|
}
|
|
@@ -309,8 +305,6 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
309
305
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
310
306
|
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, substitution, context);
|
|
311
307
|
|
|
312
|
-
statementSubstitution.validate(context);
|
|
313
|
-
|
|
314
308
|
return statementSubstitution;
|
|
315
309
|
}, context);
|
|
316
310
|
}
|
|
@@ -156,8 +156,6 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
156
156
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
157
157
|
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
158
158
|
|
|
159
|
-
termSubstitution.validate(context);
|
|
160
|
-
|
|
161
159
|
return termSubstitution;
|
|
162
160
|
}, context);
|
|
163
161
|
}
|
|
@@ -50,6 +50,17 @@ export default class Substitution extends Element {
|
|
|
50
50
|
return metavariableEqualToMetavariable;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
isEqualTo(substitution) {
|
|
54
|
+
const substitutionA = this, ///
|
|
55
|
+
substitutionB = substitution, ///
|
|
56
|
+
substitutionANode = substitutionA.getNode(),
|
|
57
|
+
substitutionBNode = substitutionB.getNode(),
|
|
58
|
+
substitutionANodeMatchesSubstitutionBNode = substitutionANode.match(substitutionBNode),
|
|
59
|
+
equalTo = substitutionANodeMatchesSubstitutionBNode; ///
|
|
60
|
+
|
|
61
|
+
return equalTo;
|
|
62
|
+
}
|
|
63
|
+
|
|
53
64
|
compareTerm(term, context) {
|
|
54
65
|
const comparesToTerm = false;
|
|
55
66
|
|
|
@@ -77,8 +77,6 @@ export default define(class Substitutions extends Element {
|
|
|
77
77
|
|
|
78
78
|
mapSubstitution(callback) { return this.array.map(callback); }
|
|
79
79
|
|
|
80
|
-
findSubstitution(callback) { return this.array.find(callback) }
|
|
81
|
-
|
|
82
80
|
someSubstitution(callback) { return this.array.some(callback); }
|
|
83
81
|
|
|
84
82
|
everySubstitution(callback) { return this.array.every(callback); }
|
|
@@ -136,23 +134,6 @@ export default define(class Substitutions extends Element {
|
|
|
136
134
|
return substitutions;
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
findSimpleSubstitutionByMetavariable(metavariable) {
|
|
140
|
-
const simpleSubstitution = this.findSubstitution((substitution) => {
|
|
141
|
-
const substitutionSimple = substitution.isSimple();
|
|
142
|
-
|
|
143
|
-
if (substitutionSimple) {
|
|
144
|
-
const simpleSubstitution = substitution, ///
|
|
145
|
-
simpleSubstitutionMetavariableEqualToMetavariable = simpleSubstitution.isMetavariableEqualToMetavariable(metavariable);
|
|
146
|
-
|
|
147
|
-
if (simpleSubstitutionMetavariableEqualToMetavariable) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}) || null;
|
|
152
|
-
|
|
153
|
-
return simpleSubstitution;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
137
|
findComplexSubstitutionsByMetavariable(metavariable) {
|
|
157
138
|
const complexSubstitutions = this.findSubstitutions((substitution) => {
|
|
158
139
|
const substitutionComplex = substitution.isComplex();
|
|
@@ -170,25 +151,6 @@ export default define(class Substitutions extends Element {
|
|
|
170
151
|
return complexSubstitutions;
|
|
171
152
|
}
|
|
172
153
|
|
|
173
|
-
findSubstitutionByMetavariableAndSubstitution(metavariable, substitution) {
|
|
174
|
-
const substitutionA = substitution; ///
|
|
175
|
-
|
|
176
|
-
substitution = this.findSubstitution((substitution) => { ///
|
|
177
|
-
const substitutionMetavariableEqualToMetavariable = substitution.isMetavariableEqualToMetavariable(metavariable);
|
|
178
|
-
|
|
179
|
-
if (substitutionMetavariableEqualToMetavariable) {
|
|
180
|
-
const substitutionB = substitution, ///
|
|
181
|
-
substitutionBSubstitutionComparesToSubstitutionA = substitutionB.compareSubstitution(substitutionA);
|
|
182
|
-
|
|
183
|
-
if (substitutionBSubstitutionComparesToSubstitutionA) {
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}) || null;
|
|
188
|
-
|
|
189
|
-
return substitution;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
154
|
isSubstitutionPresentByVariable(variable) {
|
|
193
155
|
const substitution = this.findSubstitutionByVariable(variable),
|
|
194
156
|
substitutionPresent = (substitution !== null);
|
|
@@ -196,21 +158,6 @@ export default define(class Substitutions extends Element {
|
|
|
196
158
|
return substitutionPresent;
|
|
197
159
|
}
|
|
198
160
|
|
|
199
|
-
isSimpleSubstitutionPresentByMetavariable(metavariable) {
|
|
200
|
-
const simpleSubstitution = this.findSimpleSubstitutionByMetavariable(metavariable),
|
|
201
|
-
simpleSubstitutionPresent = (simpleSubstitution !== null);
|
|
202
|
-
|
|
203
|
-
return simpleSubstitutionPresent;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
isSubstitutionPresentByMetavariableAndSubstitution(metavariable, substitution) {
|
|
207
|
-
substitution = this.findSubstitutionByMetavariableAndSubstitution(metavariable, substitution); ///
|
|
208
|
-
|
|
209
|
-
const substitutionPresent = (substitution !== null);
|
|
210
|
-
|
|
211
|
-
return substitutionPresent;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
161
|
addSubstitution(substitution, context) {
|
|
215
162
|
const substitutionString = substitution.getString(),
|
|
216
163
|
substitutionsString = this.asString(); ///
|
package/src/element/term.js
CHANGED
|
@@ -26,7 +26,8 @@ export default define(class Term extends Element {
|
|
|
26
26
|
|
|
27
27
|
isSingular() {
|
|
28
28
|
const node = this.getNode(),
|
|
29
|
-
|
|
29
|
+
termNode = node, ///
|
|
30
|
+
singular = termNode.isSingular();
|
|
30
31
|
|
|
31
32
|
return singular;
|
|
32
33
|
}
|
|
@@ -76,10 +77,12 @@ export default define(class Term extends Element {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
isEqualTo(term) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const termA = this, ///
|
|
81
|
+
termB = term, ///
|
|
82
|
+
termANode = termA.getNode(),
|
|
83
|
+
termBNode = termB.getNode(),
|
|
84
|
+
termANodeMatchesTermBNode = termANode.match(termBNode),
|
|
85
|
+
equalTo = termANodeMatchesTermBNode; ///
|
|
83
86
|
|
|
84
87
|
return equalTo;
|
|
85
88
|
}
|
|
@@ -235,8 +235,11 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
235
235
|
async verify() {
|
|
236
236
|
let verifies;
|
|
237
237
|
|
|
238
|
-
const context = this.getContext()
|
|
239
|
-
|
|
238
|
+
const context = this.getContext();
|
|
239
|
+
|
|
240
|
+
await this.break(context);
|
|
241
|
+
|
|
242
|
+
const axiomString = this.getString(); ///
|
|
240
243
|
|
|
241
244
|
context.trace(`Verifying the '${axiomString}' axiom...`);
|
|
242
245
|
|
|
@@ -8,8 +8,11 @@ export default define(class Conjecture extends TopLevelAssertion {
|
|
|
8
8
|
async verify() {
|
|
9
9
|
let verifies;
|
|
10
10
|
|
|
11
|
-
const context = this.getContext()
|
|
12
|
-
|
|
11
|
+
const context = this.getContext();
|
|
12
|
+
|
|
13
|
+
await this.break(context);
|
|
14
|
+
|
|
15
|
+
const conjectureString = this.getString(); ///
|
|
13
16
|
|
|
14
17
|
context.trace(`Verifying the '${conjectureString}' conjecture...`);
|
|
15
18
|
|
|
@@ -8,14 +8,17 @@ export default define(class Lemma extends TopLevelAssertion {
|
|
|
8
8
|
async verify() {
|
|
9
9
|
let verifies;
|
|
10
10
|
|
|
11
|
-
const context = this.getContext()
|
|
12
|
-
|
|
11
|
+
const context = this.getContext();
|
|
12
|
+
|
|
13
|
+
await this.break(context);
|
|
14
|
+
|
|
15
|
+
const lemmaString = this.getString(); ///
|
|
13
16
|
|
|
14
17
|
(lemmaString === null) ?
|
|
15
18
|
context.trace(`Verifying a lemma...`) :
|
|
16
19
|
context.trace(`Verifying the '${lemmaString}' lemma...`);
|
|
17
20
|
|
|
18
|
-
verifies = super.verify();
|
|
21
|
+
verifies = await super.verify();
|
|
19
22
|
|
|
20
23
|
if (verifies) {
|
|
21
24
|
const lemma = this; ///
|
|
@@ -8,8 +8,11 @@ export default define(class Theorem extends TopLevelAssertion {
|
|
|
8
8
|
async verify() {
|
|
9
9
|
let verifies;
|
|
10
10
|
|
|
11
|
-
const context = this.getContext()
|
|
12
|
-
|
|
11
|
+
const context = this.getContext();
|
|
12
|
+
|
|
13
|
+
await this.break(context);
|
|
14
|
+
|
|
15
|
+
const theoremString = this.getString(); ///
|
|
13
16
|
|
|
14
17
|
context.trace(`Verifying the '${theoremString}' theorem...`);
|
|
15
18
|
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
|
+
import { asynchronousUtilities } from "occam-languages";
|
|
5
6
|
|
|
6
|
-
import {
|
|
7
|
+
import { asyncScope, asyncAttempt } from "../utilities/context";
|
|
7
8
|
import { labelsFromJSON,
|
|
8
9
|
deductionFromJSON,
|
|
9
10
|
signatureFromJSON,
|
|
@@ -15,7 +16,8 @@ import { labelsFromJSON,
|
|
|
15
16
|
hypothesesToHypothesesJSON,
|
|
16
17
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
17
18
|
|
|
18
|
-
const {
|
|
19
|
+
const { asyncEvery } = asynchronousUtilities,
|
|
20
|
+
{ extract, reverse, correlate, backwardsEvery } = arrayUtilities;
|
|
19
21
|
|
|
20
22
|
export default class TopLevelAssertion extends Element {
|
|
21
23
|
constructor(context, string, node, labels, suppositions, deduction, proof, signature, hypotheses) {
|
|
@@ -120,22 +122,35 @@ export default class TopLevelAssertion extends Element {
|
|
|
120
122
|
return correlatesToHypotheses;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
verifyLabels() {
|
|
126
|
+
const labelsVerify = this.labels.every((label) => {
|
|
127
|
+
const nameOnly = true,
|
|
128
|
+
labelVerifies = label.verify(nameOnly);
|
|
129
|
+
|
|
130
|
+
if (labelVerifies) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return labelsVerify;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async verify() {
|
|
124
139
|
let verifies = false;
|
|
125
140
|
|
|
126
141
|
const context = this.getContext();
|
|
127
142
|
|
|
128
|
-
|
|
143
|
+
await asyncScope(async (context) => {
|
|
129
144
|
const labelsVerify = this.verifyLabels();
|
|
130
145
|
|
|
131
146
|
if (labelsVerify) {
|
|
132
|
-
const suppositionsVerify = this.verifySuppositions(context);
|
|
147
|
+
const suppositionsVerify = await this.verifySuppositions(context);
|
|
133
148
|
|
|
134
149
|
if (suppositionsVerify) {
|
|
135
|
-
const deductionVerifies = this.verifyDeduction(context);
|
|
150
|
+
const deductionVerifies = await this.verifyDeduction(context);
|
|
136
151
|
|
|
137
152
|
if (deductionVerifies) {
|
|
138
|
-
const proofVerifies = this.verifyProof(context);
|
|
153
|
+
const proofVerifies = await this.verifyProof(context);
|
|
139
154
|
|
|
140
155
|
if (proofVerifies) {
|
|
141
156
|
verifies = true;
|
|
@@ -148,22 +163,9 @@ export default class TopLevelAssertion extends Element {
|
|
|
148
163
|
return verifies;
|
|
149
164
|
}
|
|
150
165
|
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
labelVerifies = label.verify(nameOnly);
|
|
155
|
-
|
|
156
|
-
if (labelVerifies) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
return labelsVerify;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
verifySuppositions(context) {
|
|
165
|
-
const suppositionsVerify = this.suppositions.every((supposition) => {
|
|
166
|
-
const suppositionVerifies = this.verifySupposition(supposition, context);
|
|
166
|
+
async verifySuppositions(context) {
|
|
167
|
+
const suppositionsVerify = await asyncEvery(this.suppositions, async (supposition) => {
|
|
168
|
+
const suppositionVerifies = await this.verifySupposition(supposition, context);
|
|
167
169
|
|
|
168
170
|
if (suppositionVerifies) {
|
|
169
171
|
return true;
|
|
@@ -173,24 +175,24 @@ export default class TopLevelAssertion extends Element {
|
|
|
173
175
|
return suppositionsVerify;
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
verifySupposition(supposition, context) {
|
|
177
|
-
const suppositionVerifies = supposition.verify(context);
|
|
178
|
+
async verifySupposition(supposition, context) {
|
|
179
|
+
const suppositionVerifies = await supposition.verify(context);
|
|
178
180
|
|
|
179
181
|
return suppositionVerifies;
|
|
180
182
|
}
|
|
181
183
|
|
|
182
|
-
verifyDeduction(context) {
|
|
183
|
-
const deductionVerifies = this.deduction.verify(context);
|
|
184
|
+
async verifyDeduction(context) {
|
|
185
|
+
const deductionVerifies = await this.deduction.verify(context);
|
|
184
186
|
|
|
185
187
|
return deductionVerifies;
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
verifyProof(context) {
|
|
190
|
+
async verifyProof(context) {
|
|
189
191
|
let proofVerifies = true; ///
|
|
190
192
|
|
|
191
193
|
if (this.proof !== null) {
|
|
192
|
-
proofVerifies =
|
|
193
|
-
const proofVerifies = this.proof.verify(this.deduction, context);
|
|
194
|
+
proofVerifies = await asyncAttempt(async (context) => {
|
|
195
|
+
const proofVerifies = await this.proof.verify(this.deduction, context);
|
|
194
196
|
|
|
195
197
|
return proofVerifies;
|
|
196
198
|
}, context);
|
|
@@ -211,8 +213,8 @@ export default class TopLevelAssertion extends Element {
|
|
|
211
213
|
return statementUnifiesWithDeduction;
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
let
|
|
216
|
+
unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, substitutions, context) {
|
|
217
|
+
let statementAndSubproofOrProofAssertionsUnify = false;
|
|
216
218
|
|
|
217
219
|
const correlatesToHypotheses = this.correlateHypotheses(context);
|
|
218
220
|
|
|
@@ -220,22 +222,22 @@ export default class TopLevelAssertion extends Element {
|
|
|
220
222
|
const statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, context);
|
|
221
223
|
|
|
222
224
|
if (statementUnifiesWithDeduction) {
|
|
223
|
-
const subproofOrProofAssertionsUnifyWithSuppositions = this.
|
|
225
|
+
const subproofOrProofAssertionsUnifyWithSuppositions = this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, substitutions, context);
|
|
224
226
|
|
|
225
227
|
if (subproofOrProofAssertionsUnifyWithSuppositions) {
|
|
226
228
|
const substitutionsResolved = substitutions.areResolved();
|
|
227
229
|
|
|
228
230
|
if (substitutionsResolved) {
|
|
229
|
-
|
|
231
|
+
statementAndSubproofOrProofAssertionsUnify = true;
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
|
|
235
|
-
return
|
|
237
|
+
return statementAndSubproofOrProofAssertionsUnify;
|
|
236
238
|
}
|
|
237
239
|
|
|
238
|
-
|
|
240
|
+
unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, substitutions, generalContext, specificContext) {
|
|
239
241
|
let subproofOrProofAssertionsUnifiesWithSupposition = false;
|
|
240
242
|
|
|
241
243
|
if (!subproofOrProofAssertionsUnifiesWithSupposition) {
|
|
@@ -264,11 +266,11 @@ export default class TopLevelAssertion extends Element {
|
|
|
264
266
|
return subproofOrProofAssertionsUnifiesWithSupposition;
|
|
265
267
|
}
|
|
266
268
|
|
|
267
|
-
|
|
269
|
+
unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, substitutions, generalContext, specificContext) {
|
|
268
270
|
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
269
271
|
|
|
270
272
|
const subproofOrProofAssertionsUnifyWithSuppositions = backwardsEvery(this.suppositions, (supposition) => {
|
|
271
|
-
const subproofOrProofAssertionsUnifiesWithSupposition = this.
|
|
273
|
+
const subproofOrProofAssertionsUnifiesWithSupposition = this.unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, substitutions, generalContext, specificContext);
|
|
272
274
|
|
|
273
275
|
if (subproofOrProofAssertionsUnifiesWithSupposition) {
|
|
274
276
|
return true;
|
|
@@ -8,8 +8,11 @@ export default define(class MetaLemma extends TopLevelMetaAssertion {
|
|
|
8
8
|
async verify() {
|
|
9
9
|
let verifies;
|
|
10
10
|
|
|
11
|
-
const context = this.getContext()
|
|
12
|
-
|
|
11
|
+
const context = this.getContext();
|
|
12
|
+
|
|
13
|
+
this.break(context);
|
|
14
|
+
|
|
15
|
+
const metaLemmaString = this.getString(); ///
|
|
13
16
|
|
|
14
17
|
context.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
|
|
15
18
|
|
|
@@ -8,8 +8,11 @@ export default define(class Metatheorem extends TopLevelMetaAssertion {
|
|
|
8
8
|
async verify() {
|
|
9
9
|
let verifies;
|
|
10
10
|
|
|
11
|
-
const context = this.getContext()
|
|
12
|
-
|
|
11
|
+
const context = this.getContext();
|
|
12
|
+
|
|
13
|
+
this.break(context);
|
|
14
|
+
|
|
15
|
+
const metaLemmaString = this.getString(); ///
|
|
13
16
|
|
|
14
17
|
context.trace(`Verifying the '${metaLemmaString}' metatheorem...`);
|
|
15
18
|
|
package/src/element/variable.js
CHANGED
|
@@ -116,11 +116,12 @@ export default define(class Variable extends Element {
|
|
|
116
116
|
|
|
117
117
|
context.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
|
|
118
118
|
|
|
119
|
-
let variable
|
|
119
|
+
let variable,
|
|
120
|
+
substitution;
|
|
120
121
|
|
|
121
122
|
variable = this; ///
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
substitution = substitutions.findSubstitutionByVariable(variable);
|
|
124
125
|
|
|
125
126
|
if (substitution !== null) {
|
|
126
127
|
const substitutionComparesToTerm = substitution.compareTerm(term, context);
|
|
@@ -148,11 +149,12 @@ export default define(class Variable extends Element {
|
|
|
148
149
|
termTypeEqualToOrSubTypeOfVariableType = termType.isEqualToOrSubTypeOf(variableType);
|
|
149
150
|
|
|
150
151
|
if (termTypeEqualToOrSubTypeOfVariableType) {
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
const { TermSubstitution } = elements,
|
|
153
|
+
termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, context);
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
substitution = termSubstitution; ///
|
|
156
|
+
|
|
157
|
+
context.addSubstitution(substitution);
|
|
156
158
|
|
|
157
159
|
termUnifies = true;
|
|
158
160
|
}
|