occam-verify-cli 1.0.388 → 1.0.404
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/action/verify.js +3 -3
- package/lib/assignment/equality.js +2 -2
- package/lib/context/file.js +11 -11
- package/lib/context/local.js +38 -61
- package/lib/context/partial.js +10 -10
- package/lib/context/temporary.js +755 -0
- package/lib/mixins/statement/verify.js +38 -16
- package/lib/mixins/step/unify.js +7 -8
- package/lib/node/argument.js +4 -4
- package/lib/node/assertion/contained.js +6 -6
- package/lib/node/assertion/defined.js +6 -6
- package/lib/node/assertion/property.js +6 -6
- package/lib/node/assertion/satisfies.js +6 -6
- package/lib/node/assertion/subproof.js +6 -6
- package/lib/node/assertion/type.js +6 -6
- package/lib/node/assertion.js +107 -0
- package/lib/node/assumption.js +134 -0
- package/lib/node/axiom.js +6 -6
- package/lib/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +12 -12
- package/lib/node/body.js +4 -5
- package/lib/node/combinator.js +4 -4
- package/lib/node/conclusion.js +4 -4
- package/lib/node/conjecture.js +6 -6
- package/lib/node/constructor.js +4 -4
- package/lib/node/declaration/combinator.js +6 -6
- package/lib/node/declaration/complexType.js +6 -6
- package/lib/node/declaration/constructor.js +6 -6
- package/lib/node/declaration/metavariable.js +6 -6
- package/lib/node/declaration/property.js +6 -6
- package/lib/node/declaration/simpleType.js +6 -6
- package/lib/node/declaration/typePrefix.js +6 -6
- package/lib/node/declaration/variable.js +6 -6
- package/lib/node/declaration.js +6 -22
- package/lib/node/deduction.js +4 -4
- package/lib/node/derivation.js +4 -4
- package/lib/node/document.js +107 -0
- package/lib/node/equality.js +4 -4
- package/lib/node/error.js +4 -4
- package/lib/node/frame.js +25 -14
- package/lib/node/header.js +4 -4
- package/lib/node/hypothesis.js +4 -4
- package/lib/node/judgement.js +8 -8
- package/lib/node/label.js +4 -4
- package/lib/node/labels.js +4 -4
- package/lib/node/lemma.js +6 -6
- package/lib/node/metaArgument.js +4 -4
- package/lib/node/metaLemma.js +6 -6
- package/lib/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +12 -12
- package/lib/node/metaType.js +4 -4
- package/lib/node/metatheorem.js +6 -6
- package/lib/node/metavariable.js +4 -4
- package/lib/node/nonsense.js +4 -4
- package/lib/node/parameter.js +4 -4
- package/lib/node/parenthesisedLabel.js +4 -4
- package/lib/node/parenthesisedLabels.js +4 -4
- package/lib/node/placeholder.js +107 -0
- package/lib/node/premise.js +4 -4
- package/lib/node/procedureCall.js +4 -4
- package/lib/node/procedureReference.js +4 -4
- package/lib/node/proof.js +4 -4
- package/lib/node/property.js +4 -4
- package/lib/node/propertyRelation.js +4 -4
- package/lib/node/qualification.js +4 -4
- package/lib/node/reference.js +4 -4
- package/lib/node/rule.js +4 -4
- package/lib/node/section.js +4 -4
- package/lib/node/signature.js +4 -4
- package/lib/node/statement.js +15 -4
- package/lib/node/step.js +4 -4
- package/lib/node/subDerivation.js +4 -4
- package/lib/node/subproof.js +4 -4
- package/lib/node/substitution/frame.js +28 -6
- package/lib/node/substitution/statement.js +6 -6
- package/lib/node/substitution/term.js +28 -6
- package/lib/node/substitution.js +107 -0
- package/lib/node/supposition.js +4 -4
- package/lib/node/term.js +27 -4
- package/lib/node/theorem.js +6 -6
- package/lib/node/type.js +4 -4
- package/lib/node/typePrefix.js +4 -4
- package/lib/node/types.js +4 -4
- package/lib/node/variable.js +4 -4
- package/lib/nominal/parser.js +3 -3
- package/lib/nonTerminalNode.js +222 -0
- package/lib/nonTerminalNodeMap.js +5 -3
- package/lib/ontology/assertion/contained.js +80 -39
- package/lib/ontology/assertion/defined.js +80 -39
- package/lib/ontology/assertion/property.js +71 -29
- package/lib/ontology/assertion/satisfies.js +73 -25
- package/lib/ontology/assertion/subproof.js +95 -41
- package/lib/ontology/assertion/type.js +74 -18
- package/lib/ontology/assertion.js +66 -0
- package/lib/ontology/assumption.js +379 -0
- package/lib/ontology/axiom.js +8 -11
- package/lib/ontology/combinator/bracketed.js +17 -3
- package/lib/ontology/combinator.js +17 -3
- package/lib/ontology/conclusion.js +38 -9
- package/lib/ontology/constructor/bracketed.js +17 -3
- package/lib/ontology/constructor.js +17 -3
- package/lib/ontology/declaration/combinator.js +75 -33
- package/lib/ontology/declaration/complexType.js +110 -63
- package/lib/ontology/declaration/constructor.js +81 -38
- package/lib/ontology/declaration/metavariable.js +87 -39
- package/lib/ontology/declaration/simpleType.js +95 -48
- package/lib/ontology/declaration/typePrefix.js +87 -40
- package/lib/ontology/declaration/variable.js +87 -39
- package/lib/ontology/declaration.js +13 -313
- package/lib/ontology/deduction.js +38 -9
- package/lib/ontology/equivalence.js +295 -0
- package/lib/ontology/equivalences.js +264 -0
- package/lib/ontology/frame.js +83 -51
- package/lib/ontology/hypothesis.js +11 -11
- package/lib/ontology/judgement.js +8 -8
- package/lib/ontology/label.js +5 -6
- package/lib/ontology/metavariable.js +14 -15
- package/lib/ontology/premise.js +60 -21
- package/lib/ontology/procedureCall.js +15 -15
- package/lib/ontology/procedureReference.js +1 -1
- package/lib/ontology/proof.js +2 -2
- package/lib/ontology/reference.js +6 -13
- package/lib/ontology/rule.js +69 -71
- package/lib/ontology/section.js +2 -2
- package/lib/ontology/signature.js +2 -2
- package/lib/ontology/statement.js +36 -24
- package/lib/ontology/step.js +38 -26
- package/lib/ontology/subproof.js +12 -13
- package/lib/ontology/substitution/frame.js +69 -21
- package/lib/ontology/substitution/reference.js +24 -9
- package/lib/ontology/substitution/statement.js +137 -76
- package/lib/ontology/substitution/term.js +75 -35
- package/lib/ontology/substitution.js +50 -44
- package/lib/ontology/substitutions.js +425 -0
- package/lib/ontology/supposition.js +69 -29
- package/lib/ontology/term.js +35 -37
- package/lib/ontology/topLevelAssertion.js +16 -17
- package/lib/ontology/topLevelMetaAssertion.js +3 -4
- package/lib/ontology/variable.js +9 -14
- package/lib/preamble.js +7 -4
- package/lib/ruleNames.js +20 -12
- package/lib/unifier/intrinsicLevel.js +4 -5
- package/lib/unifier/metaLevel.js +24 -24
- package/lib/utilities/brackets.js +4 -21
- package/lib/utilities/context.js +6 -6
- package/lib/utilities/frame.js +18 -0
- package/lib/utilities/json.js +24 -1
- package/lib/utilities/metavariable.js +18 -0
- package/lib/utilities/statement.js +18 -0
- package/lib/utilities/substitutions.js +43 -30
- package/lib/utilities/unification.js +10 -16
- package/lib/utilities/variable.js +18 -0
- package/package.json +10 -10
- package/src/action/verify.js +2 -2
- package/src/assignment/equality.js +1 -1
- package/src/context/file.js +13 -11
- package/src/context/local.js +40 -65
- package/src/context/partial.js +9 -14
- package/src/context/temporary.js +463 -0
- package/src/mixins/statement/verify.js +60 -23
- package/src/mixins/step/unify.js +6 -6
- package/src/node/argument.js +1 -1
- package/src/node/assertion/contained.js +3 -3
- package/src/node/assertion/defined.js +3 -3
- package/src/node/assertion/property.js +3 -3
- package/src/node/assertion/satisfies.js +3 -3
- package/src/node/assertion/subproof.js +3 -3
- package/src/node/assertion/type.js +3 -3
- package/src/node/assertion.js +7 -0
- package/src/node/assumption.js +35 -0
- package/src/node/axiom.js +3 -3
- package/src/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +2 -2
- package/src/node/body.js +1 -3
- package/src/node/combinator.js +1 -1
- package/src/node/conclusion.js +1 -1
- package/src/node/conjecture.js +3 -3
- package/src/node/constructor.js +1 -1
- package/src/node/declaration/combinator.js +3 -3
- package/src/node/declaration/complexType.js +3 -3
- package/src/node/declaration/constructor.js +3 -3
- package/src/node/declaration/metavariable.js +3 -3
- package/src/node/declaration/property.js +3 -3
- package/src/node/declaration/simpleType.js +3 -3
- package/src/node/declaration/typePrefix.js +3 -3
- package/src/node/declaration/variable.js +3 -3
- package/src/node/declaration.js +2 -18
- package/src/node/deduction.js +1 -1
- package/src/node/derivation.js +1 -1
- package/src/node/document.js +7 -0
- package/src/node/equality.js +1 -1
- package/src/node/error.js +1 -1
- package/src/node/frame.js +23 -11
- package/src/node/header.js +1 -1
- package/src/node/hypothesis.js +1 -1
- package/src/node/judgement.js +6 -6
- package/src/node/label.js +1 -1
- package/src/node/labels.js +1 -1
- package/src/node/lemma.js +3 -3
- package/src/node/metaArgument.js +1 -1
- package/src/node/metaLemma.js +3 -3
- package/src/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +2 -2
- package/src/node/metaType.js +1 -1
- package/src/node/metatheorem.js +3 -3
- package/src/node/metavariable.js +1 -1
- package/src/node/nonsense.js +1 -1
- package/src/node/parameter.js +1 -1
- package/src/node/parenthesisedLabel.js +1 -1
- package/src/node/parenthesisedLabels.js +1 -1
- package/src/node/placeholder.js +7 -0
- package/src/node/premise.js +1 -1
- package/src/node/procedureCall.js +1 -1
- package/src/node/procedureReference.js +1 -1
- package/src/node/proof.js +1 -1
- package/src/node/property.js +1 -1
- package/src/node/propertyRelation.js +1 -1
- package/src/node/qualification.js +1 -1
- package/src/node/reference.js +1 -1
- package/src/node/rule.js +2 -2
- package/src/node/section.js +1 -1
- package/src/node/signature.js +1 -1
- package/src/node/statement.js +13 -1
- package/src/node/step.js +1 -1
- package/src/node/subDerivation.js +1 -1
- package/src/node/subproof.js +1 -1
- package/src/node/substitution/frame.js +29 -3
- package/src/node/substitution/statement.js +3 -3
- package/src/node/substitution/term.js +29 -3
- package/src/node/substitution.js +7 -0
- package/src/node/supposition.js +1 -1
- package/src/node/term.js +27 -1
- package/src/node/theorem.js +3 -3
- package/src/node/type.js +1 -1
- package/src/node/typePrefix.js +1 -1
- package/src/node/types.js +1 -1
- package/src/node/variable.js +1 -1
- package/src/nominal/parser.js +2 -2
- package/src/{node/nonTerminal.js → nonTerminalNode.js} +31 -25
- package/src/nonTerminalNodeMap.js +10 -5
- package/src/ontology/assertion/contained.js +21 -32
- package/src/ontology/assertion/defined.js +20 -31
- package/src/ontology/assertion/property.js +7 -20
- package/src/ontology/assertion/satisfies.js +8 -16
- package/src/ontology/assertion/subproof.js +36 -42
- package/src/ontology/assertion/type.js +10 -11
- package/src/ontology/assertion.js +23 -0
- package/src/ontology/assumption.js +385 -0
- package/src/ontology/axiom.js +7 -16
- package/src/ontology/combinator/bracketed.js +2 -0
- package/src/ontology/combinator.js +2 -0
- package/src/ontology/conclusion.js +51 -10
- package/src/ontology/constructor/bracketed.js +2 -0
- package/src/ontology/constructor.js +2 -0
- package/src/ontology/declaration/combinator.js +15 -24
- package/src/ontology/declaration/complexType.js +57 -53
- package/src/ontology/declaration/constructor.js +25 -31
- package/src/ontology/declaration/metavariable.js +25 -30
- package/src/ontology/declaration/simpleType.js +34 -38
- package/src/ontology/declaration/typePrefix.js +23 -31
- package/src/ontology/declaration/variable.js +26 -31
- package/src/ontology/declaration.js +8 -339
- package/src/ontology/deduction.js +51 -10
- package/src/{equivalence.js → ontology/equivalence.js} +4 -3
- package/src/{equivalences.js → ontology/equivalences.js} +14 -12
- package/src/ontology/frame.js +93 -66
- package/src/ontology/hypothesis.js +8 -8
- package/src/ontology/judgement.js +8 -8
- package/src/ontology/label.js +2 -7
- package/src/ontology/metavariable.js +14 -17
- package/src/ontology/premise.js +82 -25
- package/src/ontology/procedureCall.js +14 -14
- package/src/ontology/procedureReference.js +2 -2
- package/src/ontology/proof.js +1 -1
- package/src/ontology/reference.js +5 -9
- package/src/ontology/rule.js +79 -82
- package/src/ontology/section.js +1 -1
- package/src/ontology/signature.js +1 -1
- package/src/ontology/statement.js +37 -27
- package/src/ontology/step.js +45 -28
- package/src/ontology/subproof.js +10 -10
- package/src/ontology/substitution/frame.js +72 -26
- package/src/ontology/substitution/reference.js +8 -6
- package/src/ontology/substitution/statement.js +95 -76
- package/src/ontology/substitution/term.js +81 -41
- package/src/ontology/substitution.js +35 -34
- package/src/{substitutions.js → ontology/substitutions.js} +29 -28
- package/src/ontology/supposition.js +88 -28
- package/src/ontology/term.js +31 -43
- package/src/ontology/topLevelAssertion.js +16 -18
- package/src/ontology/topLevelMetaAssertion.js +3 -3
- package/src/ontology/variable.js +10 -17
- package/src/preamble.js +6 -3
- package/src/ruleNames.js +10 -8
- package/src/unifier/intrinsicLevel.js +5 -6
- package/src/unifier/metaLevel.js +32 -29
- package/src/utilities/brackets.js +3 -29
- package/src/utilities/context.js +5 -5
- package/src/utilities/frame.js +13 -0
- package/src/utilities/json.js +28 -0
- package/src/utilities/metavariable.js +13 -0
- package/src/utilities/statement.js +13 -0
- package/src/utilities/substitutions.js +59 -33
- package/src/utilities/unification.js +8 -24
- package/src/utilities/variable.js +13 -0
- package/lib/equivalence.js +0 -294
- package/lib/equivalences.js +0 -263
- package/lib/node/nonTerminal.js +0 -218
- package/lib/substitutions.js +0 -424
|
@@ -10,7 +10,6 @@ import { unifyStatement } from "../utilities/unification";
|
|
|
10
10
|
import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
11
11
|
import { statementFromStatementNode } from "../utilities/node";
|
|
12
12
|
import { stripBracketsFromStatementNode } from "../utilities/brackets";
|
|
13
|
-
import { definedAssertionFromStatement, containedAssertionFromStatement, subproofAssertionFromStatement } from "../utilities/context";
|
|
14
13
|
|
|
15
14
|
const { match, backwardsSome } = arrayUtilities;
|
|
16
15
|
|
|
@@ -33,6 +32,8 @@ export default define(class Statement {
|
|
|
33
32
|
return this.tokens;
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
isSimple() { return this.node.isSimple();}
|
|
36
|
+
|
|
36
37
|
isEqualTo(statement) {
|
|
37
38
|
const statementString = statement.getString(),
|
|
38
39
|
equalTo = (statementString === this.string);
|
|
@@ -94,6 +95,8 @@ export default define(class Statement {
|
|
|
94
95
|
return frameContained;
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
matchStatementNode(statementNode) { return this.node.match(statementNode); }
|
|
99
|
+
|
|
97
100
|
verify(assignments, stated, context) {
|
|
98
101
|
let verifies;
|
|
99
102
|
|
|
@@ -111,6 +114,10 @@ export default define(class Statement {
|
|
|
111
114
|
});
|
|
112
115
|
|
|
113
116
|
if (verifies) {
|
|
117
|
+
const statement = this; ///
|
|
118
|
+
|
|
119
|
+
context.addStatement(statement);
|
|
120
|
+
|
|
114
121
|
context.debug(`...verified the '${statementString}' statement.`, this.node);
|
|
115
122
|
}
|
|
116
123
|
|
|
@@ -144,14 +151,18 @@ export default define(class Statement {
|
|
|
144
151
|
let subproofUnifies = false;
|
|
145
152
|
|
|
146
153
|
const context = specificContext, ///
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
statementNode = this.node,
|
|
155
|
+
subproofAssertionNode = statementNode.getSubproofAssertionNode(),
|
|
156
|
+
assertionNode = subproofAssertionNode; ///
|
|
157
|
+
|
|
158
|
+
if (assertionNode !== null) {
|
|
159
|
+
const assertion = generalContext.findAssertionByAssertionNode(assertionNode),
|
|
160
|
+
subproofAssertion = assertion; ///
|
|
149
161
|
|
|
150
|
-
if (subproofAssertion !== null) {
|
|
151
162
|
const subproofString = subproof.getString(),
|
|
152
163
|
subproofAssertionString = subproofAssertion.getString();
|
|
153
164
|
|
|
154
|
-
|
|
165
|
+
context.trace(`Unifying the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion...`);
|
|
155
166
|
|
|
156
167
|
const subproofStatements = subproof.getStatements(),
|
|
157
168
|
subproofAssertionStatements = subproofAssertion.getStatements();
|
|
@@ -167,7 +178,7 @@ export default define(class Statement {
|
|
|
167
178
|
});
|
|
168
179
|
|
|
169
180
|
if (subproofUnifies) {
|
|
170
|
-
|
|
181
|
+
context.debug(`...unified the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion.`);
|
|
171
182
|
}
|
|
172
183
|
}
|
|
173
184
|
|
|
@@ -193,27 +204,26 @@ export default define(class Statement {
|
|
|
193
204
|
return statementUnifies;
|
|
194
205
|
}
|
|
195
206
|
|
|
196
|
-
unifyIndependently(substitutions,
|
|
207
|
+
unifyIndependently(substitutions, generalContext, specificContext) {
|
|
197
208
|
let unifiesIndependently = false;
|
|
198
209
|
|
|
199
|
-
const
|
|
210
|
+
const context = specificContext, ///
|
|
200
211
|
statementString = this.string; ///
|
|
201
212
|
|
|
202
213
|
context.trace(`Unifying the '${statementString}' statement independently...`);
|
|
203
214
|
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (definedAssertion !== null) {
|
|
208
|
-
const definedAssertionUnifiesIndependently = definedAssertion.unifyIndependently(substitutions, context);
|
|
209
|
-
|
|
210
|
-
unifiesIndependently = definedAssertionUnifiesIndependently; ///
|
|
211
|
-
}
|
|
215
|
+
const statementNode = this.node,
|
|
216
|
+
definedAssertionNode = statementNode.getDefinedAssertionNode(),
|
|
217
|
+
containedAssertionNode = statementNode.getContainedAssertionNode();
|
|
212
218
|
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
219
|
+
if ((definedAssertionNode !== null) || (containedAssertionNode !== null)) {
|
|
220
|
+
const assertionNode = (definedAssertionNode || containedAssertionNode),
|
|
221
|
+
assertion = generalContext.findAssertionByAssertionNode(assertionNode),
|
|
222
|
+
assertionUnifiesIndependently = assertion.unifyIndependently(substitutions, generalContext, specificContext);
|
|
215
223
|
|
|
216
|
-
|
|
224
|
+
if (assertionUnifiesIndependently) {
|
|
225
|
+
unifiesIndependently = true;
|
|
226
|
+
}
|
|
217
227
|
}
|
|
218
228
|
|
|
219
229
|
if (unifiesIndependently) {
|
|
@@ -327,28 +337,28 @@ export default define(class Statement {
|
|
|
327
337
|
return statement;
|
|
328
338
|
}
|
|
329
339
|
|
|
330
|
-
static
|
|
340
|
+
static fromAssumptionNode(assumptionNode, context) {
|
|
331
341
|
let statement = null;
|
|
332
342
|
|
|
333
|
-
|
|
343
|
+
let statementNode;
|
|
344
|
+
|
|
345
|
+
statementNode = assumptionNode.getStatementNode(); ///
|
|
334
346
|
|
|
335
347
|
if (statementNode !== null) {
|
|
348
|
+
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
349
|
+
|
|
336
350
|
statement = statementFromStatementNode(statementNode, context);
|
|
337
351
|
}
|
|
338
352
|
|
|
339
353
|
return statement;
|
|
340
354
|
}
|
|
341
355
|
|
|
342
|
-
static
|
|
356
|
+
static fromSuppositionNode(suppositionNode, context) {
|
|
343
357
|
let statement = null;
|
|
344
358
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
statementNode = declarationNode.getStatementNode(); ///
|
|
359
|
+
const statementNode = suppositionNode.getStatementNode();
|
|
348
360
|
|
|
349
361
|
if (statementNode !== null) {
|
|
350
|
-
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
351
|
-
|
|
352
362
|
statement = statementFromStatementNode(statementNode, context);
|
|
353
363
|
}
|
|
354
364
|
|
package/src/ontology/step.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
4
|
import unifyMixins from "../mixins/step/unify";
|
|
5
|
-
import
|
|
5
|
+
import TemporaryContext from "../context/temporary";
|
|
6
6
|
import equationalUnifier from "../unifier/equantional";
|
|
7
7
|
|
|
8
8
|
import { define } from "../ontology";
|
|
9
9
|
import { propertyAssertionFromStatement } from "../utilities/context";
|
|
10
10
|
|
|
11
11
|
export default define(class Step {
|
|
12
|
-
constructor(node, string, statement, reference, satisfiesAssertion) {
|
|
12
|
+
constructor(context, node, string, statement, reference, satisfiesAssertion) {
|
|
13
|
+
this.context = context;
|
|
13
14
|
this.node = node;
|
|
14
15
|
this.string = string;
|
|
15
16
|
this.statement = statement;
|
|
@@ -17,6 +18,10 @@ export default define(class Step {
|
|
|
17
18
|
this.satisfiesAssertion = satisfiesAssertion;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
getContext() {
|
|
22
|
+
return this.context;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
getNode() {
|
|
21
26
|
return this.node;
|
|
22
27
|
}
|
|
@@ -74,31 +79,13 @@ export default define(class Step {
|
|
|
74
79
|
return termAndPropertyRelationMatch;
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
unify(substitutions, context) {
|
|
78
|
-
let unifies;
|
|
79
|
-
|
|
80
|
-
const stepString = this.string; ///
|
|
81
|
-
|
|
82
|
-
context.trace(`Unifying the '${stepString}' step...`, this.node);
|
|
83
|
-
|
|
84
|
-
unifies = unifyMixins.some((unifyMixin) => {
|
|
85
|
-
const unifies = unifyMixin(this.statement, this.reference, this.satisfiesAssertion, substitutions, context);
|
|
86
|
-
|
|
87
|
-
if (unifies) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
if (unifies) {
|
|
93
|
-
context.debug(`...unified the '${stepString}' step.`, this.node);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return unifies;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
82
|
verify(substitutions, assignments, context) {
|
|
100
83
|
let verifies = false;
|
|
101
84
|
|
|
85
|
+
const temporaryContext = TemporaryContext.fromNothing(context);
|
|
86
|
+
|
|
87
|
+
context = temporaryContext; ///
|
|
88
|
+
|
|
102
89
|
const stepString = this.string; ///
|
|
103
90
|
|
|
104
91
|
context.trace(`Verifying the '${stepString}' step...`, this.node);
|
|
@@ -136,12 +123,38 @@ export default define(class Step {
|
|
|
136
123
|
}
|
|
137
124
|
|
|
138
125
|
if (verifies) {
|
|
126
|
+
this.context = context;
|
|
127
|
+
|
|
139
128
|
context.debug(`...verified the '${stepString}' step.`, this.node);
|
|
140
129
|
}
|
|
141
130
|
|
|
142
131
|
return verifies;
|
|
143
132
|
}
|
|
144
133
|
|
|
134
|
+
unify(substitutions, context) {
|
|
135
|
+
let unifies;
|
|
136
|
+
|
|
137
|
+
context = this.context;
|
|
138
|
+
|
|
139
|
+
const stepString = this.string; ///
|
|
140
|
+
|
|
141
|
+
context.trace(`Unifying the '${stepString}' step...`, this.node);
|
|
142
|
+
|
|
143
|
+
unifies = unifyMixins.some((unifyMixin) => {
|
|
144
|
+
const unifies = unifyMixin(this.statement, this.reference, this.satisfiesAssertion, substitutions, context);
|
|
145
|
+
|
|
146
|
+
if (unifies) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (unifies) {
|
|
152
|
+
context.debug(`...unified the '${stepString}' step.`, this.node);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return unifies;
|
|
156
|
+
}
|
|
157
|
+
|
|
145
158
|
equateWithStatement(statement, context) {
|
|
146
159
|
let statementEquates;
|
|
147
160
|
|
|
@@ -168,7 +181,8 @@ export default define(class Step {
|
|
|
168
181
|
axiom = context.findAxiomByReference(reference);
|
|
169
182
|
|
|
170
183
|
if (axiom !== null) {
|
|
171
|
-
const
|
|
184
|
+
const { Substitutions } = ontology,
|
|
185
|
+
step = this, ///
|
|
172
186
|
substitutions = Substitutions.fromNothing(),
|
|
173
187
|
stepUnifies = axiom.unifyStep(step, substitutions, context);
|
|
174
188
|
|
|
@@ -196,7 +210,7 @@ export default define(class Step {
|
|
|
196
210
|
node = null,
|
|
197
211
|
reference = null,
|
|
198
212
|
satisfiesAssertion = null,
|
|
199
|
-
step = new Step(node, string, statement, reference, satisfiesAssertion);
|
|
213
|
+
step = new Step(context, node, string, statement, reference, satisfiesAssertion);
|
|
200
214
|
|
|
201
215
|
return step;
|
|
202
216
|
}
|
|
@@ -213,9 +227,12 @@ export default define(class Step {
|
|
|
213
227
|
string = context.nodeAsString(node),
|
|
214
228
|
statement = Statement.fromStepNode(stepNode, context),
|
|
215
229
|
reference = Reference.fromStepNode(stepNode, context),
|
|
216
|
-
satisfiesAssertion = SatisfiesAssertion.fromStepNode(stepNode, context)
|
|
230
|
+
satisfiesAssertion = SatisfiesAssertion.fromStepNode(stepNode, context),
|
|
231
|
+
temporaryContext = null;
|
|
232
|
+
|
|
233
|
+
context = temporaryContext; ///
|
|
217
234
|
|
|
218
|
-
step = new Step(node, string, statement, reference, satisfiesAssertion)
|
|
235
|
+
step = new Step(context, node, string, statement, reference, satisfiesAssertion)
|
|
219
236
|
}
|
|
220
237
|
|
|
221
238
|
return step;
|
package/src/ontology/subproof.js
CHANGED
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
|
-
import Substitutions from "../substitutions";
|
|
6
5
|
|
|
7
6
|
import { define } from "../ontology";
|
|
8
7
|
import { subproofStringFromSubproofNode } from "../utilities/subproof";
|
|
9
8
|
|
|
10
9
|
export default define(class Subproof {
|
|
11
|
-
constructor(
|
|
12
|
-
this.node = node;
|
|
10
|
+
constructor(string, node, suppositions, subDerivation) {
|
|
13
11
|
this.string = string;
|
|
12
|
+
this.node = node;
|
|
14
13
|
this.suppositions = suppositions;
|
|
15
14
|
this.subDerivation = subDerivation;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
getNode() {
|
|
19
|
-
return this.node;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
17
|
getString() {
|
|
23
18
|
return this.string;
|
|
24
19
|
}
|
|
25
20
|
|
|
21
|
+
getNode() {
|
|
22
|
+
return this.node;
|
|
23
|
+
}
|
|
24
|
+
|
|
26
25
|
getSuppositions() {
|
|
27
26
|
return this.suppositions;
|
|
28
27
|
}
|
|
@@ -66,7 +65,7 @@ export default define(class Subproof {
|
|
|
66
65
|
verify(substitutions, assignments, context) {
|
|
67
66
|
let subproofVerifies = false;
|
|
68
67
|
|
|
69
|
-
const localContext = LocalContext.
|
|
68
|
+
const localContext = LocalContext.fromNothing(context); ///
|
|
70
69
|
|
|
71
70
|
context = localContext; ///
|
|
72
71
|
|
|
@@ -110,7 +109,8 @@ export default define(class Subproof {
|
|
|
110
109
|
const axiomSatisfiable = axiom.isSatisfiable();
|
|
111
110
|
|
|
112
111
|
if (axiomSatisfiable) {
|
|
113
|
-
const
|
|
112
|
+
const { Substitutions } = ontology,
|
|
113
|
+
subproof = this, ///
|
|
114
114
|
substitutions = Substitutions.fromNothing(),
|
|
115
115
|
statementUnifies = axiom.unifySubproof(subproof, substitutions, context);
|
|
116
116
|
|
|
@@ -146,7 +146,7 @@ export default define(class Subproof {
|
|
|
146
146
|
node = subproofNode, ///
|
|
147
147
|
string = subproofString; ///
|
|
148
148
|
|
|
149
|
-
subproof = new Subproof(
|
|
149
|
+
subproof = new Subproof(string, node, suppositions, subDerivation);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
return subproof;
|
|
@@ -7,8 +7,8 @@ import FrameSubstitutionPartialContext from "../../context/partial/substitution/
|
|
|
7
7
|
import { define } from "../../ontology";
|
|
8
8
|
|
|
9
9
|
export default define(class FrameSubstitution extends Substitution {
|
|
10
|
-
constructor(string, node, tokens, frame, metavariable) {
|
|
11
|
-
super(string, node, tokens);
|
|
10
|
+
constructor(context, string, node, tokens, frame, metavariable) {
|
|
11
|
+
super(context, string, node, tokens);
|
|
12
12
|
|
|
13
13
|
this.frame = frame;
|
|
14
14
|
this.metavariable = metavariable;
|
|
@@ -22,12 +22,6 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
22
22
|
return this.metavariable;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
isFrameEqualTo(frame) { return this.frame.isEqualTo(frame); }
|
|
26
|
-
|
|
27
|
-
isMetavariableEqualTo(metavariable) { return this.metavariable.isEqualTo(metavariable); }
|
|
28
|
-
|
|
29
|
-
matchParameter(parameter) { return this.metavariable.matchParameter(parameter); }
|
|
30
|
-
|
|
31
25
|
getReplacementNode() {
|
|
32
26
|
const frameNode = this.frame.getNode(),
|
|
33
27
|
replacementNode = frameNode; ///
|
|
@@ -35,28 +29,80 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
35
29
|
return replacementNode;
|
|
36
30
|
}
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
isFrameEqualToFrame(frame) { return this.frame.isEqualTo(frame); }
|
|
33
|
+
|
|
34
|
+
isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
|
|
35
|
+
|
|
36
|
+
matchParameter(parameter) { return this.metavariable.matchParameter(parameter); }
|
|
37
|
+
|
|
38
|
+
verify(context) {
|
|
39
|
+
let verifies = false;
|
|
40
|
+
|
|
41
|
+
const frameSubstitutionString = this.string; ///
|
|
42
|
+
|
|
43
|
+
context.trace(`Verifiying the '${frameSubstitutionString}' frame substitutin...`);
|
|
44
|
+
|
|
45
|
+
const frameSimple = this.frame.isSimple();
|
|
46
|
+
|
|
47
|
+
if (frameSimple) {
|
|
48
|
+
if (this.metavariable === null) {
|
|
49
|
+
context.debug(`The specific frame is not simple.`);
|
|
50
|
+
} else {
|
|
51
|
+
const metavariablePresent = context.isMetavariablePresent(this.metavariable);
|
|
52
|
+
|
|
53
|
+
if (metavariablePresent) {
|
|
54
|
+
const metavariable = this.frame.getMetavariable(),
|
|
55
|
+
metavariablePresent = context.isMetavariablePresent(metavariable);
|
|
56
|
+
|
|
57
|
+
if (metavariablePresent) {
|
|
58
|
+
verifies = true;
|
|
59
|
+
} else {
|
|
60
|
+
const metavariableString = metavariable.getString();
|
|
61
|
+
|
|
62
|
+
context.debug(`The '${metavariableString}' metavariable is not present.`);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
const metavariableString = this.metavariable.getString();
|
|
66
|
+
|
|
67
|
+
context.debug(`The '${metavariableString}' metavariable is not present.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
context.debug(`The general frame is not simple.`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (verifies) {
|
|
75
|
+
const substititoin = this; ///
|
|
76
|
+
|
|
77
|
+
context.addSubstitution(substititoin);
|
|
78
|
+
|
|
79
|
+
context.debug(`...verified the '${frameSubstitutionString}' frame substitutin.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return verifies;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static name = "FrameSubstitution";
|
|
86
|
+
|
|
87
|
+
static fromStatement(statement, context) {
|
|
39
88
|
let frameSubstitution = null;
|
|
40
89
|
|
|
41
|
-
const
|
|
90
|
+
const statementNode = statement.getNode(),
|
|
91
|
+
frameSubstitutionNode = statementNode.getFrameSubstitutionNode();
|
|
42
92
|
|
|
43
93
|
if (frameSubstitutionNode !== null) {
|
|
44
|
-
const
|
|
94
|
+
const { Frame, Metavariable } = ontology,
|
|
45
95
|
firstFrameNode = frameSubstitutionNode.getFirstFrameNode(),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
string = stringFromFrameAndMetavariable(frame, metavariable);
|
|
57
|
-
|
|
58
|
-
frameSubstitution = new FrameSubstitution(string, node, tokens, frame, metavariable);
|
|
59
|
-
}
|
|
96
|
+
lastMetavariableNode = frameSubstitutionNode.getLastMetavariableNode(),
|
|
97
|
+
metavariableNode = lastMetavariableNode, ///
|
|
98
|
+
frameNode = firstFrameNode, ///
|
|
99
|
+
node = frameSubstitutionNode, ///
|
|
100
|
+
tokens = context.nodeAsTokens(node),
|
|
101
|
+
string = context.nodeAsString(node),
|
|
102
|
+
frame = Frame.fromFrameNode(frameNode, context),
|
|
103
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, context);
|
|
104
|
+
|
|
105
|
+
frameSubstitution = new FrameSubstitution(context, string, node, tokens, frame, metavariable);
|
|
60
106
|
}
|
|
61
107
|
|
|
62
108
|
return frameSubstitution;
|
|
@@ -69,7 +115,7 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
69
115
|
frameSubstitutionPartialContext = FrameSubstitutionPartialContext.fromStringLexerAndParser(string, lexer, parser),
|
|
70
116
|
node = frameSubstitutionPartialContext.getNode(),
|
|
71
117
|
tokens = frameSubstitutionPartialContext.getTokens(),
|
|
72
|
-
frameSubstitution = new FrameSubstitution(string, node, tokens, frame, metavariable);
|
|
118
|
+
frameSubstitution = new FrameSubstitution(context, string, node, tokens, frame, metavariable);
|
|
73
119
|
|
|
74
120
|
return frameSubstitution;
|
|
75
121
|
}
|
|
@@ -6,8 +6,8 @@ import ReferenceSubstitutionPartialContext from "../../context/partial/substitut
|
|
|
6
6
|
import { define } from "../../ontology";
|
|
7
7
|
|
|
8
8
|
export default define(class ReferenceSubstitution extends Substitution {
|
|
9
|
-
constructor(string, node, tokens, reference, metavariable) {
|
|
10
|
-
super(string, node, tokens);
|
|
9
|
+
constructor(context, string, node, tokens, reference, metavariable) {
|
|
10
|
+
super(context, string, node, tokens);
|
|
11
11
|
|
|
12
12
|
this.reference = reference;
|
|
13
13
|
this.metavariable = metavariable;
|
|
@@ -21,12 +21,14 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
21
21
|
return this.metavariable;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
const
|
|
24
|
+
isReferenceEqualToReference(reference) {
|
|
25
|
+
const referenceEqualToReference = this.reference.isEqualTo(reference);
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return referenceEqualToReference;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
static name = "ReferenceSubstitution";
|
|
31
|
+
|
|
30
32
|
static fromReferenceAndMetavariable(reference, metavariable, context) {
|
|
31
33
|
const string = stringFromReferenceAndMetavariable(reference, metavariable),
|
|
32
34
|
lexer = context.getLexer(),
|
|
@@ -34,7 +36,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
34
36
|
referenceSubstitutionPartialContext = ReferenceSubstitutionPartialContext.fromStringLexerAndParser(string, lexer, parser),
|
|
35
37
|
node = referenceSubstitutionPartialContext.getNode(),
|
|
36
38
|
tokens = referenceSubstitutionPartialContext.getTokens(),
|
|
37
|
-
referenceSubstitution = new ReferenceSubstitution(string, node, tokens, reference, metavariable);
|
|
39
|
+
referenceSubstitution = new ReferenceSubstitution(context, string, node, tokens, reference, metavariable);
|
|
38
40
|
|
|
39
41
|
return referenceSubstitution;
|
|
40
42
|
}
|