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
package/src/ontology/premise.js
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
|
+
import TemporaryContext from "../context/temporary";
|
|
4
5
|
|
|
5
6
|
import { define } from "../ontology";
|
|
6
7
|
import { assignAssignments } from "../utilities/assignments";
|
|
7
8
|
import { subproofAssertionFromStatement } from "../utilities/context";
|
|
8
|
-
import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
|
|
9
|
+
import { termsFromJSON, framesFromJSON, statementFromJSON, procedureCallFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
|
|
9
10
|
|
|
10
11
|
export default define(class Premise {
|
|
11
|
-
constructor(node, string, statement, procedureCall) {
|
|
12
|
+
constructor(context, node, string, statement, procedureCall) {
|
|
13
|
+
this.context = context;
|
|
12
14
|
this.node = node;
|
|
13
15
|
this.string = string;
|
|
14
16
|
this.statement = statement;
|
|
15
17
|
this.procedureCall = procedureCall;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
getContext() {
|
|
21
|
+
return this.context;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
getNode() {
|
|
19
25
|
return this.node;
|
|
20
26
|
}
|
|
@@ -34,6 +40,10 @@ export default define(class Premise {
|
|
|
34
40
|
verify(context) {
|
|
35
41
|
let verifies = false;
|
|
36
42
|
|
|
43
|
+
const temporaryContext = TemporaryContext.fromNothing(context);
|
|
44
|
+
|
|
45
|
+
context = temporaryContext; ///
|
|
46
|
+
|
|
37
47
|
const premiseString = this.string; ///
|
|
38
48
|
|
|
39
49
|
context.trace(`Verifying the '${premiseString}' premise...`, this.node);
|
|
@@ -71,6 +81,8 @@ export default define(class Premise {
|
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
if (verifies) {
|
|
84
|
+
this.context = context;
|
|
85
|
+
|
|
74
86
|
context.debug(`...verified the '${premiseString}' premise.`, this.node);
|
|
75
87
|
}
|
|
76
88
|
|
|
@@ -78,24 +90,38 @@ export default define(class Premise {
|
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
unifyIndependently(substitutions, context) {
|
|
81
|
-
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);
|
|
82
100
|
|
|
83
101
|
if (this.statement !== null) {
|
|
84
|
-
const
|
|
102
|
+
const statementUnifiesIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
|
|
85
103
|
|
|
86
|
-
|
|
104
|
+
if (statementUnifiesIndependently) {
|
|
105
|
+
unifiesIndependently = true;
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
|
|
89
109
|
if (this.procedureCall !== null) {
|
|
90
110
|
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, context);
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
if (procedureCallResolvedIndependently) {
|
|
113
|
+
unifiesIndependently = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (unifiesIndependently) {
|
|
118
|
+
context.debug(`...unified the '${premiseString}' premise independenly.`, this.node);
|
|
93
119
|
}
|
|
94
120
|
|
|
95
121
|
return unifiesIndependently;
|
|
96
122
|
}
|
|
97
123
|
|
|
98
|
-
unifyStepOrSubproof(stepOrSubproof, substitutions,
|
|
124
|
+
unifyStepOrSubproof(stepOrSubproof, substitutions, context) {
|
|
99
125
|
let stepOrSubproofUnifies = false;
|
|
100
126
|
|
|
101
127
|
const stepOrSubProofStep = stepOrSubproof.isStep(),
|
|
@@ -109,33 +135,35 @@ export default define(class Premise {
|
|
|
109
135
|
substitutions.snapshot();
|
|
110
136
|
|
|
111
137
|
if (subproof !== null) {
|
|
112
|
-
const subproofUnifies = this.unifySubproof(subproof, substitutions,
|
|
138
|
+
const subproofUnifies = this.unifySubproof(subproof, substitutions, context);
|
|
113
139
|
|
|
114
140
|
stepOrSubproofUnifies = subproofUnifies; ///
|
|
115
141
|
}
|
|
116
142
|
|
|
117
143
|
if (step !== null) {
|
|
118
|
-
const statementUnifies = this.unifyStep(step, substitutions,
|
|
144
|
+
const statementUnifies = this.unifyStep(step, substitutions, context);
|
|
119
145
|
|
|
120
146
|
stepOrSubproofUnifies = statementUnifies; ///
|
|
121
147
|
}
|
|
122
148
|
|
|
123
149
|
if (stepOrSubproofUnifies) {
|
|
124
|
-
substitutions.resolve(
|
|
150
|
+
substitutions.resolve(context);
|
|
125
151
|
}
|
|
126
152
|
|
|
127
153
|
stepOrSubproofUnifies ?
|
|
128
154
|
substitutions.continue() :
|
|
129
|
-
substitutions.rollback(
|
|
155
|
+
substitutions.rollback(context);
|
|
130
156
|
|
|
131
157
|
return stepOrSubproofUnifies;
|
|
132
158
|
}
|
|
133
159
|
|
|
134
|
-
unifyStep(step, substitutions,
|
|
160
|
+
unifyStep(step, substitutions, context) {
|
|
135
161
|
let stepUnifies = false;
|
|
136
162
|
|
|
163
|
+
context = step.getContext();
|
|
164
|
+
|
|
137
165
|
const statement = step.getStatement(),
|
|
138
|
-
statementUnifies = this.unifyStatement(statement, substitutions,
|
|
166
|
+
statementUnifies = this.unifyStatement(statement, substitutions, context);
|
|
139
167
|
|
|
140
168
|
if (statementUnifies) {
|
|
141
169
|
stepUnifies = true;
|
|
@@ -170,34 +198,53 @@ export default define(class Premise {
|
|
|
170
198
|
return subproofUnifies;
|
|
171
199
|
}
|
|
172
200
|
|
|
173
|
-
unifyStatement(statement, substitutions,
|
|
201
|
+
unifyStatement(statement, substitutions, context) {
|
|
174
202
|
let statementUnifies;
|
|
175
203
|
|
|
176
204
|
const premise = this, ///
|
|
177
205
|
premiseString = premise.getString(),
|
|
178
206
|
statementString = statement.getString();
|
|
179
207
|
|
|
180
|
-
|
|
208
|
+
context.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
181
209
|
|
|
182
210
|
if (this.statement !== null) {
|
|
211
|
+
const generalContext = this.context, ///
|
|
212
|
+
specificContext = context; ///
|
|
213
|
+
|
|
183
214
|
statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
184
215
|
}
|
|
185
216
|
|
|
186
217
|
if (statementUnifies) {
|
|
187
|
-
|
|
218
|
+
context.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
|
188
219
|
}
|
|
189
220
|
|
|
190
221
|
return statementUnifies;
|
|
191
222
|
}
|
|
192
223
|
|
|
193
224
|
toJSON() {
|
|
194
|
-
|
|
195
|
-
|
|
225
|
+
let frames,
|
|
226
|
+
terms;
|
|
227
|
+
|
|
228
|
+
frames = this.context.getFrames();
|
|
229
|
+
|
|
230
|
+
terms = this.context.getTerms();
|
|
231
|
+
|
|
232
|
+
const procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
|
|
233
|
+
statementJSON = statementToStatementJSON(this.statement),
|
|
234
|
+
framesJSON = framesToFramesJSON(frames),
|
|
235
|
+
termsJSON = termsToTermsJSON(terms);
|
|
236
|
+
|
|
237
|
+
frames = framesJSON; ///
|
|
238
|
+
|
|
239
|
+
terms = termsJSON; ///
|
|
240
|
+
|
|
241
|
+
const procedureCall = procedureCallJSON, ///
|
|
196
242
|
statement = statementJSON, ///
|
|
197
|
-
procedureCall = procedureCallJSON, ///
|
|
198
243
|
json = {
|
|
244
|
+
procedureCall,
|
|
199
245
|
statement,
|
|
200
|
-
|
|
246
|
+
frames,
|
|
247
|
+
terms
|
|
201
248
|
};
|
|
202
249
|
|
|
203
250
|
return json;
|
|
@@ -206,8 +253,11 @@ export default define(class Premise {
|
|
|
206
253
|
static name = "Premise";
|
|
207
254
|
|
|
208
255
|
static fromJSON(json, context) {
|
|
209
|
-
const
|
|
210
|
-
|
|
256
|
+
const terms = termsFromJSON(json, context),
|
|
257
|
+
frames = framesFromJSON(json, context),
|
|
258
|
+
statement = statementFromJSON(json, context),
|
|
259
|
+
procedureCall = procedureCallFromJSON(json, context),
|
|
260
|
+
temporaryContext = TemporaryContext.fromTermsAndFrames(terms, frames, context);
|
|
211
261
|
|
|
212
262
|
let string;
|
|
213
263
|
|
|
@@ -219,8 +269,11 @@ export default define(class Premise {
|
|
|
219
269
|
string = procedureCall.getString();
|
|
220
270
|
}
|
|
221
271
|
|
|
222
|
-
const node = null
|
|
223
|
-
|
|
272
|
+
const node = null;
|
|
273
|
+
|
|
274
|
+
context = temporaryContext; ///
|
|
275
|
+
|
|
276
|
+
const premise = new Premise(context, node, string, statement, procedureCall);
|
|
224
277
|
|
|
225
278
|
return premise;
|
|
226
279
|
}
|
|
@@ -231,7 +284,11 @@ export default define(class Premise {
|
|
|
231
284
|
string = context.nodeAsString(node),
|
|
232
285
|
statement = Statement.fromPremiseNode(premiseNode, context),
|
|
233
286
|
procedureCall = ProcedureCall.fromPremiseNode(premiseNode, context),
|
|
234
|
-
|
|
287
|
+
temporaryContext = null;
|
|
288
|
+
|
|
289
|
+
context = temporaryContext; ///
|
|
290
|
+
|
|
291
|
+
const premise = new Premise(context, node, string, statement, procedureCall);
|
|
235
292
|
|
|
236
293
|
return premise
|
|
237
294
|
}
|
|
@@ -8,29 +8,29 @@ import { define } from "../ontology";
|
|
|
8
8
|
import { parametersFromJSON, procedureReferenceFromJSON, parametersToParametersJSON, procedureReferenceToProcedureReferenceJSON } from "../utilities/json";
|
|
9
9
|
|
|
10
10
|
export default define(class ProcedureCall {
|
|
11
|
-
constructor(node,
|
|
12
|
-
this.node = node;
|
|
11
|
+
constructor(string, node, parameters, procedureReference) {
|
|
13
12
|
this.string = string;
|
|
14
|
-
this.
|
|
13
|
+
this.node = node;
|
|
15
14
|
this.parameters = parameters;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getNode() {
|
|
19
|
-
return this.node;
|
|
15
|
+
this.procedureReference = procedureReference;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
getString() {
|
|
23
19
|
return this.string;
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
return this.
|
|
22
|
+
getNode() {
|
|
23
|
+
return this.node;
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
getParameters() {
|
|
31
27
|
return this.parameters;
|
|
32
28
|
}
|
|
33
29
|
|
|
30
|
+
getProcedureReference() {
|
|
31
|
+
return this.procedureReference;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
34
|
getName() { return this.procedureReference.getName(); }
|
|
35
35
|
|
|
36
36
|
findNodes(substitutions) {
|
|
@@ -118,11 +118,11 @@ export default define(class ProcedureCall {
|
|
|
118
118
|
static name = "ProcedureCall";
|
|
119
119
|
|
|
120
120
|
static fromJSON(json, context) {
|
|
121
|
-
const
|
|
121
|
+
const node = null,
|
|
122
122
|
parameters = parametersFromJSON(json, context),
|
|
123
|
-
|
|
123
|
+
procedureReference = procedureReferenceFromJSON(json, context),
|
|
124
124
|
string = stringFromProcedureReferenceAndParameters(procedureReference, parameters),
|
|
125
|
-
procedureCall = new ProcedureCall(node,
|
|
125
|
+
procedureCall = new ProcedureCall(string, node, parameters, procedureReference);
|
|
126
126
|
|
|
127
127
|
return procedureCall;
|
|
128
128
|
}
|
|
@@ -155,10 +155,10 @@ export default define(class ProcedureCall {
|
|
|
155
155
|
function procedureCallFromProcedureCallNode(procedureCallNode, context) {
|
|
156
156
|
const { ProcedureCall, ProcedureReference } = ontology,
|
|
157
157
|
node = procedureCallNode, ///
|
|
158
|
-
procedureReference = ProcedureReference.fromProcedureCallNode(procedureCallNode, context),
|
|
159
158
|
parameters = parametersFromProcedureCallNode(procedureCallNode, context),
|
|
159
|
+
procedureReference = ProcedureReference.fromProcedureCallNode(procedureCallNode, context),
|
|
160
160
|
string = stringFromProcedureReferenceAndParameters(procedureReference, parameters),
|
|
161
|
-
procedureCall = new ProcedureCall(node,
|
|
161
|
+
procedureCall = new ProcedureCall(string, node, parameters, procedureReference);
|
|
162
162
|
|
|
163
163
|
return procedureCall;
|
|
164
164
|
}
|
|
@@ -25,6 +25,8 @@ export default define(class ProcedureReference {
|
|
|
25
25
|
return json;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
static name = "ProcedureReference";
|
|
29
|
+
|
|
28
30
|
static fromJSON(json, context) {
|
|
29
31
|
const { name } = json,
|
|
30
32
|
string = name, ///
|
|
@@ -33,8 +35,6 @@ export default define(class ProcedureReference {
|
|
|
33
35
|
return procedureReference;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
static name = "ProcedureReference";
|
|
37
|
-
|
|
38
38
|
static fromProcedureCallNode(procedureCallNode, context) {
|
|
39
39
|
const procedureName = procedureCallNode.getProcedureName(),
|
|
40
40
|
name = procedureName, ///
|
package/src/ontology/proof.js
CHANGED
|
@@ -27,7 +27,7 @@ export default define(class Proof {
|
|
|
27
27
|
verify(substitutions, conclusion, context) {
|
|
28
28
|
let verifies = false;
|
|
29
29
|
|
|
30
|
-
const localContext = LocalContext.
|
|
30
|
+
const localContext = LocalContext.fromNothing(context); ///
|
|
31
31
|
|
|
32
32
|
context = localContext; ///
|
|
33
33
|
|
|
@@ -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";
|
|
@@ -33,12 +32,7 @@ export default define(class Reference {
|
|
|
33
32
|
return metavariableNode;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
const equalTo = this.metavariable.isEqualTo(metavariable),
|
|
38
|
-
metavariableEqualTo = equalTo; ///
|
|
39
|
-
|
|
40
|
-
return metavariableEqualTo;
|
|
41
|
-
}
|
|
35
|
+
isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
|
|
42
36
|
|
|
43
37
|
matchMetavariableName(metavariableName) { return this.metavariable.matchMetavariableName(metavariableName); }
|
|
44
38
|
|
|
@@ -120,7 +114,8 @@ export default define(class Reference {
|
|
|
120
114
|
|
|
121
115
|
context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
|
|
122
116
|
|
|
123
|
-
const
|
|
117
|
+
const { Substitutions } = ontology,
|
|
118
|
+
substitutions = Substitutions.fromNothing(),
|
|
124
119
|
generalContext = context, ///
|
|
125
120
|
specificContext = context, ///
|
|
126
121
|
generalMetavariable = this.metavariable, ///
|
|
@@ -145,7 +140,8 @@ export default define(class Reference {
|
|
|
145
140
|
|
|
146
141
|
context.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${referenceString}' reference...`);
|
|
147
142
|
|
|
148
|
-
const
|
|
143
|
+
const { Substitutions } = ontology,
|
|
144
|
+
label = metaLemmaMetatheorem.getLabel(),
|
|
149
145
|
substitutions = Substitutions.fromNothing(),
|
|
150
146
|
labelUnifies = this.unifyLabel(label, substitutions, context);
|
|
151
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";
|
|
@@ -68,85 +67,6 @@ export default define(class Rule {
|
|
|
68
67
|
return metavariableNameMatches;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context) {
|
|
72
|
-
let statementAndStepsOrSubproofsUnify = false;
|
|
73
|
-
|
|
74
|
-
const generalContext = this.context, ///
|
|
75
|
-
specificContext = context; ///
|
|
76
|
-
|
|
77
|
-
const substitutions = Substitutions.fromNothing(),
|
|
78
|
-
statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, generalContext, specificContext);
|
|
79
|
-
|
|
80
|
-
if (statementUnifiesWithConclusion) {
|
|
81
|
-
const stepsOrSubproofsUnifyWithPremises = this.unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, generalContext, specificContext);
|
|
82
|
-
|
|
83
|
-
if (stepsOrSubproofsUnifyWithPremises) {
|
|
84
|
-
const substitutionsResolved = substitutions.areResolved();
|
|
85
|
-
|
|
86
|
-
if (substitutionsResolved) {
|
|
87
|
-
statementAndStepsOrSubproofsUnify = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return statementAndStepsOrSubproofsUnify;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
unifyStatementWithConclusion(statement, substitutions, generalContext, specificContext) {
|
|
96
|
-
let statementUnifiesWithConclusion = false;
|
|
97
|
-
|
|
98
|
-
const statementUnifies = this.conclusion.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
99
|
-
|
|
100
|
-
if (statementUnifies) {
|
|
101
|
-
statementUnifiesWithConclusion = true;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return statementUnifiesWithConclusion;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, generalContext, specificContext) {
|
|
108
|
-
stepsOrSubproofs = reverse(stepsOrSubproofs); ///
|
|
109
|
-
|
|
110
|
-
const stepsOrSubproofsUnifyWithPremises = backwardsEvery(this.premises, (premise) => {
|
|
111
|
-
const stepUnifiesWithPremise = this.unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, generalContext, specificContext);
|
|
112
|
-
|
|
113
|
-
if (stepUnifiesWithPremise) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
return stepsOrSubproofsUnifyWithPremises;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, generalContext, specificContext) {
|
|
122
|
-
let stepsOrSubproofsUnifyWithPremise = false;
|
|
123
|
-
|
|
124
|
-
if (!stepsOrSubproofsUnifyWithPremise) {
|
|
125
|
-
const context = specificContext, ///
|
|
126
|
-
premiseUnifiesIndependently = premise.unifyIndependently(substitutions, context);
|
|
127
|
-
|
|
128
|
-
if (premiseUnifiesIndependently) {
|
|
129
|
-
stepsOrSubproofsUnifyWithPremise = true;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (!stepsOrSubproofsUnifyWithPremise) {
|
|
134
|
-
const stepOrSubproof = extract(stepsOrSubproofs, (stepOrSubproof) => {
|
|
135
|
-
const stepOrSubproofUnifies = premise.unifyStepOrSubproof(stepOrSubproof, substitutions, generalContext, specificContext);
|
|
136
|
-
|
|
137
|
-
if (stepOrSubproofUnifies) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
}) || null;
|
|
141
|
-
|
|
142
|
-
if (stepOrSubproof !== null) {
|
|
143
|
-
stepsOrSubproofsUnifyWithPremise = true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return stepsOrSubproofsUnifyWithPremise;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
70
|
verify() {
|
|
151
71
|
let verifies = false;
|
|
152
72
|
|
|
@@ -157,7 +77,7 @@ export default define(class Rule {
|
|
|
157
77
|
const labelsVerify = this.verifyLabels();
|
|
158
78
|
|
|
159
79
|
if (labelsVerify) {
|
|
160
|
-
const localContext = LocalContext.
|
|
80
|
+
const localContext = LocalContext.fromNothing(this.context),
|
|
161
81
|
context = localContext, ///
|
|
162
82
|
premisesVerify = this.verifyPremises(context);
|
|
163
83
|
|
|
@@ -228,7 +148,8 @@ export default define(class Rule {
|
|
|
228
148
|
if (this.proof === null) {
|
|
229
149
|
proofVerifies = true;
|
|
230
150
|
} else {
|
|
231
|
-
const
|
|
151
|
+
const { Substitutions } = ontology,
|
|
152
|
+
substitutions = Substitutions.fromNothing();
|
|
232
153
|
|
|
233
154
|
proofVerifies = this.proof.verify(substitutions, this.conclusion, context);
|
|
234
155
|
}
|
|
@@ -236,6 +157,82 @@ export default define(class Rule {
|
|
|
236
157
|
return proofVerifies;
|
|
237
158
|
}
|
|
238
159
|
|
|
160
|
+
unifyStatementWithConclusion(statement, substitutions, context) {
|
|
161
|
+
let statementUnifiesWithConclusion = false;
|
|
162
|
+
|
|
163
|
+
const statementUnifies = this.conclusion.unifyStatement(statement, substitutions, context);
|
|
164
|
+
|
|
165
|
+
if (statementUnifies) {
|
|
166
|
+
statementUnifiesWithConclusion = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return statementUnifiesWithConclusion;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context) {
|
|
173
|
+
let statementAndStepsOrSubproofsUnify = false;
|
|
174
|
+
|
|
175
|
+
const { Substitutions } = ontology,
|
|
176
|
+
substitutions = Substitutions.fromNothing(),
|
|
177
|
+
statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, context);
|
|
178
|
+
|
|
179
|
+
if (statementUnifiesWithConclusion) {
|
|
180
|
+
const stepsOrSubproofsUnifiesWithPremises = this.unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, context);
|
|
181
|
+
|
|
182
|
+
if (stepsOrSubproofsUnifiesWithPremises) {
|
|
183
|
+
const substitutionsResolved = substitutions.areResolved();
|
|
184
|
+
|
|
185
|
+
if (substitutionsResolved) {
|
|
186
|
+
statementAndStepsOrSubproofsUnify = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return statementAndStepsOrSubproofsUnify;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, context) {
|
|
195
|
+
let stepsOrSubproofsUnifiesWithPremise = false;
|
|
196
|
+
|
|
197
|
+
if (!stepsOrSubproofsUnifiesWithPremise) {
|
|
198
|
+
const premiseUnifiesIndependently = premise.unifyIndependently(substitutions, context);
|
|
199
|
+
|
|
200
|
+
if (premiseUnifiesIndependently) {
|
|
201
|
+
stepsOrSubproofsUnifiesWithPremise = true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!stepsOrSubproofsUnifiesWithPremise) {
|
|
206
|
+
const stepOrSubproof = extract(stepsOrSubproofs, (stepOrSubproof) => {
|
|
207
|
+
const stepOrSubproofUnifies = premise.unifyStepOrSubproof(stepOrSubproof, substitutions, context);
|
|
208
|
+
|
|
209
|
+
if (stepOrSubproofUnifies) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}) || null;
|
|
213
|
+
|
|
214
|
+
if (stepOrSubproof !== null) {
|
|
215
|
+
stepsOrSubproofsUnifiesWithPremise = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return stepsOrSubproofsUnifiesWithPremise;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, context) {
|
|
223
|
+
stepsOrSubproofs = reverse(stepsOrSubproofs); ///
|
|
224
|
+
|
|
225
|
+
const stepsOrSubproofsUnifiesWithPremises = backwardsEvery(this.premises, (premise) => {
|
|
226
|
+
const stepUnifiesWithPremise = this.unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, context);
|
|
227
|
+
|
|
228
|
+
if (stepUnifiesWithPremise) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
return stepsOrSubproofsUnifiesWithPremises;
|
|
234
|
+
}
|
|
235
|
+
|
|
239
236
|
toJSON() {
|
|
240
237
|
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
241
238
|
premisesJSON = premisesToPremisesJSON(this.premises),
|
package/src/ontology/section.js
CHANGED
|
@@ -91,7 +91,7 @@ export default define(class Section {
|
|
|
91
91
|
static name = "Section";
|
|
92
92
|
|
|
93
93
|
static fromSectionNode(sectionNode, context) {
|
|
94
|
-
const localContext = LocalContext.
|
|
94
|
+
const localContext = LocalContext.fromNothing(context);
|
|
95
95
|
|
|
96
96
|
context = localContext; ///
|
|
97
97
|
|
|
@@ -71,7 +71,7 @@ export default define(class Signature {
|
|
|
71
71
|
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
72
72
|
substitution = termSubstitution; ///
|
|
73
73
|
|
|
74
|
-
substitutions.addSubstitution(substitution,
|
|
74
|
+
substitutions.addSubstitution(substitution, context);
|
|
75
75
|
|
|
76
76
|
return true;
|
|
77
77
|
}
|