occam-verify-cli 1.0.233 → 1.0.234
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/variable.js +4 -2
- package/lib/context/file.js +5 -5
- package/lib/context/local.js +22 -4
- package/lib/dom/axiom.js +18 -15
- package/lib/dom/declaration.js +2 -2
- package/lib/dom/hypothesis.js +12 -88
- package/lib/dom/procedureCall.js +8 -9
- package/lib/dom/rule.js +2 -2
- package/lib/dom/section.js +110 -8
- package/lib/dom/signature.js +1 -1
- package/lib/dom/topLevelAssertion.js +106 -14
- package/lib/dom/topLevelMetaAssertion.js +2 -2
- package/lib/mixins/step/unify.js +11 -11
- package/lib/mixins/term/verify.js +6 -6
- package/lib/node/section.js +29 -1
- package/lib/utilities/context.js +1 -1
- package/lib/utilities/json.js +24 -1
- package/lib/utilities/releaseContext.js +3 -3
- package/package.json +1 -1
- package/src/assignment/variable.js +6 -4
- package/src/context/file.js +3 -3
- package/src/context/local.js +7 -1
- package/src/dom/axiom.js +20 -16
- package/src/dom/declaration.js +2 -2
- package/src/dom/hypothesis.js +12 -123
- package/src/dom/procedureCall.js +6 -6
- package/src/dom/rule.js +1 -1
- package/src/dom/section.js +140 -13
- package/src/dom/signature.js +0 -1
- package/src/dom/topLevelAssertion.js +88 -14
- package/src/dom/topLevelMetaAssertion.js +1 -1
- package/src/mixins/step/unify.js +10 -10
- package/src/mixins/term/verify.js +4 -5
- package/src/node/section.js +29 -1
- package/src/utilities/context.js +2 -2
- package/src/utilities/json.js +28 -0
- package/src/utilities/releaseContext.js +2 -2
package/src/dom/axiom.js
CHANGED
|
@@ -234,34 +234,38 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
234
234
|
return suppositionsUnify;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
let
|
|
237
|
+
unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture, substitutions, context) {
|
|
238
|
+
let axiomLemmaTheoremOrConjectureUnifies = false;
|
|
239
239
|
|
|
240
240
|
const axiomString = this.getString(),
|
|
241
|
-
|
|
241
|
+
axiomLemmaTheoremOrConjectureString = axiomLemmaTheoremOrConjecture.getString();
|
|
242
242
|
|
|
243
|
-
context.trace(`Unifying the '${
|
|
243
|
+
context.trace(`Unifying the '${axiomLemmaTheoremOrConjectureString}' axiom, lemma, theorem or conjecture with the '${axiomString}' axiom...`);
|
|
244
244
|
|
|
245
|
-
const
|
|
246
|
-
specificContext = context; ///
|
|
245
|
+
const hypothesesCorrelate = axiomLemmaTheoremOrConjecture.correlateHypotheses(context);
|
|
247
246
|
|
|
248
|
-
|
|
247
|
+
if (hypothesesCorrelate) {
|
|
248
|
+
const deduction = axiomLemmaTheoremOrConjecture.getDeduction(), ///
|
|
249
|
+
specificContext = context; ///
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
deductionUnifies = this.unifyDeduction(deduction, substitutions, generalContext, specificContext);
|
|
251
|
+
context = this.getContext();
|
|
252
252
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
suppositionsUnify = this.unifySuppositions(suppositions, substitutions, generalContext, specificContext);
|
|
253
|
+
const generalContext = context, ///
|
|
254
|
+
deductionUnifies = this.unifyDeduction(deduction, substitutions, generalContext, specificContext);
|
|
256
255
|
|
|
257
|
-
|
|
256
|
+
if (deductionUnifies) {
|
|
257
|
+
const suppositions = axiomLemmaTheoremOrConjecture.getSuppositions(),
|
|
258
|
+
suppositionsUnify = this.unifySuppositions(suppositions, substitutions, generalContext, specificContext);
|
|
259
|
+
|
|
260
|
+
axiomLemmaTheoremOrConjectureUnifies = suppositionsUnify; ///
|
|
261
|
+
}
|
|
258
262
|
}
|
|
259
263
|
|
|
260
|
-
if (
|
|
261
|
-
context.debug(`...unified the '${
|
|
264
|
+
if (axiomLemmaTheoremOrConjectureUnifies) {
|
|
265
|
+
context.debug(`...unified the '${axiomLemmaTheoremOrConjectureString}' axiom, lemma, theorem or conjecture with the '${axiomString}' axiom.`);
|
|
262
266
|
}
|
|
263
267
|
|
|
264
|
-
return
|
|
268
|
+
return axiomLemmaTheoremOrConjectureUnifies;
|
|
265
269
|
}
|
|
266
270
|
|
|
267
271
|
static name = "Axiom";
|
package/src/dom/declaration.js
CHANGED
|
@@ -219,9 +219,9 @@ export default domAssigned(class Declaration {
|
|
|
219
219
|
|
|
220
220
|
const generalContext = context; ///
|
|
221
221
|
|
|
222
|
-
context = metaLemmaMetatheorem.getContext();
|
|
222
|
+
context = metaLemmaMetatheorem.getContext(); ///
|
|
223
223
|
|
|
224
|
-
const specificContext = context,
|
|
224
|
+
const specificContext = context, ///
|
|
225
225
|
labelSubstitutions = Substitutions.fromNothing(),
|
|
226
226
|
label = metaLemmaMetatheorem.getLabel(),
|
|
227
227
|
substitutions = labelSubstitutions, ///
|
package/src/dom/hypothesis.js
CHANGED
|
@@ -59,137 +59,26 @@ export default domAssigned(class Hypothesis {
|
|
|
59
59
|
return verifies;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
let
|
|
62
|
+
isEqualToStep(step, context) {
|
|
63
|
+
let equalToStep = false;
|
|
64
64
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
generalHypothesisString = this.string, ///
|
|
68
|
-
specificHypothesisString = specificHypothesis.getString();
|
|
65
|
+
const stepString = step.getString(),
|
|
66
|
+
hypothesisString = this.string; ///
|
|
69
67
|
|
|
70
|
-
context.trace(`
|
|
68
|
+
context.trace(`Is the '${hypothesisString}' hypothesis equal to the '${stepString}' step...`);
|
|
71
69
|
|
|
72
|
-
const
|
|
73
|
-
|
|
70
|
+
const stepStatement = step.getStatement(),
|
|
71
|
+
statementEqualToStepStatement = this.statement.isEqualTo(stepStatement);
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (hypothesisUnifies) {
|
|
78
|
-
context.debug(`...unified the '${specificHypothesisString}' hypothesis with the '${generalHypothesisString}' hypothesis.`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return hypothesisUnifies;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
unifyIndependently(substitutions, context) {
|
|
85
|
-
let unifiesIndependently;
|
|
86
|
-
|
|
87
|
-
if (this.statement !== null) {
|
|
88
|
-
const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, context);
|
|
89
|
-
|
|
90
|
-
unifiesIndependently = statementResolvedIndependently; ///
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (this.procedureCall !== null) {
|
|
94
|
-
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, context);
|
|
95
|
-
|
|
96
|
-
unifiesIndependently = procedureCallResolvedIndependently; ///
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return unifiesIndependently;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
unifyStepOrSubproof(stepOrSubproof, substitutions, generalContext, specificContext) {
|
|
103
|
-
let stepOrSubproofUnifies = false;
|
|
104
|
-
|
|
105
|
-
const stepOrSubProofStep = stepOrSubproof.isStep(),
|
|
106
|
-
subproof = stepOrSubProofStep ?
|
|
107
|
-
null :
|
|
108
|
-
stepOrSubproof,
|
|
109
|
-
step = stepOrSubProofStep ?
|
|
110
|
-
stepOrSubproof :
|
|
111
|
-
null;
|
|
112
|
-
|
|
113
|
-
substitutions.snapshot();
|
|
114
|
-
|
|
115
|
-
if (subproof !== null) {
|
|
116
|
-
const subproofUnifies = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
117
|
-
|
|
118
|
-
stepOrSubproofUnifies = subproofUnifies; ///
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (step !== null) {
|
|
122
|
-
const statementUnifies = this.unifyStep(step, substitutions, generalContext, specificContext);
|
|
123
|
-
|
|
124
|
-
stepOrSubproofUnifies = statementUnifies; ///
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (stepOrSubproofUnifies) {
|
|
128
|
-
substitutions.resolve(generalContext, specificContext);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
stepOrSubproofUnifies ?
|
|
132
|
-
substitutions.continue() :
|
|
133
|
-
substitutions.rollback(specificContext);
|
|
134
|
-
|
|
135
|
-
return stepOrSubproofUnifies;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
unifyStep(step, substitutions, generalContext, specificContext) {
|
|
139
|
-
let stepUnifies;
|
|
140
|
-
|
|
141
|
-
const statement = step.getStatement(),
|
|
142
|
-
statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
143
|
-
|
|
144
|
-
stepUnifies = statementUnifies; ///
|
|
145
|
-
|
|
146
|
-
return stepUnifies;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
150
|
-
let subproofUnifies = false;
|
|
151
|
-
|
|
152
|
-
const hypothesis = this, ///
|
|
153
|
-
subproofString = subproof.getString(),
|
|
154
|
-
hypothesisStatement = hypothesis.getStatement(),
|
|
155
|
-
hypothesisStatementString = hypothesisStatement.getString();
|
|
156
|
-
|
|
157
|
-
specificContext.trace(`Unifying the '${subproofString}' subproof with the hypothesis's '${hypothesisStatementString}' statement...`);
|
|
158
|
-
|
|
159
|
-
if (this.statement !== null) {
|
|
160
|
-
const context = generalContext, ///
|
|
161
|
-
subproofAssertion = subproofAssertionFromStatement(this.statement, context);
|
|
162
|
-
|
|
163
|
-
if (subproofAssertion !== null) {
|
|
164
|
-
subproofUnifies = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (subproofUnifies) {
|
|
169
|
-
specificContext.debug(`...unified the '${subproofString}' subproof with the hypothesis's '${hypothesisStatementString}' statement.`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return subproofUnifies;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
176
|
-
let statementUnifies;
|
|
177
|
-
|
|
178
|
-
const hypothesis = this, ///
|
|
179
|
-
statementString = statement.getString(),
|
|
180
|
-
hypothesisString = hypothesis.getString();
|
|
181
|
-
|
|
182
|
-
specificContext.trace(`Unifying the '${statementString}' statement with the '${hypothesisString}' hypothesis...`);
|
|
183
|
-
|
|
184
|
-
if (this.statement !== null) {
|
|
185
|
-
statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
73
|
+
if (statementEqualToStepStatement) {
|
|
74
|
+
equalToStep = true;
|
|
186
75
|
}
|
|
187
76
|
|
|
188
|
-
if (
|
|
189
|
-
|
|
77
|
+
if (equalToStep) {
|
|
78
|
+
context.trace(`...the '${hypothesisString}' hypothesis is equal to the '${stepString}' step.`);
|
|
190
79
|
}
|
|
191
80
|
|
|
192
|
-
return
|
|
81
|
+
return equalToStep;
|
|
193
82
|
}
|
|
194
83
|
|
|
195
84
|
toJSON() {
|
package/src/dom/procedureCall.js
CHANGED
|
@@ -76,16 +76,16 @@ export default domAssigned(class ProcedureCall {
|
|
|
76
76
|
nodes = this.findNodes(substitutions),
|
|
77
77
|
expressions = Expressions.fromNodes(nodes, context);
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
try {
|
|
80
80
|
const value = procedure.call(expressions, context),
|
|
81
81
|
boolean = value.getBoolean();
|
|
82
82
|
|
|
83
83
|
unifiesIndependently = boolean; ///
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
} catch (exception) {
|
|
85
|
+
const message = exception.getMessage();
|
|
86
|
+
|
|
87
|
+
context.info(message);
|
|
88
|
+
}
|
|
89
89
|
|
|
90
90
|
if (unifiesIndependently) {
|
|
91
91
|
context.debug(`...unified the '${procedureCallString}' procedure call independently.`);
|
package/src/dom/rule.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
5
|
import dom from "../dom";
|
|
6
|
+
import LocalContext from "../context/local";
|
|
6
7
|
import Substitutions from "../substitutions";
|
|
7
8
|
|
|
8
9
|
import { domAssigned } from "../dom";
|
|
@@ -13,7 +14,6 @@ import { labelsFromJSON,
|
|
|
13
14
|
labelsToLabelsJSON,
|
|
14
15
|
premisesToPremisesJSON,
|
|
15
16
|
conclusionToConclusionJSON } from "../utilities/json";
|
|
16
|
-
import LocalContext from "../context/local";
|
|
17
17
|
|
|
18
18
|
const { reverse, extract, backwardsEvery } = arrayUtilities;
|
|
19
19
|
|
package/src/dom/section.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
3
|
import dom from "../dom";
|
|
4
|
+
import LocalContext from "../context/local";
|
|
6
5
|
|
|
7
6
|
import { domAssigned } from "../dom";
|
|
8
7
|
|
|
9
|
-
const { first } = arrayUtilities;
|
|
10
|
-
|
|
11
8
|
export default domAssigned(class Section {
|
|
12
|
-
constructor(context, string, hypotheses) {
|
|
9
|
+
constructor(context, string, hypotheses, axiom, lemma, theorem, conjecture) {
|
|
13
10
|
this.context = context;
|
|
14
11
|
this.string = string;
|
|
15
12
|
this.hypotheses = hypotheses;
|
|
13
|
+
this.axiom = axiom;
|
|
14
|
+
this.lemma = lemma;
|
|
15
|
+
this.theorem = theorem;
|
|
16
|
+
this.conjecture = conjecture;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
getContext() {
|
|
@@ -27,28 +28,137 @@ export default domAssigned(class Section {
|
|
|
27
28
|
return this.hypotheses;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
getAxiom() {
|
|
32
|
+
return this.axiom;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getLemma() {
|
|
36
|
+
return this.lemma;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getTheorem() {
|
|
40
|
+
return this.theorem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getConjecture() {
|
|
44
|
+
return this.conjecture;
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
verify() {
|
|
31
48
|
let verifies = false;
|
|
32
49
|
|
|
33
50
|
const sectionString = this.string; ///
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
this.context.trace(`Verifying the '${sectionString}' section...`);
|
|
53
|
+
|
|
54
|
+
const hypothesesVerify = this.verifyHypotheses();
|
|
55
|
+
|
|
56
|
+
if (hypothesesVerify) {
|
|
57
|
+
const axiomLemmaTheoremOrConjecture = (this.axiom || this.lemma || this.theorem || this.conjecture),
|
|
58
|
+
axiomLemmaTheoremOrConjectureVerifies = axiomLemmaTheoremOrConjecture.verify(this.context);
|
|
59
|
+
|
|
60
|
+
if (axiomLemmaTheoremOrConjectureVerifies) {
|
|
61
|
+
axiomLemmaTheoremOrConjecture.setHypotheses(this.hypotheses);
|
|
62
|
+
|
|
63
|
+
verifies = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (verifies) {
|
|
68
|
+
this.context.debug(`...verified the '${sectionString}' section.`);
|
|
69
|
+
}
|
|
36
70
|
|
|
37
71
|
return verifies;
|
|
38
72
|
}
|
|
39
73
|
|
|
74
|
+
verifyHypotheses() {
|
|
75
|
+
const hypothesesVerify = this.hypotheses.every((hypothesis) => {
|
|
76
|
+
const hypothesisVerifies = hypothesis.verify(this.context);
|
|
77
|
+
|
|
78
|
+
if (hypothesisVerifies) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return hypothesesVerify;
|
|
84
|
+
}
|
|
85
|
+
|
|
40
86
|
static name = "Section";
|
|
41
87
|
|
|
42
88
|
static fromSectionNode(sectionNode, context) {
|
|
89
|
+
const localContext = LocalContext.fromContext(context);
|
|
90
|
+
|
|
91
|
+
context = localContext; ///
|
|
92
|
+
|
|
43
93
|
const hypothesisNodes = sectionNode.getHypothesisNodes(),
|
|
44
94
|
hypotheses = hypothesesFromHypothesisNodes(hypothesisNodes, context),
|
|
45
|
-
|
|
46
|
-
|
|
95
|
+
axiom = axiomFroSectionNode(sectionNode, context),
|
|
96
|
+
lemma = lemmaFroSectionNode(sectionNode, context),
|
|
97
|
+
theorem = theoremFroSectionNode(sectionNode, context),
|
|
98
|
+
conjecture = conjectureFroSectionNode(sectionNode, context),
|
|
99
|
+
string = stringFromHypothesesAxiomLemmaTheoremAndConjecture(hypotheses, axiom, lemma, theorem, conjecture, context),
|
|
100
|
+
section = new Section(context, string, hypotheses, axiom, lemma, theorem, conjecture);
|
|
47
101
|
|
|
48
102
|
return section;
|
|
49
103
|
}
|
|
50
104
|
});
|
|
51
105
|
|
|
106
|
+
function axiomFroSectionNode(sectionNode, context) {
|
|
107
|
+
let axiom = null;
|
|
108
|
+
|
|
109
|
+
const axiomNode = sectionNode.getAxiomNode();
|
|
110
|
+
|
|
111
|
+
if (axiomNode !== null) {
|
|
112
|
+
const { Axiom } = dom;
|
|
113
|
+
|
|
114
|
+
axiom = Axiom.fromAxiomNode(axiomNode, context);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return axiom;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function lemmaFroSectionNode(sectionNode, context) {
|
|
121
|
+
let lemma = null;
|
|
122
|
+
|
|
123
|
+
const lemmaNode = sectionNode.getLemmaNode();
|
|
124
|
+
|
|
125
|
+
if (lemmaNode !== null) {
|
|
126
|
+
const { Lemma } = dom;
|
|
127
|
+
|
|
128
|
+
lemma = Lemma.fromLemmaNode(lemmaNode, context);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return lemma;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function theoremFroSectionNode(sectionNode, context) {
|
|
135
|
+
let theorem = null;
|
|
136
|
+
|
|
137
|
+
const theoremNode = sectionNode.getTheoremNode();
|
|
138
|
+
|
|
139
|
+
if (theoremNode !== null) {
|
|
140
|
+
const { Theorem } = dom;
|
|
141
|
+
|
|
142
|
+
theorem = Theorem.fromTheoremNode(theoremNode, context);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return theorem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function conjectureFroSectionNode(sectionNode, context) {
|
|
149
|
+
let conjecture = null;
|
|
150
|
+
|
|
151
|
+
const conjectureNode = sectionNode.getConjectureNode();
|
|
152
|
+
|
|
153
|
+
if (conjectureNode !== null) {
|
|
154
|
+
const { Conjecture } = dom;
|
|
155
|
+
|
|
156
|
+
conjecture = Conjecture.fromConjectureNode(conjectureNode, context);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return conjecture;
|
|
160
|
+
}
|
|
161
|
+
|
|
52
162
|
function hypothesesFromHypothesisNodes(hypothesisNodes, context) {
|
|
53
163
|
const hypotheses = hypothesisNodes.map((hypothesisNode) => {
|
|
54
164
|
const { Hypothesis } = dom,
|
|
@@ -60,11 +170,28 @@ function hypothesesFromHypothesisNodes(hypothesisNodes, context) {
|
|
|
60
170
|
return hypotheses;
|
|
61
171
|
}
|
|
62
172
|
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
173
|
+
function hypothesesStringFromHypotheses(hypotheses, context) {
|
|
174
|
+
const hypothesesString = hypotheses.reduce((hypothesesString, hypothesis) => {
|
|
175
|
+
const hypothesisString = hypothesis.getString();
|
|
176
|
+
|
|
177
|
+
hypothesesString = (hypothesesString !== null) ?
|
|
178
|
+
`${hypothesesString}, ${hypothesisString}` :
|
|
179
|
+
hypothesisString; ///
|
|
180
|
+
|
|
181
|
+
return hypothesesString;
|
|
182
|
+
}, null);
|
|
183
|
+
|
|
184
|
+
return hypothesesString;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function stringFromHypothesesAxiomLemmaTheoremAndConjecture(hypotheses, axiom, lemma, theorem, conjecture, context) {
|
|
188
|
+
const axiomLemmaTheoremOrConjecture = (axiom || lemma || theorem || conjecture),
|
|
189
|
+
axiomLemmaTheoremOrConjectureString = axiomLemmaTheoremOrConjecture.getString(),
|
|
190
|
+
hypothesesString = hypothesesStringFromHypotheses(hypotheses, context),
|
|
191
|
+
string = (axiomLemmaTheoremOrConjectureString !== null) ?
|
|
192
|
+
`[${hypothesesString}]::: ${axiomLemmaTheoremOrConjectureString}` :
|
|
193
|
+
`[${hypothesesString}]::: `;
|
|
194
|
+
|
|
68
195
|
|
|
69
196
|
return string;
|
|
70
197
|
}
|
package/src/dom/signature.js
CHANGED
|
@@ -10,15 +10,17 @@ import { labelsFromJSON,
|
|
|
10
10
|
deductionFromJSON,
|
|
11
11
|
signatureFromJSON,
|
|
12
12
|
labelsToLabelsJSON,
|
|
13
|
+
hypothesesFromJSON,
|
|
13
14
|
suppositionsFromJSON,
|
|
14
15
|
deductionToDeductionJSON,
|
|
15
16
|
signatureToSignatureJSON,
|
|
17
|
+
hypothesesToHypothesesJSON,
|
|
16
18
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
17
19
|
|
|
18
|
-
const { reverse,
|
|
20
|
+
const { extract, reverse, correlate, backwardsEvery } = arrayUtilities;
|
|
19
21
|
|
|
20
22
|
export default class TopLevelAssertion {
|
|
21
|
-
constructor(context, string, labels, suppositions, deduction, proof, signature) {
|
|
23
|
+
constructor(context, string, labels, suppositions, deduction, proof, signature, hypotheses) {
|
|
22
24
|
this.context = context;
|
|
23
25
|
this.string = string;
|
|
24
26
|
this.labels = labels;
|
|
@@ -26,6 +28,7 @@ export default class TopLevelAssertion {
|
|
|
26
28
|
this.deduction = deduction;
|
|
27
29
|
this.proof = proof;
|
|
28
30
|
this.signature = signature;
|
|
31
|
+
this.hypotheses = hypotheses;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
getContext() {
|
|
@@ -56,8 +59,35 @@ export default class TopLevelAssertion {
|
|
|
56
59
|
return this.signature;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
getHypotheses() {
|
|
63
|
+
return this.hypotheses;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setContext(context) { this.context = context; }
|
|
67
|
+
|
|
68
|
+
setString(string) { this.string = string; }
|
|
69
|
+
|
|
70
|
+
setLabels(labels) { this.labels = labels; }
|
|
71
|
+
|
|
72
|
+
setSuppositions(suppositions) { this.suppositions = suppositions; }
|
|
73
|
+
|
|
74
|
+
setDeduction(deduction) { this.deduction = deduction; }
|
|
75
|
+
|
|
76
|
+
setProof(proof) { this.proof = proof; }
|
|
77
|
+
|
|
78
|
+
setSignature(signature) { this.signature = signature; }
|
|
79
|
+
|
|
80
|
+
setHypotheses(hypotheses) { this.hypotheses = hypotheses; }
|
|
81
|
+
|
|
59
82
|
getStatement() { return this.deduction.getStatement(); }
|
|
60
83
|
|
|
84
|
+
isHypothetical() {
|
|
85
|
+
const hypothesesLength = this.hypotheses.length,
|
|
86
|
+
hypothetical = (hypothesesLength > 0);
|
|
87
|
+
|
|
88
|
+
return hypothetical;
|
|
89
|
+
}
|
|
90
|
+
|
|
61
91
|
isUnconditional() {
|
|
62
92
|
const suppositionsLength = this.suppositions.length,
|
|
63
93
|
unconditional = (suppositionsLength === 0);
|
|
@@ -160,6 +190,36 @@ export default class TopLevelAssertion {
|
|
|
160
190
|
return proofVerifies;
|
|
161
191
|
}
|
|
162
192
|
|
|
193
|
+
correlateHypotheses(context) {
|
|
194
|
+
let hypothesesCorrelate;
|
|
195
|
+
|
|
196
|
+
const hypothetical = this.isHypothetical();
|
|
197
|
+
|
|
198
|
+
if (hypothetical) {
|
|
199
|
+
const steps = context.getSteps(),
|
|
200
|
+
topLevelAssertionString = this.string; ///
|
|
201
|
+
|
|
202
|
+
context.trace(`Correlating the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture...`);
|
|
203
|
+
|
|
204
|
+
hypothesesCorrelate = correlate(this.hypotheses, steps, (hypothesis, step) => {
|
|
205
|
+
const hypothesesEqualToStep = hypothesis.isEqualToStep(step, context);
|
|
206
|
+
|
|
207
|
+
if (hypothesesEqualToStep) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
if (hypothesesCorrelate) {
|
|
213
|
+
context.debug(`...correlated the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture.`);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
hypothesesCorrelate = true
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
return hypothesesCorrelate;
|
|
221
|
+
}
|
|
222
|
+
|
|
163
223
|
unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext) {
|
|
164
224
|
let statementUnifiesWithDeduction = false;
|
|
165
225
|
|
|
@@ -175,20 +235,29 @@ export default class TopLevelAssertion {
|
|
|
175
235
|
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context) {
|
|
176
236
|
let statementAndStepsOrSubproofsUnify = false;
|
|
177
237
|
|
|
178
|
-
const
|
|
179
|
-
specificContext = context, ///
|
|
180
|
-
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
|
|
238
|
+
const hypothetical = this.isHypothetical();
|
|
181
239
|
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
240
|
+
if (!hypothetical) {
|
|
241
|
+
const generalContext = this.context, ///
|
|
242
|
+
specificContext = context, ///
|
|
243
|
+
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
|
|
184
244
|
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
245
|
+
if (statementUnifiesWithDeduction) {
|
|
246
|
+
const stepsOrSubproofsUnifyWithSuppositions = this.unifyStepsOrSubproofsWithSuppositions(stepsOrSubproofs, substitutions, generalContext, specificContext);
|
|
187
247
|
|
|
188
|
-
if (
|
|
189
|
-
|
|
248
|
+
if (stepsOrSubproofsUnifyWithSuppositions) {
|
|
249
|
+
const substitutionsResolved = substitutions.areResolved();
|
|
250
|
+
|
|
251
|
+
if (substitutionsResolved) {
|
|
252
|
+
statementAndStepsOrSubproofsUnify = true;
|
|
253
|
+
}
|
|
190
254
|
}
|
|
191
255
|
}
|
|
256
|
+
} else {
|
|
257
|
+
const statementString = statement.getString(),
|
|
258
|
+
topLevelAssertionString = this.string; ///
|
|
259
|
+
|
|
260
|
+
context.trace(`Cannot unify the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture with the '${statementString}' and steps or subproofs because it is hypothetical.`);
|
|
192
261
|
}
|
|
193
262
|
|
|
194
263
|
return statementAndStepsOrSubproofsUnify;
|
|
@@ -238,15 +307,18 @@ export default class TopLevelAssertion {
|
|
|
238
307
|
deductionJSON = deductionToDeductionJSON(this.deduction),
|
|
239
308
|
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
240
309
|
signatureJSON = signatureToSignatureJSON(this.signature),
|
|
310
|
+
hypothesesJSON = hypothesesToHypothesesJSON(this.signature),
|
|
241
311
|
labels = labelsJSON, ///
|
|
242
312
|
deduction = deductionJSON, ///
|
|
243
313
|
suppositions = suppositionsJSON, ///
|
|
244
|
-
signature = signatureJSON,
|
|
314
|
+
signature = signatureJSON, ///
|
|
315
|
+
hypotheses = hypothesesJSON, ///
|
|
245
316
|
json = {
|
|
246
317
|
labels,
|
|
247
318
|
deduction,
|
|
248
319
|
suppositions,
|
|
249
320
|
signature,
|
|
321
|
+
hypotheses
|
|
250
322
|
};
|
|
251
323
|
|
|
252
324
|
return json;
|
|
@@ -257,9 +329,10 @@ export default class TopLevelAssertion {
|
|
|
257
329
|
deduction = deductionFromJSON(json, context),
|
|
258
330
|
suppositions = suppositionsFromJSON(json, context),
|
|
259
331
|
signature = signatureFromJSON(json, context),
|
|
332
|
+
hypotheses = hypothesesFromJSON(json, context),
|
|
260
333
|
proof = null,
|
|
261
334
|
string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
|
|
262
|
-
topLevelAssertion = new Class(context, string, labels, suppositions, deduction, proof, signature);
|
|
335
|
+
topLevelAssertion = new Class(context, string, labels, suppositions, deduction, proof, signature, hypotheses);
|
|
263
336
|
|
|
264
337
|
return topLevelAssertion;
|
|
265
338
|
}
|
|
@@ -276,8 +349,9 @@ export default class TopLevelAssertion {
|
|
|
276
349
|
deduction = deductionFromDeductionNode(deductionNode, context),
|
|
277
350
|
suppositions = suppositionsFromSuppositionNodes(suppositionNodes, context),
|
|
278
351
|
signature = signatureFromSignatureNode(signatureNode, context),
|
|
352
|
+
hypotheses = [],
|
|
279
353
|
string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
|
|
280
|
-
topLevelAssertion = new Class(context, string, labels, suppositions, deduction, proof, signature);
|
|
354
|
+
topLevelAssertion = new Class(context, string, labels, suppositions, deduction, proof, signature, hypotheses);
|
|
281
355
|
|
|
282
356
|
return topLevelAssertion;
|
|
283
357
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import dom from "../dom";
|
|
4
|
+
import LocalContext from "../context/local";
|
|
4
5
|
import Substitutions from "../substitutions";
|
|
5
6
|
|
|
6
7
|
import { proofFromProofNode, deductionFromDeductionNode, suppositionsFromSuppositionNodes } from "./topLevelAssertion";
|
|
@@ -12,7 +13,6 @@ import { labelFromJSON,
|
|
|
12
13
|
deductionToDeductionJSON,
|
|
13
14
|
suppositionsToSuppositionsJSON,
|
|
14
15
|
substitutionsToSubstitutionsJSON } from "../utilities/json";
|
|
15
|
-
import LocalContext from "../context/local";
|
|
16
16
|
|
|
17
17
|
export default class TopLevelMetaAssertion {
|
|
18
18
|
constructor(context, string, label, suppositions, deduction, proof, substitutions) {
|