occam-verify-cli 1.0.444 → 1.0.457
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/constants.js +1 -5
- package/lib/context/file.js +54 -82
- package/lib/context/fragment.js +77 -0
- package/lib/context/release.js +5 -9
- package/lib/context/scoped.js +314 -0
- package/lib/context/transient.js +371 -0
- package/lib/element/assumption.js +71 -84
- package/lib/element/combinator/bracketed.js +1 -10
- package/lib/element/conclusion.js +11 -8
- package/lib/element/constructor/bracketed.js +1 -10
- package/lib/element/declaration/combinator.js +1 -2
- package/lib/element/declaration/metavariable.js +3 -3
- package/lib/element/declaration/variable.js +3 -3
- package/lib/element/deduction.js +18 -13
- package/lib/element/derivation.js +14 -14
- package/lib/element/frame.js +40 -46
- package/lib/element/hypothesis.js +14 -55
- package/lib/element/judgement.js +35 -56
- package/lib/element/metaType.js +5 -4
- package/lib/element/metavariable.js +14 -10
- package/lib/element/proof.js +10 -10
- package/lib/element/proofAssertion/premise.js +308 -0
- package/lib/element/proofAssertion/step.js +305 -0
- package/lib/element/proofAssertion/supposition.js +322 -0
- package/lib/element/proofAssertion.js +199 -0
- package/lib/element/reference.js +28 -25
- package/lib/element/rule.js +29 -29
- package/lib/element/section.js +4 -4
- package/lib/element/statement.js +9 -14
- package/lib/element/subDerivation.js +14 -14
- package/lib/element/subproof.js +14 -14
- package/lib/element/substitution/frame.js +7 -7
- package/lib/element/substitution/statement.js +15 -39
- package/lib/element/substitution.js +5 -5
- package/lib/element/term.js +12 -10
- package/lib/element/topLevelAssertion/axiom.js +329 -0
- package/lib/element/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
- package/lib/element/{lemma.js → topLevelAssertion/lemma.js} +6 -6
- package/lib/element/{theorem.js → topLevelAssertion/theorem.js} +7 -7
- package/lib/element/topLevelAssertion.js +427 -0
- package/lib/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
- package/lib/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
- package/lib/element/topLevelMetaAssertion.js +289 -0
- package/lib/element/type.js +4 -4
- package/lib/element/variable.js +20 -20
- package/lib/metaTypes.js +33 -19
- package/lib/node/proofAssertion/premise.js +116 -0
- package/lib/node/proofAssertion/step.js +152 -0
- package/lib/node/proofAssertion/supposition.js +116 -0
- package/lib/node/{premise.js → proofAssertion.js} +11 -18
- package/lib/node/statement.js +2 -2
- package/lib/node/subDerivation.js +1 -8
- package/lib/node/subproof.js +1 -8
- package/lib/node/substitution/statement.js +2 -2
- package/lib/node/{axiom.js → topLevelAssertion/axiom.js} +7 -7
- package/lib/node/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
- package/lib/node/{lemma.js → topLevelAssertion/lemma.js} +7 -7
- package/lib/node/{theorem.js → topLevelAssertion/theorem.js} +7 -7
- package/lib/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +9 -9
- package/lib/node/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
- package/lib/node/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
- package/lib/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +9 -9
- package/lib/nonTerminalNodeMap.js +13 -13
- package/lib/preamble.js +10 -10
- package/lib/process/instantiate.js +6 -9
- package/lib/process/unify.js +7 -6
- package/lib/types.js +3 -3
- package/lib/utilities/bnf.js +5 -5
- package/lib/utilities/brackets.js +6 -11
- package/lib/utilities/context.js +28 -0
- package/lib/utilities/element.js +101 -99
- package/lib/utilities/fragment.js +23 -0
- package/lib/utilities/instance.js +12 -21
- package/lib/utilities/json.js +3 -2
- package/lib/utilities/string.js +44 -23
- package/lib/utilities/unification.js +36 -36
- package/lib/utilities/validation.js +22 -25
- package/package.json +6 -6
- package/src/constants.js +0 -1
- package/src/context/file.js +51 -58
- package/src/context/fragment.js +38 -0
- package/src/context/release.js +6 -11
- package/src/context/{local.js → scoped.js} +35 -127
- package/src/context/{temporary.js → transient.js} +9 -131
- package/src/element/assumption.js +69 -85
- package/src/element/combinator/bracketed.js +0 -7
- package/src/element/conclusion.js +14 -10
- package/src/element/constructor/bracketed.js +0 -7
- package/src/element/declaration/combinator.js +0 -1
- package/src/element/declaration/metavariable.js +2 -2
- package/src/element/declaration/variable.js +5 -5
- package/src/element/deduction.js +22 -15
- package/src/element/derivation.js +12 -12
- package/src/element/frame.js +36 -48
- package/src/element/hypothesis.js +14 -16
- package/src/element/judgement.js +33 -58
- package/src/element/metaType.js +4 -4
- package/src/element/metavariable.js +17 -10
- package/src/element/proof.js +9 -9
- package/src/element/{premise.js → proofAssertion/premise.js} +107 -75
- package/src/element/{step.js → proofAssertion/step.js} +43 -89
- package/src/element/{supposition.js → proofAssertion/supposition.js} +89 -88
- package/src/element/proofAssertion.js +69 -0
- package/src/element/reference.js +27 -23
- package/src/element/rule.js +25 -25
- package/src/element/section.js +4 -4
- package/src/element/statement.js +8 -15
- package/src/element/subDerivation.js +12 -12
- package/src/element/subproof.js +10 -10
- package/src/element/substitution/frame.js +10 -13
- package/src/element/substitution/statement.js +20 -52
- package/src/element/substitution.js +3 -3
- package/src/element/term.js +10 -9
- package/src/element/{axiom.js → topLevelAssertion/axiom.js} +41 -41
- package/src/element/{conjecture.js → topLevelAssertion/conjecture.js} +4 -4
- package/src/element/{lemma.js → topLevelAssertion/lemma.js} +3 -3
- package/src/element/{theorem.js → topLevelAssertion/theorem.js} +4 -4
- package/src/element/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +30 -49
- package/src/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +4 -4
- package/src/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +4 -4
- package/src/element/{metaLemmaMetatheorem.js → topLevelMetaAssertion.js} +7 -72
- package/src/element/type.js +2 -4
- package/src/element/variable.js +17 -17
- package/src/metaTypes.js +42 -13
- package/src/node/proofAssertion/premise.js +16 -0
- package/src/node/{step.js → proofAssertion/step.js} +4 -18
- package/src/node/proofAssertion/supposition.js +16 -0
- package/src/node/proofAssertion.js +23 -0
- package/src/node/statement.js +1 -1
- package/src/node/subDerivation.js +0 -7
- package/src/node/subproof.js +0 -7
- package/src/node/substitution/statement.js +1 -1
- package/src/node/topLevelAssertion/axiom.js +13 -0
- package/src/node/topLevelAssertion/conjecture.js +13 -0
- package/src/node/topLevelAssertion/lemma.js +13 -0
- package/src/node/topLevelAssertion/theorem.js +13 -0
- package/src/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +1 -1
- package/src/node/topLevelMetaAssertion/metaLemma.js +13 -0
- package/src/node/topLevelMetaAssertion/metatheorem.js +13 -0
- package/src/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +1 -1
- package/src/nonTerminalNodeMap.js +12 -12
- package/src/preamble.js +9 -9
- package/src/process/instantiate.js +31 -32
- package/src/process/unify.js +6 -5
- package/src/types.js +4 -2
- package/src/utilities/bnf.js +3 -2
- package/src/utilities/brackets.js +5 -8
- package/src/utilities/context.js +20 -0
- package/src/utilities/element.js +169 -162
- package/src/utilities/fragment.js +11 -0
- package/src/utilities/instance.js +19 -24
- package/src/utilities/json.js +3 -1
- package/src/utilities/string.js +57 -32
- package/src/utilities/unification.js +39 -39
- package/src/utilities/validation.js +26 -35
- package/lib/context/local.js +0 -605
- package/lib/context/temporary.js +0 -752
- package/lib/element/axiom.js +0 -329
- package/lib/element/axiomLemmaTheoremConjecture.js +0 -434
- package/lib/element/metaLemmaMetatheorem.js +0 -322
- package/lib/element/premise.js +0 -380
- package/lib/element/step.js +0 -390
- package/lib/element/supposition.js +0 -410
- package/lib/node/step.js +0 -166
- package/lib/node/supposition.js +0 -130
- package/src/node/axiom.js +0 -13
- package/src/node/conjecture.js +0 -13
- package/src/node/lemma.js +0 -13
- package/src/node/metaLemma.js +0 -13
- package/src/node/metatheorem.js +0 -13
- package/src/node/premise.js +0 -30
- package/src/node/supposition.js +0 -30
- package/src/node/theorem.js +0 -13
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import assignAssignments from "../process/assign";
|
|
3
|
+
import ProofAssertion from "../proofAssertion";
|
|
4
|
+
import TransientContext from "../../context/transient";
|
|
5
|
+
import assignAssignments from "../../process/assign";
|
|
7
6
|
|
|
8
|
-
import { define } from "
|
|
9
|
-
import { termsFromJSON, framesFromJSON, statementFromJSON, procedureCallFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "
|
|
7
|
+
import { define } from "../../elements";
|
|
8
|
+
import { termsFromJSON, framesFromJSON, statementFromJSON, procedureCallFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../../utilities/json";
|
|
10
9
|
|
|
11
|
-
export default define(class Supposition extends
|
|
10
|
+
export default define(class Supposition extends ProofAssertion {
|
|
12
11
|
constructor(context, string, node, statement, procedureCall) {
|
|
13
|
-
super(context, string, node);
|
|
12
|
+
super(context, string, node, statement);
|
|
14
13
|
|
|
15
|
-
this.statement = statement;
|
|
16
14
|
this.procedureCall = procedureCall;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
getStatement() {
|
|
20
|
-
return this.statement;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
17
|
getProcedureCall() {
|
|
24
18
|
return this.procedureCall;
|
|
25
19
|
}
|
|
@@ -27,32 +21,32 @@ export default define(class Supposition extends Element {
|
|
|
27
21
|
verify(context) {
|
|
28
22
|
let verifies = false;
|
|
29
23
|
|
|
30
|
-
const
|
|
24
|
+
const transientContext = TransientContext.fromNothing(context);
|
|
31
25
|
|
|
32
|
-
context =
|
|
26
|
+
context = transientContext; ///
|
|
33
27
|
|
|
34
28
|
const node = this.getNode(),
|
|
35
29
|
suppositionString = this.getString(); ///
|
|
36
30
|
|
|
37
31
|
context.trace(`Verifying the '${suppositionString}' supposition...`, node);
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
const statement = this.getStatement();
|
|
34
|
+
|
|
35
|
+
if ((statement === null) && (this.procedureCall === null)) {
|
|
40
36
|
context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`, node);
|
|
41
37
|
} else {
|
|
42
|
-
if (
|
|
38
|
+
if (statement !== null) {
|
|
43
39
|
const stated = true,
|
|
44
40
|
assignments = [],
|
|
45
|
-
statementValidates =
|
|
41
|
+
statementValidates = statement.validate(assignments, stated, context);
|
|
46
42
|
|
|
47
43
|
if (statementValidates) {
|
|
48
44
|
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
49
45
|
|
|
50
46
|
if (assignmentsAssigned) {
|
|
51
|
-
const
|
|
52
|
-
step = Step.fromStatement(this.statement, context),
|
|
53
|
-
stepOrSubproof = step; ///
|
|
47
|
+
const subproofOrProofAssertion = this; ///
|
|
54
48
|
|
|
55
|
-
context.
|
|
49
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
56
50
|
|
|
57
51
|
verifies = true;
|
|
58
52
|
}
|
|
@@ -82,10 +76,9 @@ export default define(class Supposition extends Element {
|
|
|
82
76
|
unifyIndependently(substitutions, context) {
|
|
83
77
|
let unifiesIndependently = false;
|
|
84
78
|
|
|
85
|
-
const
|
|
86
|
-
suppositionString = this.getString();
|
|
79
|
+
const suppositionString = this.getString();
|
|
87
80
|
|
|
88
|
-
context.trace(`Unifying the '${suppositionString}' supposition independently
|
|
81
|
+
context.trace(`Unifying the '${suppositionString}' supposition independently...`);
|
|
89
82
|
|
|
90
83
|
const specificContext = context; ///
|
|
91
84
|
|
|
@@ -95,8 +88,10 @@ export default define(class Supposition extends Element {
|
|
|
95
88
|
|
|
96
89
|
context = specificContext; ///
|
|
97
90
|
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
const statement = this.getStatement();
|
|
92
|
+
|
|
93
|
+
if (statement !== null) {
|
|
94
|
+
const statementUnifiesIndependently = statement.unifyIndependently(substitutions, generalContext, specificContext);
|
|
100
95
|
|
|
101
96
|
if (statementUnifiesIndependently) {
|
|
102
97
|
unifiesIndependently = true;
|
|
@@ -112,119 +107,125 @@ export default define(class Supposition extends Element {
|
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
if (unifiesIndependently) {
|
|
115
|
-
context.debug(`...unified the '${suppositionString}' supposition independenly
|
|
110
|
+
context.debug(`...unified the '${suppositionString}' supposition independenly.`);
|
|
116
111
|
}
|
|
117
112
|
|
|
118
113
|
return unifiesIndependently;
|
|
119
114
|
}
|
|
120
115
|
|
|
121
|
-
|
|
122
|
-
let
|
|
116
|
+
unifySubproofOrProosAssertion(subproofOrProofAssertion, substitutions, context) {
|
|
117
|
+
let subproofOrProofAssertionUnifies = false;
|
|
123
118
|
|
|
124
|
-
const
|
|
125
|
-
subproof =
|
|
119
|
+
const subproofOrProofAssertionProofAssertion = subproofOrProofAssertion.isProofAssertion(),
|
|
120
|
+
subproof = subproofOrProofAssertionProofAssertion ?
|
|
126
121
|
null :
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
subproofOrProofAssertion,
|
|
123
|
+
proofAssertion = subproofOrProofAssertionProofAssertion ?
|
|
124
|
+
subproofOrProofAssertion :
|
|
125
|
+
null;
|
|
131
126
|
|
|
132
127
|
substitutions.snapshot();
|
|
133
128
|
|
|
134
129
|
if (subproof !== null) {
|
|
135
130
|
const subproofUnifies = this.unifySubproof(subproof, substitutions, context);
|
|
136
131
|
|
|
137
|
-
|
|
132
|
+
if (subproofUnifies) {
|
|
133
|
+
subproofOrProofAssertionUnifies = true;
|
|
134
|
+
}
|
|
138
135
|
}
|
|
139
136
|
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
137
|
+
if (proofAssertion !== null) {
|
|
138
|
+
const proofAssertionUnifies = this.unifyProofAssertion(proofAssertion, substitutions, context);
|
|
142
139
|
|
|
143
|
-
|
|
140
|
+
if (proofAssertionUnifies) {
|
|
141
|
+
subproofOrProofAssertionUnifies = true;
|
|
142
|
+
}
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
if (
|
|
145
|
+
if (subproofOrProofAssertionUnifies) {
|
|
147
146
|
substitutions.resolve(context);
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
|
|
149
|
+
subproofOrProofAssertionUnifies ?
|
|
151
150
|
substitutions.continue() :
|
|
152
151
|
substitutions.rollback(context);
|
|
153
152
|
|
|
154
|
-
return
|
|
153
|
+
return subproofOrProofAssertionUnifies;
|
|
155
154
|
}
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
let
|
|
156
|
+
unifyProofAssertion(proofAssertion, substitutions, context) {
|
|
157
|
+
let proofAssertionUnifies = false;
|
|
159
158
|
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
suppositionStatement = supposition.getStatement(),
|
|
163
|
-
suppositionStatementString = suppositionStatement.getString();
|
|
164
|
-
|
|
165
|
-
context.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
159
|
+
const suppositionString = this.getString(),
|
|
160
|
+
proofAssertionString = proofAssertion.getString();
|
|
166
161
|
|
|
167
|
-
|
|
162
|
+
context.trace(`Unifying the '${proofAssertionString}' proof assertion with the '${suppositionString}' supposition...`);
|
|
168
163
|
|
|
169
164
|
context = this.getContext();
|
|
170
165
|
|
|
171
|
-
const generalContext = context;
|
|
166
|
+
const generalContext = context; ///
|
|
172
167
|
|
|
173
|
-
context =
|
|
168
|
+
context = proofAssertion.getContext();
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
const node = this.getNode(),
|
|
177
|
-
assertionNode = node, ///
|
|
178
|
-
assertion = context.findAssertionByAssertionNode(assertionNode);
|
|
170
|
+
const specificContext = context; ///
|
|
179
171
|
|
|
180
|
-
|
|
172
|
+
context = specificContext; ///
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
174
|
+
const statement = proofAssertion.getStatement(),
|
|
175
|
+
statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
176
|
+
|
|
177
|
+
if (statementUnifies) {
|
|
178
|
+
proofAssertionUnifies = true;
|
|
185
179
|
}
|
|
186
180
|
|
|
187
|
-
if (
|
|
188
|
-
context.debug(`...unified the '${
|
|
181
|
+
if (proofAssertionUnifies) {
|
|
182
|
+
context.debug(`...unified the '${proofAssertionString}' proof assertion with the '${suppositionString}' supposition.`);
|
|
189
183
|
}
|
|
190
184
|
|
|
191
|
-
return
|
|
185
|
+
return proofAssertionUnifies;
|
|
192
186
|
}
|
|
193
187
|
|
|
194
|
-
|
|
195
|
-
let
|
|
188
|
+
unifySubproof(subproof, substitutions, context) {
|
|
189
|
+
let subproofUnifies = false;
|
|
196
190
|
|
|
197
|
-
|
|
191
|
+
const node = this.getNode(),
|
|
192
|
+
subproofString = subproof.getString(),
|
|
193
|
+
suppositionString = this.getString();
|
|
198
194
|
|
|
199
|
-
|
|
200
|
-
statementUnifies = this.unifyStatement(statement, substitutions, context);
|
|
195
|
+
context.trace(`Unifying the '${subproofString}' subproof with the '${suppositionString}' supposition...`, node);
|
|
201
196
|
|
|
202
|
-
|
|
197
|
+
const specificContext = context; ///
|
|
203
198
|
|
|
204
|
-
|
|
205
|
-
}
|
|
199
|
+
context = this.getContext();
|
|
206
200
|
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
const generalContext = context; ///
|
|
202
|
+
|
|
203
|
+
context = specificContext; ///
|
|
209
204
|
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
205
|
+
const statement = this.getStatement();
|
|
206
|
+
|
|
207
|
+
if (statement !== null) {
|
|
208
|
+
const statementNode = statement.getNode(),
|
|
209
|
+
subproofAssertionNode = statementNode.getSubproofAssertionNode();
|
|
213
210
|
|
|
214
|
-
|
|
211
|
+
if (subproofAssertionNode !== null) {
|
|
212
|
+
const context = generalContext, ///
|
|
213
|
+
assertionNode = subproofAssertionNode, ///
|
|
214
|
+
assertion = context.findAssertionByAssertionNode(assertionNode)
|
|
215
215
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
specificContext = context; ///
|
|
216
|
+
if (assertion !== null) {
|
|
217
|
+
const subproofAssertion = assertion; ///
|
|
219
218
|
|
|
220
|
-
|
|
219
|
+
subproofUnifies = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
if (
|
|
224
|
-
context.debug(`...unified the '${
|
|
224
|
+
if (subproofUnifies) {
|
|
225
|
+
context.debug(`...unified the '${subproofString}' subproof with the '${suppositionString}' supposition.`, node);
|
|
225
226
|
}
|
|
226
227
|
|
|
227
|
-
return
|
|
228
|
+
return subproofUnifies;
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
unifySupposition(supposition, substitutions, generalContext, specificContext) {
|
|
@@ -286,7 +287,7 @@ export default define(class Supposition extends Element {
|
|
|
286
287
|
frames = framesFromJSON(json, context),
|
|
287
288
|
statement = statementFromJSON(json, context),
|
|
288
289
|
procedureCall = procedureCallFromJSON(json, context),
|
|
289
|
-
|
|
290
|
+
transientContext = TransientContext.fromTermsAndFrames(terms, frames, context);
|
|
290
291
|
|
|
291
292
|
let string;
|
|
292
293
|
|
|
@@ -300,7 +301,7 @@ export default define(class Supposition extends Element {
|
|
|
300
301
|
|
|
301
302
|
const node = null;
|
|
302
303
|
|
|
303
|
-
context =
|
|
304
|
+
context = transientContext; ///
|
|
304
305
|
|
|
305
306
|
const supposition = new Supposition(context, string, node, statement, procedureCall);
|
|
306
307
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Element from "../element";
|
|
4
|
+
|
|
5
|
+
import { equateStatements } from "../process/equate";
|
|
6
|
+
|
|
7
|
+
export default class ProofAssertion extends Element {
|
|
8
|
+
constructor(context, string, node, statement) {
|
|
9
|
+
super(context, string, node);
|
|
10
|
+
|
|
11
|
+
this.statement = statement;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getStatement() {
|
|
15
|
+
return this.statement;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
isProofAssertion() {
|
|
19
|
+
const proofAssertion = true;
|
|
20
|
+
|
|
21
|
+
return proofAssertion;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
compareStatement(statement, context) {
|
|
25
|
+
let comparesToStatement = false;
|
|
26
|
+
|
|
27
|
+
const statementString = statement.getString(),
|
|
28
|
+
proofAssertionString = this.getString();
|
|
29
|
+
|
|
30
|
+
context.trace(`Comparing the '${statementString}' statement to the '${proofAssertionString}' proof assertion...`);
|
|
31
|
+
|
|
32
|
+
const leftStatement = statement, ///
|
|
33
|
+
rightStatement = this.statement, ///
|
|
34
|
+
leftStatementNode = leftStatement.getNode(),
|
|
35
|
+
rightStatementNode = rightStatement.getNode(),
|
|
36
|
+
statementsEquate = equateStatements(leftStatementNode, rightStatementNode, context);
|
|
37
|
+
|
|
38
|
+
if (statementsEquate) {
|
|
39
|
+
comparesToStatement = true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (comparesToStatement) {
|
|
43
|
+
context.debug(`...compared the '${statementString}' statement to the '${proofAssertionString}' proof assertion.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return comparesToStatement;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
50
|
+
let statementUnifies = false;
|
|
51
|
+
|
|
52
|
+
if (this.statement !== null) {
|
|
53
|
+
const node = this.getNode(),
|
|
54
|
+
context = specificContext, ///
|
|
55
|
+
statementString = statement.getString(),
|
|
56
|
+
proorAssertionString = this.getString(); ///
|
|
57
|
+
|
|
58
|
+
context.trace(`Unifying the '${statementString}' statement with the '${proorAssertionString}' proof assertion...`, node);
|
|
59
|
+
|
|
60
|
+
statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
61
|
+
|
|
62
|
+
if (statementUnifies) {
|
|
63
|
+
context.debug(`...unified the '${statementString}' statement with the '${proorAssertionString}' proof assertion.`, node);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return statementUnifies;
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/element/reference.js
CHANGED
|
@@ -4,7 +4,8 @@ import Element from "../element";
|
|
|
4
4
|
import elements from "../elements";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
|
|
8
|
+
import { findMetaTypeByMetaTypeName } from "../metaTypes";
|
|
8
9
|
import { unifyMetavariableIntrinsically } from "../process/unify";
|
|
9
10
|
import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
10
11
|
|
|
@@ -39,45 +40,48 @@ export default define(class Reference extends Element {
|
|
|
39
40
|
|
|
40
41
|
matchMetavariableNode(metavariableNode) { return this.metavariable.matchNode(metavariableNode); }
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
let
|
|
43
|
+
validate(context) {
|
|
44
|
+
let validate = false;
|
|
44
45
|
|
|
45
46
|
const referenceString = this.getString(); ///
|
|
46
47
|
|
|
47
|
-
context.trace(`
|
|
48
|
+
context.trace(`Validating the '${referenceString}' reference...`);
|
|
48
49
|
|
|
49
|
-
if (!
|
|
50
|
+
if (!validate) {
|
|
50
51
|
const metavariableValidates = this.validateMetavariable(context);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
validate = metavariableValidates; ///
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
if (!
|
|
56
|
+
if (!validate) {
|
|
56
57
|
const reference = this, ///
|
|
57
58
|
labelPresent = context.isLabelPresentByReference(reference);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
validate = labelPresent; ///
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
if (
|
|
63
|
+
if (validate) {
|
|
63
64
|
const reference = this; ///
|
|
64
65
|
|
|
65
66
|
context.addReference(reference);
|
|
66
67
|
|
|
67
|
-
context.debug(`...
|
|
68
|
+
context.debug(`...validated the '${referenceString}' reference.`);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
return
|
|
71
|
+
return validate;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
validateMetavariable(context) {
|
|
74
|
-
let metavariableValidates;
|
|
75
|
+
let metavariableValidates = false;
|
|
75
76
|
|
|
76
|
-
const
|
|
77
|
+
const metaTypeName = REFERENCE_META_TYPE_NAME,
|
|
78
|
+
referenceMetaType = findMetaTypeByMetaTypeName(metaTypeName),
|
|
77
79
|
metaType = referenceMetaType, ///
|
|
78
80
|
metavariableValidatesGivenMetaType = this.metavariable.validateGivenMetaType(metaType, context);
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
if (metavariableValidatesGivenMetaType) {
|
|
83
|
+
metavariableValidates = true;
|
|
84
|
+
}
|
|
81
85
|
|
|
82
86
|
return metavariableValidates;
|
|
83
87
|
}
|
|
@@ -139,27 +143,27 @@ export default define(class Reference extends Element {
|
|
|
139
143
|
return metavariableUnifies;
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
|
|
143
|
-
let
|
|
146
|
+
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
147
|
+
let topLevelMetaAssertionUnifies;
|
|
144
148
|
|
|
145
149
|
const reference = this, ///
|
|
146
150
|
referenceString = reference.getString(),
|
|
147
|
-
|
|
151
|
+
topLevelMetaAssertionString = topLevelMetaAssertion.getString();
|
|
148
152
|
|
|
149
|
-
context.trace(`Unifying the '${
|
|
153
|
+
context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference...`);
|
|
150
154
|
|
|
151
155
|
const { Substitutions } = elements,
|
|
152
|
-
label =
|
|
156
|
+
label = topLevelMetaAssertion.getLabel(),
|
|
153
157
|
substitutions = Substitutions.fromNothing(),
|
|
154
158
|
labelUnifies = this.unifyLabel(label, substitutions, context);
|
|
155
159
|
|
|
156
|
-
|
|
160
|
+
topLevelMetaAssertionUnifies = labelUnifies; ///
|
|
157
161
|
|
|
158
|
-
if (
|
|
159
|
-
context.trace(`...unified the '${
|
|
162
|
+
if (topLevelMetaAssertionUnifies) {
|
|
163
|
+
context.trace(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference.`);
|
|
160
164
|
}
|
|
161
165
|
|
|
162
|
-
return
|
|
166
|
+
return topLevelMetaAssertionUnifies;
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
toJSON() {
|
package/src/element/rule.js
CHANGED
|
@@ -4,7 +4,7 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import Element from "../element";
|
|
6
6
|
import elements from "../elements";
|
|
7
|
-
import
|
|
7
|
+
import ScopedContext from "../context/scoped";
|
|
8
8
|
|
|
9
9
|
import { define } from "../elements";
|
|
10
10
|
import { labelsFromJSON,
|
|
@@ -70,9 +70,9 @@ export default define(class Rule extends Element {
|
|
|
70
70
|
const labelsVerify = this.verifyLabels();
|
|
71
71
|
|
|
72
72
|
if (labelsVerify) {
|
|
73
|
-
const
|
|
73
|
+
const scopedContext = ScopedContext.fromNothing(context);
|
|
74
74
|
|
|
75
|
-
context =
|
|
75
|
+
context = scopedContext; ///
|
|
76
76
|
|
|
77
77
|
const premisesVerify = this.verifyPremises(context);
|
|
78
78
|
|
|
@@ -165,68 +165,68 @@ export default define(class Rule extends Element {
|
|
|
165
165
|
return statementUnifiesWithConclusion;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
let
|
|
168
|
+
unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context) {
|
|
169
|
+
let statementAndSubproofOrProofAssertionsUnify = false;
|
|
170
170
|
|
|
171
171
|
const { Substitutions } = elements,
|
|
172
172
|
substitutions = Substitutions.fromNothing(),
|
|
173
173
|
statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, context);
|
|
174
174
|
|
|
175
175
|
if (statementUnifiesWithConclusion) {
|
|
176
|
-
const
|
|
176
|
+
const subproofOrProofAssertionsUnifiesWithPremises = this.unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, substitutions, context);
|
|
177
177
|
|
|
178
|
-
if (
|
|
178
|
+
if (subproofOrProofAssertionsUnifiesWithPremises) {
|
|
179
179
|
const substitutionsResolved = substitutions.areResolved();
|
|
180
180
|
|
|
181
181
|
if (substitutionsResolved) {
|
|
182
|
-
|
|
182
|
+
statementAndSubproofOrProofAssertionsUnify = true;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
return
|
|
187
|
+
return statementAndSubproofOrProofAssertionsUnify;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
let
|
|
190
|
+
unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, substitutions, context) {
|
|
191
|
+
let subproofOrProofAssertionsUnifiesWithPremise = false;
|
|
192
192
|
|
|
193
|
-
if (!
|
|
193
|
+
if (!subproofOrProofAssertionsUnifiesWithPremise) {
|
|
194
194
|
const premiseUnifiesIndependently = premise.unifyIndependently(substitutions, context);
|
|
195
195
|
|
|
196
196
|
if (premiseUnifiesIndependently) {
|
|
197
|
-
|
|
197
|
+
subproofOrProofAssertionsUnifiesWithPremise = true;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
if (!
|
|
202
|
-
const
|
|
203
|
-
const
|
|
201
|
+
if (!subproofOrProofAssertionsUnifiesWithPremise) {
|
|
202
|
+
const subproofOrProofAssertion = extract(subproofOrProofAssertions, (subproofOrProofAssertion) => {
|
|
203
|
+
const subproofOrProofAssertionUnifies = premise.unifySubproofOrProofAssertion(subproofOrProofAssertion, substitutions, context);
|
|
204
204
|
|
|
205
|
-
if (
|
|
205
|
+
if (subproofOrProofAssertionUnifies) {
|
|
206
206
|
return true;
|
|
207
207
|
}
|
|
208
208
|
}) || null;
|
|
209
209
|
|
|
210
|
-
if (
|
|
211
|
-
|
|
210
|
+
if (subproofOrProofAssertion !== null) {
|
|
211
|
+
subproofOrProofAssertionsUnifiesWithPremise = true;
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
return
|
|
215
|
+
return subproofOrProofAssertionsUnifiesWithPremise;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, substitutions, context) {
|
|
219
|
+
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
220
220
|
|
|
221
|
-
const
|
|
222
|
-
const stepUnifiesWithPremise = this.
|
|
221
|
+
const subproofOrProofAssertionsUnifiesWithPremises = backwardsEvery(this.premises, (premise) => {
|
|
222
|
+
const stepUnifiesWithPremise = this.unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, substitutions, context);
|
|
223
223
|
|
|
224
224
|
if (stepUnifiesWithPremise) {
|
|
225
225
|
return true;
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
return
|
|
229
|
+
return subproofOrProofAssertionsUnifiesWithPremises;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
toJSON() {
|
package/src/element/section.js
CHANGED
|
@@ -45,11 +45,11 @@ export default define(class Section extends Element {
|
|
|
45
45
|
const hypothesesVerify = this.verifyHypotheses();
|
|
46
46
|
|
|
47
47
|
if (hypothesesVerify) {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const topLevelAssertion = (this.axiom || this.lemma || this.theorem || this.conjecture),
|
|
49
|
+
topLevelAssertionVerifies = topLevelAssertion.verify(this.context);
|
|
50
50
|
|
|
51
|
-
if (
|
|
52
|
-
|
|
51
|
+
if (topLevelAssertionVerifies) {
|
|
52
|
+
topLevelAssertion.setHypotheses(this.hypotheses);
|
|
53
53
|
|
|
54
54
|
verifies = true;
|
|
55
55
|
}
|
package/src/element/statement.js
CHANGED
|
@@ -18,15 +18,8 @@ export default define(class Statement extends Element {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
getMetavariableName() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const singular = this.isSingular();
|
|
24
|
-
|
|
25
|
-
if (singular) {
|
|
26
|
-
const node = this.getNode();
|
|
27
|
-
|
|
28
|
-
metavariableName = node.getMetavariableName();
|
|
29
|
-
}
|
|
21
|
+
const node = this.getNode(),
|
|
22
|
+
metavariableName = node.getMetavariableName();
|
|
30
23
|
|
|
31
24
|
return metavariableName;
|
|
32
25
|
}
|
|
@@ -254,19 +247,19 @@ export default define(class Statement extends Element {
|
|
|
254
247
|
return unifiesIndependently;
|
|
255
248
|
}
|
|
256
249
|
|
|
257
|
-
|
|
258
|
-
let
|
|
250
|
+
compareSubproofOrProofAssertions(subproofOrProofAssertions, context) {
|
|
251
|
+
let comparesToSubproofOrProofAssertions;
|
|
259
252
|
|
|
260
|
-
|
|
253
|
+
comparesToSubproofOrProofAssertions = backwardsSome(subproofOrProofAssertions, (subproofOrProofAssertion) => {
|
|
261
254
|
const statement = this, ///
|
|
262
|
-
|
|
255
|
+
subproofOrProofAssertionComparesToStatement = subproofOrProofAssertion.compareStatement(statement, context);
|
|
263
256
|
|
|
264
|
-
if (
|
|
257
|
+
if (subproofOrProofAssertionComparesToStatement) {
|
|
265
258
|
return true;
|
|
266
259
|
}
|
|
267
260
|
});
|
|
268
261
|
|
|
269
|
-
return
|
|
262
|
+
return comparesToSubproofOrProofAssertions;
|
|
270
263
|
}
|
|
271
264
|
|
|
272
265
|
toJSON() {
|