occam-verify-cli 1.0.396 → 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/assignment/equality.js +2 -2
- package/lib/context/file.js +4 -5
- package/lib/context/local.js +17 -6
- package/lib/context/partial.js +10 -10
- package/lib/context/temporary.js +102 -52
- package/lib/mixins/step/unify.js +5 -6
- 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 +6 -6
- package/lib/node/substitution/statement.js +6 -6
- package/lib/node/substitution/term.js +6 -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 +8 -9
- package/lib/ontology/assertion/defined.js +9 -10
- package/lib/ontology/assertion/satisfies.js +4 -4
- package/lib/ontology/assumption.js +379 -0
- 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 -338
- package/lib/ontology/equivalence.js +295 -0
- package/lib/ontology/equivalences.js +264 -0
- package/lib/ontology/frame.js +49 -54
- package/lib/ontology/judgement.js +8 -8
- package/lib/ontology/metavariable.js +4 -4
- package/lib/ontology/premise.js +14 -5
- package/lib/ontology/reference.js +3 -9
- package/lib/ontology/rule.js +3 -4
- package/lib/ontology/statement.js +28 -24
- package/lib/ontology/step.js +2 -3
- package/lib/ontology/subproof.js +2 -3
- package/lib/ontology/substitution/statement.js +77 -36
- package/lib/ontology/substitution/term.js +14 -34
- package/lib/ontology/substitution.js +18 -19
- package/lib/ontology/substitutions.js +425 -0
- package/lib/ontology/supposition.js +14 -5
- package/lib/ontology/term.js +33 -36
- package/lib/ontology/topLevelAssertion.js +2 -3
- package/lib/ontology/topLevelMetaAssertion.js +2 -3
- package/lib/ontology/variable.js +1 -34
- package/lib/preamble.js +7 -4
- package/lib/ruleNames.js +20 -12
- package/lib/unifier/intrinsicLevel.js +4 -12
- package/lib/unifier/metaLevel.js +14 -22
- package/lib/utilities/frame.js +18 -0
- package/lib/utilities/statement.js +18 -0
- package/lib/utilities/substitutions.js +43 -30
- package/lib/utilities/variable.js +5 -17
- package/package.json +10 -10
- package/src/assignment/equality.js +1 -1
- package/src/context/file.js +5 -4
- package/src/context/local.js +28 -5
- package/src/context/partial.js +9 -14
- package/src/context/temporary.js +120 -51
- package/src/mixins/step/unify.js +4 -4
- 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 +3 -3
- package/src/node/substitution/statement.js +3 -3
- package/src/node/substitution/term.js +3 -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 +14 -14
- package/src/ontology/assertion/defined.js +13 -13
- package/src/ontology/assertion/satisfies.js +2 -1
- package/src/ontology/assumption.js +385 -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 -372
- package/src/{equivalence.js → ontology/equivalence.js} +4 -3
- package/src/{equivalences.js → ontology/equivalences.js} +14 -12
- package/src/ontology/frame.js +53 -63
- package/src/ontology/judgement.js +8 -8
- package/src/ontology/metavariable.js +2 -2
- package/src/ontology/premise.js +18 -4
- package/src/ontology/reference.js +4 -3
- package/src/ontology/rule.js +4 -3
- package/src/ontology/statement.js +31 -27
- package/src/ontology/step.js +2 -2
- package/src/ontology/subproof.js +2 -2
- package/src/ontology/substitution/statement.js +56 -53
- package/src/ontology/substitution/term.js +9 -35
- package/src/ontology/substitution.js +11 -15
- package/src/{substitutions.js → ontology/substitutions.js} +4 -3
- package/src/ontology/supposition.js +18 -4
- package/src/ontology/term.js +27 -39
- package/src/ontology/topLevelAssertion.js +2 -2
- package/src/ontology/topLevelMetaAssertion.js +2 -2
- package/src/ontology/variable.js +0 -54
- package/src/preamble.js +6 -3
- package/src/ruleNames.js +10 -8
- package/src/unifier/intrinsicLevel.js +3 -14
- package/src/unifier/metaLevel.js +14 -25
- package/src/utilities/frame.js +13 -0
- package/src/utilities/statement.js +13 -0
- package/src/utilities/substitutions.js +59 -31
- package/src/utilities/variable.js +1 -10
- 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
|
@@ -6,10 +6,10 @@ import JudgementAssignment from "../assignment/judgement";
|
|
|
6
6
|
import { define } from "../ontology";
|
|
7
7
|
|
|
8
8
|
export default define(class Judgement {
|
|
9
|
-
constructor(string, frame,
|
|
9
|
+
constructor(string, frame, assumption) {
|
|
10
10
|
this.string = string;
|
|
11
11
|
this.frame = frame;
|
|
12
|
-
this.
|
|
12
|
+
this.assumption = assumption;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
getString() {
|
|
@@ -21,7 +21,7 @@ export default define(class Judgement {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
getDeclaration() {
|
|
24
|
-
return this.
|
|
24
|
+
return this.assumption;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
isSimple() { return this.frame.isSimple(); }
|
|
@@ -88,7 +88,7 @@ export default define(class Judgement {
|
|
|
88
88
|
verifyDeclaration(assignments, stated, context) {
|
|
89
89
|
let declarationVerifies;
|
|
90
90
|
|
|
91
|
-
declarationVerifies = this.
|
|
91
|
+
declarationVerifies = this.assumption.verify(assignments, stated, context);
|
|
92
92
|
|
|
93
93
|
return declarationVerifies;
|
|
94
94
|
}
|
|
@@ -116,7 +116,7 @@ export default define(class Judgement {
|
|
|
116
116
|
|
|
117
117
|
context.trace(`Verifying the '${judgementString}' derived judgement...`);
|
|
118
118
|
|
|
119
|
-
const metavariable = this.
|
|
119
|
+
const metavariable = this.assumption.getMetavariable(),
|
|
120
120
|
reference = referenceFromMetavariable(metavariable, context),
|
|
121
121
|
metaLemmaMetatheorem = context.findMetaLemmaMetatheoremByReference(reference),
|
|
122
122
|
substitutions = metaLemmaMetatheorem.getSubstitutions(),
|
|
@@ -151,13 +151,13 @@ export default define(class Judgement {
|
|
|
151
151
|
const judgementNode = statementNode.getJudgementNode();
|
|
152
152
|
|
|
153
153
|
if (judgementNode !== null) {
|
|
154
|
-
const { Frame,
|
|
154
|
+
const { Frame, Assumption } = ontology,
|
|
155
155
|
node = judgementNode, ///
|
|
156
156
|
string = context.nodeAsString(node),
|
|
157
157
|
frame = Frame.fromJudgementNode(judgementNode, context),
|
|
158
|
-
|
|
158
|
+
assumption = Assumption.fromJudgementNode(judgementNode, context);
|
|
159
159
|
|
|
160
|
-
judgement = new Judgement(string, frame,
|
|
160
|
+
judgement = new Judgement(string, frame, assumption);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
return judgement;
|
|
@@ -474,8 +474,8 @@ export default define(class Metavariable {
|
|
|
474
474
|
return metavariable;
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
-
static
|
|
478
|
-
const metavariableNode =
|
|
477
|
+
static fromAssumptionNode(assumptionNode, context) {
|
|
478
|
+
const metavariableNode = assumptionNode.getMetavariableNode(),
|
|
479
479
|
metavariable = metavariableFromMetavariableNode(metavariableNode, context);
|
|
480
480
|
|
|
481
481
|
return metavariable;
|
package/src/ontology/premise.js
CHANGED
|
@@ -90,18 +90,32 @@ export default define(class Premise {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
unifyIndependently(substitutions, context) {
|
|
93
|
-
let unifiesIndependently;
|
|
93
|
+
let unifiesIndependently = false;
|
|
94
|
+
|
|
95
|
+
const premiseString = this.string, ///
|
|
96
|
+
generalContext = this.context, ///
|
|
97
|
+
specificContext = context; ///
|
|
98
|
+
|
|
99
|
+
context.trace(`Unifying the '${premiseString}' premise independently...`, this.node);
|
|
94
100
|
|
|
95
101
|
if (this.statement !== null) {
|
|
96
|
-
const
|
|
102
|
+
const statementUnifiesIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
if (statementUnifiesIndependently) {
|
|
105
|
+
unifiesIndependently = true;
|
|
106
|
+
}
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
if (this.procedureCall !== null) {
|
|
102
110
|
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, context);
|
|
103
111
|
|
|
104
|
-
|
|
112
|
+
if (procedureCallResolvedIndependently) {
|
|
113
|
+
unifiesIndependently = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (unifiesIndependently) {
|
|
118
|
+
context.debug(`...unified the '${premiseString}' premise independenly.`, this.node);
|
|
105
119
|
}
|
|
106
120
|
|
|
107
121
|
return unifiesIndependently;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
|
-
import Substitutions from "../substitutions";
|
|
5
4
|
|
|
6
5
|
import { define } from "../ontology";
|
|
7
6
|
import { referenceMetaType } from ".//metaType";
|
|
@@ -115,7 +114,8 @@ export default define(class Reference {
|
|
|
115
114
|
|
|
116
115
|
context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
|
|
117
116
|
|
|
118
|
-
const
|
|
117
|
+
const { Substitutions } = ontology,
|
|
118
|
+
substitutions = Substitutions.fromNothing(),
|
|
119
119
|
generalContext = context, ///
|
|
120
120
|
specificContext = context, ///
|
|
121
121
|
generalMetavariable = this.metavariable, ///
|
|
@@ -140,7 +140,8 @@ export default define(class Reference {
|
|
|
140
140
|
|
|
141
141
|
context.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${referenceString}' reference...`);
|
|
142
142
|
|
|
143
|
-
const
|
|
143
|
+
const { Substitutions } = ontology,
|
|
144
|
+
label = metaLemmaMetatheorem.getLabel(),
|
|
144
145
|
substitutions = Substitutions.fromNothing(),
|
|
145
146
|
labelUnifies = this.unifyLabel(label, substitutions, context);
|
|
146
147
|
|
package/src/ontology/rule.js
CHANGED
|
@@ -4,7 +4,6 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import ontology from "../ontology";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
|
-
import Substitutions from "../substitutions";
|
|
8
7
|
|
|
9
8
|
import { define } from "../ontology";
|
|
10
9
|
import { labelsStringFromLabels } from "./topLevelAssertion";
|
|
@@ -149,7 +148,8 @@ export default define(class Rule {
|
|
|
149
148
|
if (this.proof === null) {
|
|
150
149
|
proofVerifies = true;
|
|
151
150
|
} else {
|
|
152
|
-
const
|
|
151
|
+
const { Substitutions } = ontology,
|
|
152
|
+
substitutions = Substitutions.fromNothing();
|
|
153
153
|
|
|
154
154
|
proofVerifies = this.proof.verify(substitutions, this.conclusion, context);
|
|
155
155
|
}
|
|
@@ -172,7 +172,8 @@ export default define(class Rule {
|
|
|
172
172
|
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context) {
|
|
173
173
|
let statementAndStepsOrSubproofsUnify = false;
|
|
174
174
|
|
|
175
|
-
const
|
|
175
|
+
const { Substitutions } = ontology,
|
|
176
|
+
substitutions = Substitutions.fromNothing(),
|
|
176
177
|
statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, context);
|
|
177
178
|
|
|
178
179
|
if (statementUnifiesWithConclusion) {
|
|
@@ -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);
|
|
@@ -150,14 +151,18 @@ export default define(class Statement {
|
|
|
150
151
|
let subproofUnifies = false;
|
|
151
152
|
|
|
152
153
|
const context = specificContext, ///
|
|
153
|
-
|
|
154
|
-
|
|
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; ///
|
|
155
161
|
|
|
156
|
-
if (subproofAssertion !== null) {
|
|
157
162
|
const subproofString = subproof.getString(),
|
|
158
163
|
subproofAssertionString = subproofAssertion.getString();
|
|
159
164
|
|
|
160
|
-
|
|
165
|
+
context.trace(`Unifying the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion...`);
|
|
161
166
|
|
|
162
167
|
const subproofStatements = subproof.getStatements(),
|
|
163
168
|
subproofAssertionStatements = subproofAssertion.getStatements();
|
|
@@ -173,7 +178,7 @@ export default define(class Statement {
|
|
|
173
178
|
});
|
|
174
179
|
|
|
175
180
|
if (subproofUnifies) {
|
|
176
|
-
|
|
181
|
+
context.debug(`...unified the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion.`);
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
184
|
|
|
@@ -199,27 +204,26 @@ export default define(class Statement {
|
|
|
199
204
|
return statementUnifies;
|
|
200
205
|
}
|
|
201
206
|
|
|
202
|
-
unifyIndependently(substitutions,
|
|
207
|
+
unifyIndependently(substitutions, generalContext, specificContext) {
|
|
203
208
|
let unifiesIndependently = false;
|
|
204
209
|
|
|
205
|
-
const
|
|
210
|
+
const context = specificContext, ///
|
|
206
211
|
statementString = this.string; ///
|
|
207
212
|
|
|
208
213
|
context.trace(`Unifying the '${statementString}' statement independently...`);
|
|
209
214
|
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (definedAssertion !== null) {
|
|
214
|
-
const definedAssertionUnifiesIndependently = definedAssertion.unifyIndependently(substitutions, context);
|
|
215
|
+
const statementNode = this.node,
|
|
216
|
+
definedAssertionNode = statementNode.getDefinedAssertionNode(),
|
|
217
|
+
containedAssertionNode = statementNode.getContainedAssertionNode();
|
|
215
218
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const containedAssertionUnifiesIndependently = containedAssertion.unifyIndependently(substitutions, context);
|
|
219
|
+
if ((definedAssertionNode !== null) || (containedAssertionNode !== null)) {
|
|
220
|
+
const assertionNode = (definedAssertionNode || containedAssertionNode),
|
|
221
|
+
assertion = generalContext.findAssertionByAssertionNode(assertionNode),
|
|
222
|
+
assertionUnifiesIndependently = assertion.unifyIndependently(substitutions, generalContext, specificContext);
|
|
221
223
|
|
|
222
|
-
|
|
224
|
+
if (assertionUnifiesIndependently) {
|
|
225
|
+
unifiesIndependently = true;
|
|
226
|
+
}
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
if (unifiesIndependently) {
|
|
@@ -333,28 +337,28 @@ export default define(class Statement {
|
|
|
333
337
|
return statement;
|
|
334
338
|
}
|
|
335
339
|
|
|
336
|
-
static
|
|
340
|
+
static fromAssumptionNode(assumptionNode, context) {
|
|
337
341
|
let statement = null;
|
|
338
342
|
|
|
339
|
-
|
|
343
|
+
let statementNode;
|
|
344
|
+
|
|
345
|
+
statementNode = assumptionNode.getStatementNode(); ///
|
|
340
346
|
|
|
341
347
|
if (statementNode !== null) {
|
|
348
|
+
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
349
|
+
|
|
342
350
|
statement = statementFromStatementNode(statementNode, context);
|
|
343
351
|
}
|
|
344
352
|
|
|
345
353
|
return statement;
|
|
346
354
|
}
|
|
347
355
|
|
|
348
|
-
static
|
|
356
|
+
static fromSuppositionNode(suppositionNode, context) {
|
|
349
357
|
let statement = null;
|
|
350
358
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
statementNode = declarationNode.getStatementNode(); ///
|
|
359
|
+
const statementNode = suppositionNode.getStatementNode();
|
|
354
360
|
|
|
355
361
|
if (statementNode !== null) {
|
|
356
|
-
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
357
|
-
|
|
358
362
|
statement = statementFromStatementNode(statementNode, context);
|
|
359
363
|
}
|
|
360
364
|
|
package/src/ontology/step.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
4
|
import unifyMixins from "../mixins/step/unify";
|
|
5
|
-
import Substitutions from "../substitutions";
|
|
6
5
|
import TemporaryContext from "../context/temporary";
|
|
7
6
|
import equationalUnifier from "../unifier/equantional";
|
|
8
7
|
|
|
@@ -182,7 +181,8 @@ export default define(class Step {
|
|
|
182
181
|
axiom = context.findAxiomByReference(reference);
|
|
183
182
|
|
|
184
183
|
if (axiom !== null) {
|
|
185
|
-
const
|
|
184
|
+
const { Substitutions } = ontology,
|
|
185
|
+
step = this, ///
|
|
186
186
|
substitutions = Substitutions.fromNothing(),
|
|
187
187
|
stepUnifies = axiom.unifyStep(step, substitutions, context);
|
|
188
188
|
|
package/src/ontology/subproof.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
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";
|
|
@@ -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
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import ontology from "../../ontology";
|
|
3
4
|
import Substitution from "../substitution";
|
|
4
|
-
import Substitutions from "../../substitutions";
|
|
5
5
|
import StatementSubstitutionPartialContext from "../../context/partial/substitution/statement";
|
|
6
6
|
|
|
7
7
|
import { define } from "../../ontology";
|
|
@@ -67,7 +67,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
67
67
|
if (substitution === null) {
|
|
68
68
|
substitutionEqualToSubstitution = false;
|
|
69
69
|
} else {
|
|
70
|
-
substitutionEqualToSubstitution = this.substitution.
|
|
70
|
+
substitutionEqualToSubstitution = this.substitution.isEqualTo(substitution);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -76,16 +76,63 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
76
76
|
|
|
77
77
|
matchParameter(parameter) { return this.metavariable.matchParameter(parameter); }
|
|
78
78
|
|
|
79
|
+
resolve(substitutions, context) {
|
|
80
|
+
const substitutionString = this.string; ///
|
|
81
|
+
|
|
82
|
+
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
83
|
+
|
|
84
|
+
substitutions.snapshot();
|
|
85
|
+
|
|
86
|
+
const metavariable = this.getMetavariable(),
|
|
87
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable);
|
|
88
|
+
|
|
89
|
+
if (simpleSubstitution !== null) {
|
|
90
|
+
let context;
|
|
91
|
+
|
|
92
|
+
context = this.getContext();
|
|
93
|
+
|
|
94
|
+
const substitution = simpleSubstitution.unifyStatement(this.statement, context);
|
|
95
|
+
|
|
96
|
+
if (substitution !== null) {
|
|
97
|
+
context = simpleSubstitution.getContext();
|
|
98
|
+
|
|
99
|
+
const terms = context.getTerms(),
|
|
100
|
+
frames = context.getFrames();
|
|
101
|
+
|
|
102
|
+
context = substitution.getContext();
|
|
103
|
+
|
|
104
|
+
context.addTerms(terms);
|
|
105
|
+
|
|
106
|
+
context.addFrames(frames);
|
|
107
|
+
|
|
108
|
+
const substitutionUnifies = this.unifySubstitution(substitution, substitutions, context);
|
|
109
|
+
|
|
110
|
+
if (substitutionUnifies) {
|
|
111
|
+
this.resolved = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.resolved ?
|
|
117
|
+
substitutions.continue() :
|
|
118
|
+
substitutions.rollback(context);
|
|
119
|
+
|
|
120
|
+
if (this.resolved) {
|
|
121
|
+
context.debug(`...resolved the ${substitutionString} substitution.`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
79
125
|
unifyStatement(statement, context) {
|
|
80
126
|
let substitution = null;
|
|
81
127
|
|
|
82
|
-
const
|
|
83
|
-
|
|
128
|
+
const { Substitutions } = ontology,
|
|
129
|
+
substitutions = Substitutions.fromNothing(),
|
|
130
|
+
specificContext = context; ///
|
|
84
131
|
|
|
85
132
|
context = this.getContext();
|
|
86
133
|
|
|
87
|
-
const
|
|
88
|
-
statementUnifies = statement.unifyStatement(
|
|
134
|
+
const generalContext = context, ///
|
|
135
|
+
statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
89
136
|
|
|
90
137
|
if (statementUnifies) {
|
|
91
138
|
const substitutionsNonTrivialLength = substitutions.getNonTrivialLength();
|
|
@@ -101,8 +148,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
101
148
|
}
|
|
102
149
|
|
|
103
150
|
unifySubstitution(substitution, substitutions, context) {
|
|
104
|
-
const
|
|
105
|
-
generalSubstitution = this.substitution, ///
|
|
151
|
+
const generalSubstitution = this.substitution, ///
|
|
106
152
|
specificSubstitution = substitution, ///
|
|
107
153
|
generalSubstitutionString = generalSubstitution.getString(),
|
|
108
154
|
specificSubstitutionString = specificSubstitution.getString();
|
|
@@ -117,19 +163,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
117
163
|
|
|
118
164
|
substitutionContext = substitution.getContext();
|
|
119
165
|
|
|
120
|
-
const specificContext = substitutionContext
|
|
121
|
-
|
|
122
|
-
specificContext.addFrame(frame);
|
|
123
|
-
|
|
124
|
-
substitutions.snapshot();
|
|
125
|
-
|
|
126
|
-
const substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, substitutions, generalContext, specificContext);
|
|
127
|
-
|
|
128
|
-
specificContext.removeFrame(frame);
|
|
129
|
-
|
|
130
|
-
substitutionUnifies ?
|
|
131
|
-
substitutions.continue() :
|
|
132
|
-
substitutions.rollback(context);
|
|
166
|
+
const specificContext = substitutionContext, ///
|
|
167
|
+
substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, substitutions, generalContext, specificContext);
|
|
133
168
|
|
|
134
169
|
if (substitutionUnifies) {
|
|
135
170
|
context.trace(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
|
|
@@ -138,38 +173,6 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
138
173
|
return substitutionUnifies;
|
|
139
174
|
}
|
|
140
175
|
|
|
141
|
-
resolve(substitutions, context) {
|
|
142
|
-
const substitutionString = this.string; ///
|
|
143
|
-
|
|
144
|
-
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
145
|
-
|
|
146
|
-
const metavariable = this.getMetavariable(),
|
|
147
|
-
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable);
|
|
148
|
-
|
|
149
|
-
if (simpleSubstitution !== null) {
|
|
150
|
-
let substitution;
|
|
151
|
-
|
|
152
|
-
substitution = simpleSubstitution; ///
|
|
153
|
-
|
|
154
|
-
const context = substitution.getContext(),
|
|
155
|
-
statement = substitution.getStatement();
|
|
156
|
-
|
|
157
|
-
substitution = this.unifyStatement(statement, context);
|
|
158
|
-
|
|
159
|
-
if (substitution !== null) {
|
|
160
|
-
const substitutionUnifies = this.unifySubstitution(substitution, substitutions, context);
|
|
161
|
-
|
|
162
|
-
if (substitutionUnifies) {
|
|
163
|
-
this.resolved = true;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (this.resolved) {
|
|
169
|
-
context.debug(`...resolved the ${substitutionString} substitution.`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
176
|
toJSON() {
|
|
174
177
|
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
175
178
|
statementJSON = statementToStatementJSON(this.statement),
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import ontology from "../../ontology";
|
|
3
4
|
import Substitution from "../substitution";
|
|
4
5
|
import TermSubstitutionPartialContext from "../../context/partial/substitution/term";
|
|
5
6
|
|
|
6
|
-
import
|
|
7
|
-
import { nodeQuery } from "../../utilities/query";
|
|
7
|
+
import { define } from "../../ontology";
|
|
8
8
|
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
9
|
-
import {
|
|
9
|
+
import { termVariableIdentifierFromTermNode } from "../../utilities/variable";
|
|
10
10
|
|
|
11
|
-
const termVariableNodeQuery = nodeQuery("/term/variable!");
|
|
12
11
|
|
|
13
12
|
export default define(class TermSubstitution extends Substitution {
|
|
14
13
|
constructor(context, string, node, tokens, term, variable) {
|
|
@@ -49,31 +48,6 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
49
48
|
return termEqualToTerm;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
isTermVariableEqualToTerm(termVariable, context) {
|
|
53
|
-
let termVariableEqualToTerm = false;
|
|
54
|
-
|
|
55
|
-
const termNode = this.term.getNode();
|
|
56
|
-
|
|
57
|
-
let termVariableNode;
|
|
58
|
-
|
|
59
|
-
termVariableNode = termVariableNodeQuery(termNode);
|
|
60
|
-
|
|
61
|
-
if (termVariableNode !== null) {
|
|
62
|
-
const termVariableNodeA = termVariableNode; ///
|
|
63
|
-
|
|
64
|
-
termVariableNode = termVariable.getNode();
|
|
65
|
-
|
|
66
|
-
const termVariableNodeB = termVariableNode, ///
|
|
67
|
-
termVariableNodeAMatchesTermVariableNodeB = termVariableNodeA.match(termVariableNodeB);
|
|
68
|
-
|
|
69
|
-
if (termVariableNodeAMatchesTermVariableNodeB) {
|
|
70
|
-
termVariableEqualToTerm = true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return termVariableEqualToTerm;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
51
|
matchParameter(parameter) { return this.variable.matchParameter(parameter); }
|
|
78
52
|
|
|
79
53
|
verify(context) {
|
|
@@ -89,15 +63,15 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
89
63
|
if (this.variable === null) {
|
|
90
64
|
context.debug(`The specific term is not simple.`);
|
|
91
65
|
} else {
|
|
92
|
-
const
|
|
93
|
-
variablePresent = context.isVariablePresentByVariableIdentifier(
|
|
66
|
+
const variableIdentifier = this.variable.getIdentifier(),
|
|
67
|
+
variablePresent = context.isVariablePresentByVariableIdentifier(variableIdentifier);
|
|
94
68
|
|
|
95
69
|
if (variablePresent) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
70
|
+
const termNode = this.term.getNode(),
|
|
71
|
+
termVariableIdentifier = termVariableIdentifierFromTermNode(termNode),
|
|
72
|
+
termVariablePresent = context.isVariablePresentByVariableIdentifier(termVariableIdentifier);
|
|
99
73
|
|
|
100
|
-
if (
|
|
74
|
+
if (termVariablePresent) {
|
|
101
75
|
verifies = true;
|
|
102
76
|
} else {
|
|
103
77
|
const variableString = variable.getString();
|
|
@@ -66,6 +66,12 @@ export default class Substitution {
|
|
|
66
66
|
return substitution;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
getReplacementNode() {
|
|
70
|
+
const replacementNode = null;
|
|
71
|
+
|
|
72
|
+
return replacementNode;
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
isSimple() {
|
|
70
76
|
const simple = true;
|
|
71
77
|
|
|
@@ -104,12 +110,6 @@ export default class Substitution {
|
|
|
104
110
|
return frameEqualToFrame;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
isTermVariableEqualToTerm(termVariable, context) {
|
|
108
|
-
const termVariableEqualToTerm = false;
|
|
109
|
-
|
|
110
|
-
return termVariableEqualToTerm;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
113
|
isReferenceEqualToReference(reference, context) {
|
|
114
114
|
const referenceEqualToReference = false;
|
|
115
115
|
|
|
@@ -134,21 +134,17 @@ export default class Substitution {
|
|
|
134
134
|
return substitutionEqualToSubstitution;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
resolve(substitutions, context) {
|
|
138
|
-
const resolved = true;
|
|
139
|
-
|
|
140
|
-
return resolved;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
137
|
matchParameter(parameter) {
|
|
144
138
|
const parameterMatches = false;
|
|
145
139
|
|
|
146
140
|
return parameterMatches;
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
|
|
150
|
-
const replacementNode = null;
|
|
143
|
+
matchSubstitutionNode(substitutionNode) { return this.node.match(substitutionNode); }
|
|
151
144
|
|
|
152
|
-
|
|
145
|
+
resolve(substitutions, context) {
|
|
146
|
+
const resolved = true;
|
|
147
|
+
|
|
148
|
+
return resolved;
|
|
153
149
|
}
|
|
154
150
|
}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { define } from "../ontology";
|
|
6
|
+
import { EMPTY_STRING } from "../constants";
|
|
6
7
|
|
|
7
8
|
const { find, first, clear, prune, filter, compress, correlate } = arrayUtilities;
|
|
8
9
|
|
|
9
|
-
export default class Substitutions {
|
|
10
|
+
export default define(class Substitutions {
|
|
10
11
|
constructor(array, savedArray) {
|
|
11
12
|
this.array = array;
|
|
12
13
|
this.savedArray = savedArray;
|
|
@@ -357,7 +358,7 @@ export default class Substitutions {
|
|
|
357
358
|
|
|
358
359
|
return substitutions;
|
|
359
360
|
}
|
|
360
|
-
}
|
|
361
|
+
});
|
|
361
362
|
|
|
362
363
|
function leftDifference(arrayA, arrayB) {
|
|
363
364
|
filter(arrayA, (elementA) => {
|
|
@@ -112,18 +112,32 @@ export default define(class Supposition {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
unifyIndependently(substitutions, context) {
|
|
115
|
-
let unifiesIndependently;
|
|
115
|
+
let unifiesIndependently = false;
|
|
116
|
+
|
|
117
|
+
const suppositionString = this.string, ///
|
|
118
|
+
generalContext = this.context, ///
|
|
119
|
+
specificContext = context; ///
|
|
120
|
+
|
|
121
|
+
context.trace(`Unifying the '${suppositionString}' supposition independently...`, this.node);
|
|
116
122
|
|
|
117
123
|
if (this.statement !== null) {
|
|
118
|
-
const
|
|
124
|
+
const statementUnifiesIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
|
|
119
125
|
|
|
120
|
-
|
|
126
|
+
if (statementUnifiesIndependently) {
|
|
127
|
+
unifiesIndependently = true;
|
|
128
|
+
}
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
if (this.procedureCall !== null) {
|
|
124
132
|
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, context);
|
|
125
133
|
|
|
126
|
-
|
|
134
|
+
if (procedureCallResolvedIndependently) {
|
|
135
|
+
unifiesIndependently = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (unifiesIndependently) {
|
|
140
|
+
context.debug(`...unified the '${suppositionString}' supposition independenly.`, this.node);
|
|
127
141
|
}
|
|
128
142
|
|
|
129
143
|
return unifiesIndependently;
|