occam-verify-cli 1.0.211 → 1.0.219
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/dom/assertion/satisfies.js +17 -17
- package/lib/dom/axiom.js +81 -57
- package/lib/dom/deduction.js +15 -1
- package/lib/dom/metavariable.js +1 -1
- package/lib/dom/rule.js +3 -3
- package/lib/dom/step.js +25 -3
- package/lib/dom/subproof.js +38 -16
- package/lib/dom/substitution/term.js +8 -1
- package/lib/dom/substitution.js +8 -1
- package/lib/dom/supposition.js +15 -1
- package/lib/dom/term.js +1 -1
- package/lib/dom/topLevelAssertion.js +19 -5
- package/lib/dom/variable.js +9 -28
- package/lib/mixins/step/unify.js +41 -26
- package/lib/node/conclusion.js +8 -1
- package/lib/node/deduction.js +8 -1
- package/lib/node/nonsense.js +107 -0
- package/lib/node/premise.js +8 -1
- package/lib/node/step.js +8 -1
- package/lib/node/supposition.js +8 -1
- package/lib/nonTerminalNodeMap.js +3 -2
- package/lib/ruleNames.js +5 -1
- package/lib/substitutions.js +12 -1
- package/lib/utilities/subproof.js +26 -12
- package/package.json +1 -1
- package/src/dom/assertion/satisfies.js +18 -21
- package/src/dom/axiom.js +116 -79
- package/src/dom/deduction.js +22 -0
- package/src/dom/metavariable.js +1 -1
- package/src/dom/rule.js +2 -2
- package/src/dom/step.js +37 -3
- package/src/dom/subproof.js +55 -23
- package/src/dom/substitution/term.js +8 -0
- package/src/dom/substitution.js +6 -0
- package/src/dom/supposition.js +22 -0
- package/src/dom/term.js +1 -1
- package/src/dom/topLevelAssertion.js +18 -5
- package/src/dom/variable.js +17 -40
- package/src/mixins/step/unify.js +49 -28
- package/src/node/conclusion.js +8 -1
- package/src/node/deduction.js +8 -1
- package/src/node/nonsense.js +7 -0
- package/src/node/premise.js +8 -1
- package/src/node/step.js +8 -1
- package/src/node/supposition.js +8 -1
- package/src/nonTerminalNodeMap.js +3 -0
- package/src/ruleNames.js +1 -0
- package/src/substitutions.js +10 -0
- package/src/utilities/subproof.js +43 -21
package/src/dom/variable.js
CHANGED
|
@@ -61,23 +61,6 @@ export default domAssigned(class Variable {
|
|
|
61
61
|
return variableNameMatches;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
isEffectivelyEqualToTerm(term, generalContext, specificContext) {
|
|
65
|
-
let effectivelyEqualToTerm = false;
|
|
66
|
-
|
|
67
|
-
const generalContextFilePath = generalContext.getFilePath(),
|
|
68
|
-
specificContextFilePath = specificContext.getFilePath();
|
|
69
|
-
|
|
70
|
-
if (generalContextFilePath === specificContextFilePath) {
|
|
71
|
-
const termString = term.getString();
|
|
72
|
-
|
|
73
|
-
if (termString === this.string) {
|
|
74
|
-
effectivelyEqualToTerm = true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return effectivelyEqualToTerm;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
64
|
verify(context) {
|
|
82
65
|
let verified;
|
|
83
66
|
|
|
@@ -137,32 +120,26 @@ export default domAssigned(class Variable {
|
|
|
137
120
|
|
|
138
121
|
specificContext.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
|
|
139
122
|
|
|
140
|
-
const
|
|
123
|
+
const variable = this, ///
|
|
124
|
+
substitutionPresent = substitutions.isSubstitutionPresentByVariable(variable);
|
|
141
125
|
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const variable = this, ///
|
|
146
|
-
substitutionPresent = substitutions.isSubstitutionPresentByVariable(variable);
|
|
147
|
-
|
|
148
|
-
if (substitutionPresent) {
|
|
149
|
-
const substitution = substitutions.findSubstitutionByVariable(variable),
|
|
150
|
-
substitutionTermEqualToTerm = substitution.isTermEqualTo(term);
|
|
151
|
-
|
|
152
|
-
if (substitutionTermEqualToTerm) {
|
|
153
|
-
termUnified = true;
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
const { TermSubstitution } = dom,
|
|
157
|
-
context = specificContext, ///
|
|
158
|
-
variable = this, ///
|
|
159
|
-
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
160
|
-
substitution = termSubstitution; ///
|
|
161
|
-
|
|
162
|
-
substitutions.addSubstitution(substitution, specificContext);
|
|
126
|
+
if (substitutionPresent) {
|
|
127
|
+
const substitution = substitutions.findSubstitutionByVariable(variable),
|
|
128
|
+
substitutionTermEqualToTerm = substitution.isTermEqualTo(term);
|
|
163
129
|
|
|
130
|
+
if (substitutionTermEqualToTerm) {
|
|
164
131
|
termUnified = true;
|
|
165
132
|
}
|
|
133
|
+
} else {
|
|
134
|
+
const { TermSubstitution } = dom,
|
|
135
|
+
context = specificContext, ///
|
|
136
|
+
variable = this, ///
|
|
137
|
+
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
138
|
+
substitution = termSubstitution; ///
|
|
139
|
+
|
|
140
|
+
substitutions.addSubstitution(substitution, specificContext);
|
|
141
|
+
|
|
142
|
+
termUnified = true;
|
|
166
143
|
}
|
|
167
144
|
|
|
168
145
|
if (termUnified) {
|
|
@@ -174,7 +151,7 @@ export default domAssigned(class Variable {
|
|
|
174
151
|
|
|
175
152
|
toJSON() {
|
|
176
153
|
const typeJSON = typeToTypeJSON(this.type),
|
|
177
|
-
string = this.string,
|
|
154
|
+
string = this.string, ///
|
|
178
155
|
type = typeJSON, ///
|
|
179
156
|
json = {
|
|
180
157
|
type,
|
package/src/mixins/step/unify.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import dom from "../../dom";
|
|
4
6
|
import Substitutions from "../../substitutions";
|
|
5
7
|
|
|
@@ -9,7 +11,9 @@ import { equalityFromStatement,
|
|
|
9
11
|
propertyAssertionFromStatement,
|
|
10
12
|
satisfiesAssertionFromStatement } from "../../utilities/context";
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
const { backwardsSome } = arrayUtilities;
|
|
15
|
+
|
|
16
|
+
function unifyWithRule(statement, reference, substitutions, context) {
|
|
13
17
|
let unifiedWithRule = false;
|
|
14
18
|
|
|
15
19
|
if (reference !== null) {
|
|
@@ -35,7 +39,7 @@ function unifyAWithRule(statement, reference, substitutions, context) {
|
|
|
35
39
|
return unifiedWithRule;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
function
|
|
42
|
+
function unifyWithReference(statement, reference, substitutions, context) {
|
|
39
43
|
let unifiedWithReference = false;
|
|
40
44
|
|
|
41
45
|
if (reference !== null) {
|
|
@@ -69,40 +73,58 @@ function unifyAWithReference(statement, reference, substitutions, context) {
|
|
|
69
73
|
function unifyAsSatisfiesAssertion(statement, reference, substitutions, context) {
|
|
70
74
|
let unifiedAsSatisfiesAssertion = false;
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
const satisfiesAssertion = satisfiesAssertionFromStatement(statement, context);
|
|
76
|
+
const satisfiesAssertion = satisfiesAssertionFromStatement(statement, context);
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
if (satisfiesAssertion !== null) {
|
|
79
|
+
const statementString = statement.getString();
|
|
80
|
+
|
|
81
|
+
context.trace(`Unifying the '${statementString}' statement as a satisfies assertion...`);
|
|
82
|
+
|
|
83
|
+
const stated = true,
|
|
84
|
+
assignments = null;
|
|
85
|
+
|
|
86
|
+
satisfiesAssertion.verifySignature(assignments, stated, context);
|
|
77
87
|
|
|
78
|
-
|
|
88
|
+
if (reference === null) {
|
|
89
|
+
const stepsOrSubproofs = context.getStepsOrSubproofs();
|
|
79
90
|
|
|
91
|
+
unifiedAsSatisfiesAssertion = backwardsSome(stepsOrSubproofs, (stepsOrSubproof) => {
|
|
92
|
+
const satisfiedAssertionUnified = stepsOrSubproof.unifySatisfiesAssertion(satisfiesAssertion, context);
|
|
93
|
+
|
|
94
|
+
if (satisfiedAssertionUnified) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
80
99
|
const axiomLemmaTheoremConjecture = context.findAxiomLemmaTheoremConjectureByReference(reference);
|
|
81
100
|
|
|
82
101
|
if (axiomLemmaTheoremConjecture !== null) {
|
|
83
102
|
reference = satisfiesAssertion.getReference();
|
|
84
103
|
|
|
85
|
-
const axiom = context.findAxiomByReference(reference)
|
|
86
|
-
substitutions = Substitutions.fromNothing(),
|
|
87
|
-
axiomLemmaTheoremConjectureUnified = axiom.unifyAxiomLemmaTheoremConjecture(axiomLemmaTheoremConjecture, substitutions, context);
|
|
104
|
+
const axiom = context.findAxiomByReference(reference);
|
|
88
105
|
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
106
|
+
if (axiom !== null) {
|
|
107
|
+
const substitutions = Substitutions.fromNothing(),
|
|
108
|
+
axiomLemmaTheoremConjectureUnified = axiom.unifyAxiomLemmaTheoremConjecture(axiomLemmaTheoremConjecture, substitutions, context);
|
|
91
109
|
|
|
92
|
-
|
|
110
|
+
if (axiomLemmaTheoremConjectureUnified) {
|
|
111
|
+
const substitutionsMatch = satisfiesAssertion.matchSubstitutions(substitutions, context);
|
|
112
|
+
|
|
113
|
+
unifiedAsSatisfiesAssertion = substitutionsMatch; ///
|
|
114
|
+
}
|
|
93
115
|
}
|
|
94
116
|
}
|
|
117
|
+
}
|
|
95
118
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
119
|
+
if (unifiedAsSatisfiesAssertion) {
|
|
120
|
+
context.debug(`...unified the '${statementString}' statement as a satisfies assertion.`);
|
|
99
121
|
}
|
|
100
122
|
}
|
|
101
123
|
|
|
102
124
|
return unifiedAsSatisfiesAssertion;
|
|
103
125
|
}
|
|
104
126
|
|
|
105
|
-
function
|
|
127
|
+
function unifyWithAxiomLemmaTheoremOrConjecture(statement, reference, substitutions, context) {
|
|
106
128
|
let unifiedWithAxiomLemmaTheoremOrConjecture = false;
|
|
107
129
|
|
|
108
130
|
if (reference !== null) {
|
|
@@ -115,10 +137,9 @@ function unifyAWithAxiomLemmaTheoremOrConjecture(statement, reference, substitut
|
|
|
115
137
|
|
|
116
138
|
context.trace(`Unifying the '${statementString}' statement with the '${axiomLemmaTheoremConjectureString}' axiom, lemma, theorem or conjecture...`);
|
|
117
139
|
|
|
118
|
-
const stepsOrSubproofs = context.getStepsOrSubproofs()
|
|
119
|
-
specificSubstitutions = Substitutions.fromNothing();
|
|
140
|
+
const stepsOrSubproofs = context.getStepsOrSubproofs();
|
|
120
141
|
|
|
121
|
-
substitutions =
|
|
142
|
+
substitutions = Substitutions.fromNothing();
|
|
122
143
|
|
|
123
144
|
const statementAndStepsUnified = axiomLemmaTheoremConjecture.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context);
|
|
124
145
|
|
|
@@ -240,16 +261,16 @@ function unifyAsPropertyAssertion(statement, reference, substitutions, context)
|
|
|
240
261
|
}
|
|
241
262
|
|
|
242
263
|
function unifyWithStepsOrSubproofs(statement, reference, substitutions, context) {
|
|
243
|
-
let
|
|
264
|
+
let unifiedWithStepOrSubproofs = false;
|
|
244
265
|
|
|
245
266
|
if (reference === null) {
|
|
246
267
|
const stepsOrSubproofs = context.getStepsOrSubproofs(),
|
|
247
268
|
statementUnifiedWithSteps = statement.unifyWithStepsOrSubproofs(stepsOrSubproofs, context);
|
|
248
269
|
|
|
249
|
-
|
|
270
|
+
unifiedWithStepOrSubproofs = statementUnifiedWithSteps; ///
|
|
250
271
|
}
|
|
251
272
|
|
|
252
|
-
return
|
|
273
|
+
return unifiedWithStepOrSubproofs;
|
|
253
274
|
}
|
|
254
275
|
|
|
255
276
|
function unifyWithSatisfiesAssertion(statement, reference, substitutions, context) {
|
|
@@ -274,8 +295,8 @@ function unifyWithSatisfiesAssertion(statement, reference, substitutions, contex
|
|
|
274
295
|
return satisfiesAssertions;
|
|
275
296
|
}, []);
|
|
276
297
|
|
|
277
|
-
unifiedWithSatisfiesAssertion = satisfiesAssertions
|
|
278
|
-
const statementUnified = satisfiesAssertion.
|
|
298
|
+
unifiedWithSatisfiesAssertion = backwardsSome(satisfiesAssertions, (satisfiesAssertion) => {
|
|
299
|
+
const statementUnified = satisfiesAssertion.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context);
|
|
279
300
|
|
|
280
301
|
if (statementUnified) {
|
|
281
302
|
return true;
|
|
@@ -286,10 +307,10 @@ function unifyWithSatisfiesAssertion(statement, reference, substitutions, contex
|
|
|
286
307
|
}
|
|
287
308
|
|
|
288
309
|
const unifyMixins = [
|
|
289
|
-
|
|
290
|
-
|
|
310
|
+
unifyWithRule,
|
|
311
|
+
unifyWithReference,
|
|
291
312
|
unifyAsSatisfiesAssertion,
|
|
292
|
-
|
|
313
|
+
unifyWithAxiomLemmaTheoremOrConjecture,
|
|
293
314
|
unifyAsEquality,
|
|
294
315
|
unifyAsJudgement,
|
|
295
316
|
unifyAsTypeAssertion,
|
package/src/node/conclusion.js
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import NonTerminalNode from "../node/nonTerminal";
|
|
4
4
|
|
|
5
|
-
import { STATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { NONSENSE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class ConclusionNode extends NonTerminalNode {
|
|
8
|
+
getNonsenseNode() {
|
|
9
|
+
const ruleName = NONSENSE_RULE_NAME,
|
|
10
|
+
nonsenseNode = this.getNodeByRuleName(ruleName);
|
|
11
|
+
|
|
12
|
+
return nonsenseNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
getStatementNode() {
|
|
9
16
|
const ruleName = STATEMENT_RULE_NAME,
|
|
10
17
|
statementNode = this.getNodeByRuleName(ruleName);
|
package/src/node/deduction.js
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import NonTerminalNode from "../node/nonTerminal";
|
|
4
4
|
|
|
5
|
-
import { STATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { NONSENSE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class DeductionNode extends NonTerminalNode {
|
|
8
|
+
getNonsenseNode() {
|
|
9
|
+
const ruleName = NONSENSE_RULE_NAME,
|
|
10
|
+
nonsenseNode = this.getNodeByRuleName(ruleName);
|
|
11
|
+
|
|
12
|
+
return nonsenseNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
getStatementNode() {
|
|
9
16
|
const ruleName = STATEMENT_RULE_NAME,
|
|
10
17
|
statementNode = this.getNodeByRuleName(ruleName);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import NonTerminalNode from "../node/nonTerminal";
|
|
4
|
+
|
|
5
|
+
export default class NonsenseNode extends NonTerminalNode {
|
|
6
|
+
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(NonsenseNode, ruleName, childNodes, opacity, precedence); }
|
|
7
|
+
}
|
package/src/node/premise.js
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import NonTerminalNode from "../node/nonTerminal";
|
|
4
4
|
|
|
5
|
-
import { STATEMENT_RULE_NAME, PROCEDURE_CALL_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { NONSENSE_RULE_NAME, STATEMENT_RULE_NAME, PROCEDURE_CALL_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class PremiseNode extends NonTerminalNode {
|
|
8
|
+
getNonsenseNode() {
|
|
9
|
+
const ruleName = NONSENSE_RULE_NAME,
|
|
10
|
+
nonsenseNode = this.getNodeByRuleName(ruleName);
|
|
11
|
+
|
|
12
|
+
return nonsenseNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
getStatementNode() {
|
|
9
16
|
const ruleName = STATEMENT_RULE_NAME,
|
|
10
17
|
statementNode = this.getNodeByRuleName(ruleName);
|
package/src/node/step.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import NonTerminalNode from "../node/nonTerminal";
|
|
4
4
|
|
|
5
|
-
import { REFERENCE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { NONSENSE_RULE_NAME, REFERENCE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class StepNode extends NonTerminalNode {
|
|
8
8
|
isStepNode() {
|
|
@@ -17,6 +17,13 @@ export default class StepNode extends NonTerminalNode {
|
|
|
17
17
|
return subproofNode;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
getNonsenseNode() {
|
|
21
|
+
const ruleName = NONSENSE_RULE_NAME,
|
|
22
|
+
nonsenseNode = this.getNodeByRuleName(ruleName);
|
|
23
|
+
|
|
24
|
+
return nonsenseNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
getStatementNode() {
|
|
21
28
|
const ruleName = STATEMENT_RULE_NAME,
|
|
22
29
|
statementNode = this.getNodeByRuleName(ruleName);
|
package/src/node/supposition.js
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import NonTerminalNode from "../node/nonTerminal";
|
|
4
4
|
|
|
5
|
-
import { STATEMENT_RULE_NAME, PROCEDURE_CALL_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { NONSENSE_RULE_NAME, STATEMENT_RULE_NAME, PROCEDURE_CALL_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class SuppositionNode extends NonTerminalNode {
|
|
8
|
+
getNonsenseNode() {
|
|
9
|
+
const ruleName = NONSENSE_RULE_NAME,
|
|
10
|
+
nonsenseNode = this.getNodeByRuleName(ruleName);
|
|
11
|
+
|
|
12
|
+
return nonsenseNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
getStatementNode() {
|
|
9
16
|
const ruleName = STATEMENT_RULE_NAME,
|
|
10
17
|
statementNode = this.getNodeByRuleName(ruleName);
|
|
@@ -14,6 +14,7 @@ import LabelNode from "./node/label";
|
|
|
14
14
|
import LabelsNode from "./node/labels";
|
|
15
15
|
import PremiseNode from "./node/premise";
|
|
16
16
|
import TheoremNode from "./node/theorem";
|
|
17
|
+
import NonsenseNode from "./node/nonsense";
|
|
17
18
|
import ArgumentNode from "./node/argument";
|
|
18
19
|
import SubproofNode from "./node/subproof";
|
|
19
20
|
import PropertyNode from "./node/property";
|
|
@@ -74,6 +75,7 @@ import { RULE_RULE_NAME,
|
|
|
74
75
|
LABELS_RULE_NAME,
|
|
75
76
|
THEOREM_RULE_NAME,
|
|
76
77
|
PREMISE_RULE_NAME,
|
|
78
|
+
NONSENSE_RULE_NAME,
|
|
77
79
|
ARGUMENT_RULE_NAME,
|
|
78
80
|
SUBPROOF_RULE_NAME,
|
|
79
81
|
PROPERTY_RULE_NAME,
|
|
@@ -140,6 +142,7 @@ const nonTerminalNodeMap = {
|
|
|
140
142
|
[SUBPROOF_RULE_NAME]: SubproofNode,
|
|
141
143
|
[EQUALITY_RULE_NAME]: EqualityNode,
|
|
142
144
|
[VARIABLE_RULE_NAME]: VariableNode,
|
|
145
|
+
[NONSENSE_RULE_NAME]: NonsenseNode,
|
|
143
146
|
[META_TYPE_RULE_NAME]: MetaTypeNode,
|
|
144
147
|
[SIGNATURE_RULE_NAME]: SignatureNode,
|
|
145
148
|
[REFERENCE_RULE_NAME]: ReferenceNode,
|
package/src/ruleNames.js
CHANGED
|
@@ -19,6 +19,7 @@ export const PROPERTY_RULE_NAME = "property";
|
|
|
19
19
|
export const EQUALITY_RULE_NAME = "equality";
|
|
20
20
|
export const VARIABLE_RULE_NAME = "variable";
|
|
21
21
|
export const SUBPROOF_RULE_NAME = "subproof";
|
|
22
|
+
export const NONSENSE_RULE_NAME = "nonsense";
|
|
22
23
|
export const SIGNATURE_RULE_NAME = "signature";
|
|
23
24
|
export const META_TYPE_RULE_NAME = "metaType";
|
|
24
25
|
export const PARAMETER_RULE_NAME = "parameter";
|
package/src/substitutions.js
CHANGED
|
@@ -216,6 +216,16 @@ export default class Substitutions {
|
|
|
216
216
|
return match;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
removeTrivialSubstitutions() {
|
|
220
|
+
filter(this.array, (substitution) => {
|
|
221
|
+
const trivial = substitution.isTrivial();
|
|
222
|
+
|
|
223
|
+
if (!trivial) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
219
229
|
clear() {
|
|
220
230
|
clear(this.array);
|
|
221
231
|
|
|
@@ -1,34 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { nodeAsString, nodesAsString } from "./string";
|
|
4
|
-
|
|
5
3
|
export function subproofStringFromSubproofNode(subproofNode, fileContext) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
suppositionStatementsString = nodesAsString(suppositionStatementNodes, tokens),
|
|
10
|
-
lastStepStatementString = nodeAsString(lastStepStatementNode, tokens),
|
|
11
|
-
subproofString = `[${suppositionStatementsString}]...${lastStepStatementString}`;
|
|
4
|
+
const suppositionStatementsOrNonsenseString = suppositionStatementOrNonsenseStringFromSubproofNode(subproofNode, fileContext),
|
|
5
|
+
lastStatementOrNonsenseString = lastStatementOrNonsenseStringFromSubproofNode(subproofNode, fileContext),
|
|
6
|
+
subproofString = `[${suppositionStatementsOrNonsenseString}]...${lastStatementOrNonsenseString}`;
|
|
12
7
|
|
|
13
8
|
return subproofString;
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
function
|
|
11
|
+
function suppositionStatementOrNonsenseStringFromSubproofNode(subproofNode, fileContext) {
|
|
12
|
+
const suppositionNodes = subproofNode.getSuppositionNodes(),
|
|
13
|
+
suppositionStatementsOrNonsenseString = suppositionNodes.reduce((suppositionStatementsOrNonsenseString, suppositionNode) => {
|
|
14
|
+
const suppositionOrStepNode = suppositionNode, ///
|
|
15
|
+
statementOrNonsenseString = statementOrNonsenseStringFromSuppositionOrStepNode(suppositionOrStepNode, fileContext),
|
|
16
|
+
suppositionStatementOrNonsenseString = statementOrNonsenseString; ///
|
|
17
|
+
|
|
18
|
+
suppositionStatementsOrNonsenseString = (suppositionStatementsOrNonsenseString !== null) ?
|
|
19
|
+
`${suppositionStatementsOrNonsenseString}, ${suppositionStatementOrNonsenseString}` :
|
|
20
|
+
suppositionStatementOrNonsenseString; ///
|
|
21
|
+
|
|
22
|
+
return suppositionStatementsOrNonsenseString;
|
|
23
|
+
}, null);
|
|
24
|
+
|
|
25
|
+
return suppositionStatementsOrNonsenseString;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function lastStatementOrNonsenseStringFromSubproofNode(subproofNode, fileContext) {
|
|
17
29
|
const lastStepNode = subproofNode.getLastStepNode(),
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
suppositionOrStepNode = lastStepNode, ///
|
|
31
|
+
statementOrNonsenseString = statementOrNonsenseStringFromSuppositionOrStepNode(suppositionOrStepNode, fileContext),
|
|
32
|
+
lastStatementOrNonsenseString = statementOrNonsenseString; ///
|
|
20
33
|
|
|
21
|
-
return
|
|
34
|
+
return lastStatementOrNonsenseString;
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
suppositionNodeStatementNodes = suppositionNodes.map((suppositionNode) => {
|
|
27
|
-
const suppositionNodeStatementNode = suppositionNode.getStatementNode();
|
|
37
|
+
function statementOrNonsenseStringFromSuppositionOrStepNode(suppositionOrStepNode, fileContext) {
|
|
38
|
+
let statementOrNonsenseString;
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
suppositionStatementNodes = suppositionNodeStatementNodes; ///
|
|
40
|
+
const nonsenseNode = suppositionOrStepNode.getNonsenseNode(),
|
|
41
|
+
statementNode = suppositionOrStepNode.getStatementNode();
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
if (false) {
|
|
44
|
+
///
|
|
45
|
+
} else if (nonsenseNode !== null) {
|
|
46
|
+
const nonsenseString = fileContext.nodeAsString(nonsenseNode);
|
|
47
|
+
|
|
48
|
+
statementOrNonsenseString = nonsenseString; ///
|
|
49
|
+
} else if (statementNode !== null) {
|
|
50
|
+
const statementString = fileContext.nodeAsString(statementNode);
|
|
51
|
+
|
|
52
|
+
statementOrNonsenseString = statementString; ///
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return statementOrNonsenseString;
|
|
56
|
+
}
|