occam-verify-cli 1.0.437 → 1.0.444
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/context/file.js +38 -35
- package/lib/context/local.js +10 -10
- package/lib/context/release.js +6 -6
- package/lib/context/temporary.js +14 -14
- package/lib/element/assertion/contained.js +45 -45
- package/lib/element/assertion/defined.js +13 -13
- package/lib/element/assertion/property.js +23 -22
- package/lib/element/assertion/satisfies.js +7 -6
- package/lib/element/assertion/subproof.js +20 -17
- package/lib/element/assertion/type.js +3 -2
- package/lib/element/assertion.js +1 -23
- package/lib/element/assumption.js +24 -22
- package/lib/element/axiom.js +9 -12
- package/lib/element/axiomLemmaTheoremConjecture.js +32 -32
- package/lib/element/{statement/combinator → combinator}/bracketed.js +16 -16
- package/lib/element/combinator.js +229 -0
- package/lib/element/conclusion.js +11 -9
- package/lib/element/{term/constructor → constructor}/bracketed.js +5 -5
- package/lib/element/constructor.js +232 -0
- package/lib/element/declaration/combinator.js +2 -16
- package/lib/element/declaration/complexType.js +12 -12
- package/lib/element/declaration/constructor.js +13 -11
- package/lib/element/declaration/simpleType.js +4 -4
- package/lib/element/declaration/typePrefix.js +2 -2
- package/lib/element/declaration/variable.js +3 -3
- package/lib/element/deduction.js +11 -9
- package/lib/element/derivation.js +5 -8
- package/lib/element/equivalence.js +10 -10
- package/lib/element/equivalences.js +5 -5
- package/lib/element/frame.js +32 -38
- package/lib/element/hypothesis.js +3 -3
- package/lib/element/judgement.js +6 -4
- package/lib/element/label.js +16 -18
- package/lib/element/metaLemmaMetatheorem.js +5 -5
- package/lib/element/metaType.js +17 -80
- package/lib/element/metavariable.js +34 -34
- package/lib/element/parameter.js +3 -3
- package/lib/element/premise.js +43 -52
- package/lib/element/property.js +9 -9
- package/lib/element/propertyRelation.js +13 -13
- package/lib/element/reference.js +14 -17
- package/lib/element/rule.js +26 -50
- package/lib/element/signature.js +11 -11
- package/lib/element/statement.js +54 -56
- package/lib/element/step.js +79 -51
- package/lib/element/subDerivation.js +7 -10
- package/lib/element/subproof.js +6 -14
- package/lib/element/substitution/frame.js +1 -7
- package/lib/element/substitution/reference.js +2 -3
- package/lib/element/substitution/statement.js +44 -15
- package/lib/element/substitution/term.js +10 -57
- package/lib/element/substitution.js +5 -11
- package/lib/element/substitutions.js +29 -29
- package/lib/element/supposition.js +63 -55
- package/lib/element/term.js +21 -34
- package/lib/element/type.js +47 -60
- package/lib/element/typePrefix.js +5 -5
- package/lib/element/variable.js +9 -9
- package/lib/element.js +27 -3
- package/lib/metaTypes.js +52 -0
- package/lib/node/axiomLemmaTheoremConjecture.js +9 -9
- package/lib/node/body/axiom.js +2 -25
- package/lib/node/body/conjecture.js +2 -25
- package/lib/node/body/lemma.js +2 -25
- package/lib/node/body/metaLemma.js +2 -25
- package/lib/node/body/metatheorem.js +2 -25
- package/lib/node/body/rule.js +15 -1
- package/lib/node/body/theorem.js +2 -25
- package/lib/node/body.js +25 -2
- package/lib/node/combinator.js +11 -2
- package/lib/node/constructor.js +11 -2
- package/lib/node/declaration/combinator.js +5 -5
- package/lib/node/declaration/constructor.js +8 -8
- package/lib/node/declaration/property.js +15 -15
- package/lib/node/declaration/simpleType.js +31 -31
- package/lib/node/declaration/variable.js +8 -8
- package/lib/node/equality.js +8 -8
- package/lib/node/frame.js +20 -20
- package/lib/node/header.js +22 -22
- package/lib/node/metaLemmaMetaTheorem.js +16 -16
- package/lib/node/metavariable.js +15 -15
- package/lib/node/property.js +8 -8
- package/lib/node/propertyRelation.js +8 -8
- package/lib/node/rule.js +16 -16
- package/lib/node/statement.js +12 -12
- package/lib/node/step.js +22 -22
- package/lib/node/subproof.js +8 -8
- package/lib/node/substitution/frame.js +19 -19
- package/lib/node/substitution/statement.js +19 -19
- package/lib/node/substitution/term.js +19 -19
- package/lib/node/term.js +35 -35
- package/lib/preamble.js +5 -5
- package/lib/process/instantiate.js +20 -2
- package/lib/process/unify.js +39 -42
- package/lib/process/validate.js +431 -0
- package/lib/process/verify.js +44 -135
- package/lib/types.js +27 -0
- package/lib/utilities/brackets.js +4 -4
- package/lib/utilities/element.js +100 -61
- package/lib/utilities/instance.js +18 -18
- package/lib/utilities/statement.js +11 -16
- package/lib/utilities/string.js +21 -10
- package/lib/utilities/unification.js +237 -0
- package/lib/utilities/validation.js +251 -0
- package/package.json +6 -6
- package/src/context/file.js +37 -31
- package/src/context/local.js +8 -8
- package/src/context/release.js +9 -6
- package/src/context/temporary.js +11 -11
- package/src/element/assertion/contained.js +19 -20
- package/src/element/assertion/defined.js +11 -12
- package/src/element/assertion/property.js +20 -20
- package/src/element/assertion/satisfies.js +6 -6
- package/src/element/assertion/subproof.js +17 -15
- package/src/element/assertion/type.js +2 -2
- package/src/element/assertion.js +0 -2
- package/src/element/assumption.js +22 -19
- package/src/element/axiom.js +7 -11
- package/src/element/axiomLemmaTheoremConjecture.js +36 -36
- package/src/element/{statement/combinator → combinator}/bracketed.js +7 -7
- package/src/element/combinator.js +90 -0
- package/src/element/conclusion.js +12 -10
- package/src/element/{term/constructor → constructor}/bracketed.js +5 -5
- package/src/element/{term/constructor.js → constructor.js} +17 -25
- package/src/element/declaration/combinator.js +1 -22
- package/src/element/declaration/complexType.js +11 -11
- package/src/element/declaration/constructor.js +13 -10
- package/src/element/declaration/simpleType.js +3 -3
- package/src/element/declaration/typePrefix.js +1 -1
- package/src/element/declaration/variable.js +2 -2
- package/src/element/deduction.js +12 -9
- package/src/element/derivation.js +4 -8
- package/src/element/equivalence.js +8 -8
- package/src/element/equivalences.js +4 -4
- package/src/element/frame.js +28 -30
- package/src/element/hypothesis.js +2 -2
- package/src/element/judgement.js +6 -3
- package/src/element/label.js +14 -21
- package/src/element/metaLemmaMetatheorem.js +4 -3
- package/src/element/metaType.js +9 -45
- package/src/element/metavariable.js +29 -31
- package/src/element/parameter.js +2 -2
- package/src/element/premise.js +56 -62
- package/src/element/property.js +6 -6
- package/src/element/propertyRelation.js +11 -11
- package/src/element/reference.js +12 -21
- package/src/element/rule.js +28 -72
- package/src/element/signature.js +10 -9
- package/src/element/statement.js +69 -56
- package/src/element/step.js +89 -51
- package/src/element/subDerivation.js +6 -10
- package/src/element/subproof.js +4 -12
- package/src/element/substitution/frame.js +0 -2
- package/src/element/substitution/reference.js +1 -5
- package/src/element/substitution/statement.js +44 -14
- package/src/element/substitution/term.js +10 -13
- package/src/element/substitution.js +3 -5
- package/src/element/substitutions.js +48 -30
- package/src/element/supposition.js +88 -70
- package/src/element/term.js +18 -28
- package/src/element/type.js +42 -36
- package/src/element/typePrefix.js +3 -3
- package/src/element/variable.js +7 -7
- package/src/element.js +15 -1
- package/src/metaTypes.js +42 -0
- package/src/node/axiomLemmaTheoremConjecture.js +6 -6
- package/src/node/body/axiom.js +0 -21
- package/src/node/body/conjecture.js +0 -23
- package/src/node/body/lemma.js +0 -23
- package/src/node/body/metaLemma.js +0 -23
- package/src/node/body/metatheorem.js +0 -23
- package/src/node/body/rule.js +12 -0
- package/src/node/body/theorem.js +0 -23
- package/src/node/body.js +23 -0
- package/src/node/combinator.js +9 -0
- package/src/node/constructor.js +9 -0
- package/src/node/declaration/combinator.js +5 -5
- package/src/node/declaration/constructor.js +8 -8
- package/src/node/declaration/property.js +14 -14
- package/src/node/declaration/simpleType.js +31 -31
- package/src/node/declaration/variable.js +7 -7
- package/src/node/equality.js +7 -7
- package/src/node/frame.js +21 -21
- package/src/node/header.js +22 -22
- package/src/node/metaLemmaMetaTheorem.js +14 -14
- package/src/node/metavariable.js +14 -14
- package/src/node/property.js +7 -7
- package/src/node/propertyRelation.js +7 -7
- package/src/node/rule.js +15 -15
- package/src/node/statement.js +12 -12
- package/src/node/step.js +21 -21
- package/src/node/subproof.js +7 -7
- package/src/node/substitution/frame.js +18 -18
- package/src/node/substitution/statement.js +18 -18
- package/src/node/substitution/term.js +18 -18
- package/src/node/term.js +34 -34
- package/src/preamble.js +4 -4
- package/src/process/instantiate.js +12 -0
- package/src/process/unify.js +53 -57
- package/src/process/validate.js +316 -0
- package/src/process/verify.js +50 -138
- package/src/types.js +18 -0
- package/src/utilities/brackets.js +10 -6
- package/src/utilities/element.js +138 -91
- package/src/utilities/instance.js +18 -18
- package/src/utilities/statement.js +27 -28
- package/src/utilities/string.js +34 -20
- package/src/{mixins/step/unify.js → utilities/unification.js} +82 -68
- package/src/utilities/validation.js +369 -0
- package/lib/element/statement/combinator.js +0 -105
- package/lib/element/term/constructor.js +0 -172
- package/lib/mixins/statement/verify.js +0 -198
- package/lib/mixins/step/unify.js +0 -228
- package/lib/mixins/term/verify.js +0 -65
- package/src/element/statement/combinator.js +0 -59
- package/src/mixins/statement/verify.js +0 -295
- package/src/mixins/term/verify.js +0 -81
|
@@ -81,16 +81,45 @@ export default class AxiomLemmaTheoremConjecture extends Element {
|
|
|
81
81
|
return supposition;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
84
|
+
compareMetavariableName(metavariableName) {
|
|
85
|
+
const comparesToMetavariableName = this.labels.some((label) => {
|
|
86
|
+
const labelComparesToMetavariableName = label.compareMetavariableName(metavariableName);
|
|
87
87
|
|
|
88
|
-
if (
|
|
88
|
+
if (labelComparesToMetavariableName) {
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
return
|
|
93
|
+
return comparesToMetavariableName;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
correlateHypotheses(context) {
|
|
97
|
+
let correlatesToHypotheses;
|
|
98
|
+
|
|
99
|
+
const hypothetical = this.isHypothetical();
|
|
100
|
+
|
|
101
|
+
if (hypothetical) {
|
|
102
|
+
const steps = context.getSteps(),
|
|
103
|
+
topLevelAssertionString = this.getString(); ///
|
|
104
|
+
|
|
105
|
+
context.trace(`Correlating the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture...`, this.node);
|
|
106
|
+
|
|
107
|
+
correlatesToHypotheses = correlate(this.hypotheses, steps, (hypothesis, step) => {
|
|
108
|
+
const hypothesesEqualToStep = hypothesis.isEqualToStep(step, context);
|
|
109
|
+
|
|
110
|
+
if (hypothesesEqualToStep) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (correlatesToHypotheses) {
|
|
116
|
+
context.debug(`...correlated the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture.`, this.node);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
correlatesToHypotheses = true
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return correlatesToHypotheses;
|
|
94
123
|
}
|
|
95
124
|
|
|
96
125
|
verify() {
|
|
@@ -171,35 +200,6 @@ export default class AxiomLemmaTheoremConjecture extends Element {
|
|
|
171
200
|
return proofVerifies;
|
|
172
201
|
}
|
|
173
202
|
|
|
174
|
-
correlateHypotheses(context) {
|
|
175
|
-
let hypothesesCorrelate;
|
|
176
|
-
|
|
177
|
-
const hypothetical = this.isHypothetical();
|
|
178
|
-
|
|
179
|
-
if (hypothetical) {
|
|
180
|
-
const steps = context.getSteps(),
|
|
181
|
-
topLevelAssertionString = this.string; ///
|
|
182
|
-
|
|
183
|
-
context.trace(`Correlating the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture...`, this.node);
|
|
184
|
-
|
|
185
|
-
hypothesesCorrelate = correlate(this.hypotheses, steps, (hypothesis, step) => {
|
|
186
|
-
const hypothesesEqualToStep = hypothesis.isEqualToStep(step, context);
|
|
187
|
-
|
|
188
|
-
if (hypothesesEqualToStep) {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
if (hypothesesCorrelate) {
|
|
194
|
-
context.debug(`...correlated the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture.`, this.node);
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
hypothesesCorrelate = true
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return hypothesesCorrelate;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
203
|
unifyStatementWithDeduction(statement, substitutions, context) {
|
|
204
204
|
let statementUnifiesWithDeduction = false;
|
|
205
205
|
|
|
@@ -215,9 +215,9 @@ export default class AxiomLemmaTheoremConjecture extends Element {
|
|
|
215
215
|
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context) {
|
|
216
216
|
let statementAndStepsOrSubproofsUnifies = false;
|
|
217
217
|
|
|
218
|
-
const
|
|
218
|
+
const correlatesToHypotheses = this.correlateHypotheses(context);
|
|
219
219
|
|
|
220
|
-
if (
|
|
220
|
+
if (correlatesToHypotheses) {
|
|
221
221
|
const statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, context);
|
|
222
222
|
|
|
223
223
|
if (statementUnifiesWithDeduction) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Combinator from "../combinator";
|
|
4
4
|
|
|
5
|
-
import { define } from "
|
|
6
|
-
import {
|
|
5
|
+
import { define } from "../../elements";
|
|
6
|
+
import { bracketedCombinatorFromNothing } from "../../utilities/instance";
|
|
7
7
|
|
|
8
|
-
export default define(class
|
|
8
|
+
export default define(class BracketedCombinator extends Combinator {
|
|
9
9
|
unifyStatement(statement, assignments, stated, context) {
|
|
10
10
|
let statementUnifies;
|
|
11
11
|
|
|
@@ -22,11 +22,11 @@ export default define(class BracketedCombinatorStatement extends CombinatorState
|
|
|
22
22
|
return statementUnifies;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
static name = "
|
|
25
|
+
static name = "BracketedCombinator";
|
|
26
26
|
|
|
27
27
|
static fromNothing() {
|
|
28
|
-
const
|
|
28
|
+
const bracketedCombinator = bracketedCombinatorFromNothing();
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return bracketedCombinator;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Element from "../element";
|
|
4
|
+
|
|
5
|
+
import { define } from "../elements";
|
|
6
|
+
import { verifyCombinator } from "../process/verify";
|
|
7
|
+
import { unifyStatementWithCombinator } from "../process/unify";
|
|
8
|
+
import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
|
|
9
|
+
|
|
10
|
+
export default define(class Combinator extends Element {
|
|
11
|
+
constructor(context, string, node, statement) {
|
|
12
|
+
super(context, string, node)
|
|
13
|
+
|
|
14
|
+
this.statement = statement;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getStatement() {
|
|
18
|
+
return this.statement;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
verify() {
|
|
22
|
+
let verifies;
|
|
23
|
+
|
|
24
|
+
const node = this.getNode(),
|
|
25
|
+
context = this.getContext(),
|
|
26
|
+
combinatorString = this.getString(); ///
|
|
27
|
+
|
|
28
|
+
context.trace(`Verifying the '${combinatorString}' combinator...`, node);
|
|
29
|
+
|
|
30
|
+
const combinator = this, ///
|
|
31
|
+
combinatorVerifies = verifyCombinator(combinator, context);
|
|
32
|
+
|
|
33
|
+
if (combinatorVerifies) {
|
|
34
|
+
verifies = true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (verifies) {
|
|
38
|
+
context.debug(`...verified the '${combinatorString}' combinator.`, node);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return verifies;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
unifyStatement(statement, assignments, stated, context) {
|
|
45
|
+
let statementUnifies;
|
|
46
|
+
|
|
47
|
+
const statementString = statement.getString(),
|
|
48
|
+
combinatorString = this.getString(); ///
|
|
49
|
+
|
|
50
|
+
context.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
|
|
51
|
+
|
|
52
|
+
const specifiContext = context; ///
|
|
53
|
+
|
|
54
|
+
context = this.getContext();
|
|
55
|
+
|
|
56
|
+
const generalContext = context; ///
|
|
57
|
+
|
|
58
|
+
context = specifiContext; ///
|
|
59
|
+
|
|
60
|
+
const combinator = this, ///
|
|
61
|
+
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, assignments, stated, generalContext, specifiContext);
|
|
62
|
+
|
|
63
|
+
statementUnifies = statementUnifiesWithCombinator; ///
|
|
64
|
+
|
|
65
|
+
if (statementUnifies) {
|
|
66
|
+
context.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return statementUnifies;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
toJSON() {
|
|
73
|
+
const statementJSON = statementToStatementJSON(this.statement),
|
|
74
|
+
statement = statementJSON, ///
|
|
75
|
+
json = {
|
|
76
|
+
statement,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return json;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static name = "Combinator";
|
|
83
|
+
|
|
84
|
+
static fromJSON(json, context) {
|
|
85
|
+
const statement = statementFromJSON(json, context),
|
|
86
|
+
combinator = new Combinator(statement);
|
|
87
|
+
|
|
88
|
+
return combinator;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
@@ -24,25 +24,27 @@ export default define(class Conclusion extends Element {
|
|
|
24
24
|
|
|
25
25
|
context = temporaryContext; ///
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const node = this.getNode(),
|
|
28
|
+
conclusionString = this.getString(); ///
|
|
28
29
|
|
|
29
|
-
context.trace(`Verifying the '${conclusionString}' conclusion...`,
|
|
30
|
+
context.trace(`Verifying the '${conclusionString}' conclusion...`, node);
|
|
30
31
|
|
|
31
|
-
if (this.statement
|
|
32
|
+
if (this.statement === null) {
|
|
33
|
+
context.debug(`Unable to verify the '${conclusionString}' conclusion because it is nonsense.`, node);
|
|
34
|
+
} else {
|
|
32
35
|
const stated = true,
|
|
33
36
|
assignments = null,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
verifies = statementVerifies; ///
|
|
37
|
+
statementValidates = this.statement.validate(assignments, stated, context);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (statementValidates) {
|
|
40
|
+
verifies = true;
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
if (verifies) {
|
|
43
|
-
this.context
|
|
45
|
+
this.setContext(context);
|
|
44
46
|
|
|
45
|
-
context.debug(`...verified the '${conclusionString}' conclusion.`,
|
|
47
|
+
context.debug(`...verified the '${conclusionString}' conclusion.`, node);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
return verifies;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import elements from "
|
|
3
|
+
import elements from "../../elements";
|
|
4
4
|
import Constructor from "../constructor";
|
|
5
5
|
|
|
6
|
-
import { define } from "
|
|
7
|
-
import {
|
|
6
|
+
import { define } from "../../elements";
|
|
7
|
+
import { bracketedConstructorFromNothing } from "../../utilities/instance";
|
|
8
8
|
|
|
9
9
|
export default define(class BracketedConstructor extends Constructor {
|
|
10
10
|
unifyTerm(term, context, verifyAhead) {
|
|
@@ -55,8 +55,8 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
55
55
|
static name = "BracketedConstructor";
|
|
56
56
|
|
|
57
57
|
static fromNothing() {
|
|
58
|
-
const
|
|
58
|
+
const bracketedConstructor = bracketedConstructorFromNothing();
|
|
59
59
|
|
|
60
|
-
return
|
|
60
|
+
return bracketedConstructor;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Element from "../element";
|
|
4
4
|
|
|
5
|
-
import { define } from "
|
|
6
|
-
import {
|
|
7
|
-
import { termFromJSON, termToTermJSON } from "
|
|
5
|
+
import { define } from "../elements";
|
|
6
|
+
import { unifyTermWithConstructor } from "../process/unify";
|
|
7
|
+
import { termFromJSON, termToTermJSON } from "../utilities/json";
|
|
8
|
+
|
|
9
|
+
export default define(class Constructor extends Element {
|
|
10
|
+
constructor(context, string, node, term) {
|
|
11
|
+
super(context, string, node);
|
|
8
12
|
|
|
9
|
-
export default define(class ConstructorTerm {
|
|
10
|
-
constructor(term) {
|
|
11
13
|
this.term = term;
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -15,24 +17,22 @@ export default define(class ConstructorTerm {
|
|
|
15
17
|
return this.term;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
getType() { return this.term.getType(); }
|
|
19
|
-
|
|
20
|
-
getString() { return this.term.getString(); }
|
|
21
|
-
|
|
22
20
|
isProvisional() { return this.term.isProvisional(); }
|
|
23
21
|
|
|
22
|
+
getType() { return this.term.getType(); }
|
|
23
|
+
|
|
24
24
|
setType(type) { this.term.setType(type); }
|
|
25
25
|
|
|
26
26
|
unifyTerm(term, context, verifyAhead) {
|
|
27
27
|
let termUnifies = false;
|
|
28
28
|
|
|
29
29
|
const termString = term.getString(),
|
|
30
|
-
|
|
30
|
+
constructorString = this.getString();
|
|
31
31
|
|
|
32
|
-
context.trace(`Unifying the '${termString}' term with the '${
|
|
32
|
+
context.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`);
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
termUnifiesWithConstructor =
|
|
34
|
+
const constructor = this, ///
|
|
35
|
+
termUnifiesWithConstructor = unifyTermWithConstructor(term, constructor, context);
|
|
36
36
|
|
|
37
37
|
if (termUnifiesWithConstructor) {
|
|
38
38
|
let verifiesAhead;
|
|
@@ -47,7 +47,7 @@ export default define(class ConstructorTerm {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (termUnifies) {
|
|
50
|
-
context.debug(`...unified the '${termString}' term with the '${
|
|
50
|
+
context.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return termUnifies;
|
|
@@ -63,19 +63,11 @@ export default define(class ConstructorTerm {
|
|
|
63
63
|
return json;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
static name = "
|
|
66
|
+
static name = "Constructor";
|
|
67
67
|
|
|
68
68
|
static fromJSON(json, context) {
|
|
69
69
|
const term = termFromJSON(json, context),
|
|
70
|
-
constructor = new
|
|
71
|
-
|
|
72
|
-
return constructor;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static fromConstructorDeclarationNode(constructorDeclarationNode, context) {
|
|
76
|
-
const { Term } = elements,
|
|
77
|
-
term = Term.fromConstructorDeclarationNode(constructorDeclarationNode, context),
|
|
78
|
-
constructor = new ConstructorTerm(term);
|
|
70
|
+
constructor = new Constructor(term);
|
|
79
71
|
|
|
80
72
|
return constructor;
|
|
81
73
|
}
|
|
@@ -25,7 +25,7 @@ export default define(class CombinatorDeclaration extends Declaration {
|
|
|
25
25
|
|
|
26
26
|
context.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration...`, node);
|
|
27
27
|
|
|
28
|
-
const combinatorVerifies = this.
|
|
28
|
+
const combinatorVerifies = this.combinator.verify();
|
|
29
29
|
|
|
30
30
|
if (combinatorVerifies) {
|
|
31
31
|
context.addCombinator(this.combinator);
|
|
@@ -40,26 +40,5 @@ export default define(class CombinatorDeclaration extends Declaration {
|
|
|
40
40
|
return verifies;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
verifyCombinator() {
|
|
44
|
-
let statementVerifies;
|
|
45
|
-
|
|
46
|
-
const node = this.getNode(),
|
|
47
|
-
context = this.getContext(),
|
|
48
|
-
combinatorString = this.combinator.getString();
|
|
49
|
-
|
|
50
|
-
context.trace(`Verifying the '${combinatorString}' combinator...`, node);
|
|
51
|
-
|
|
52
|
-
const statement = this.combinator.getStatement(),
|
|
53
|
-
statementNode = statement.getNode();
|
|
54
|
-
|
|
55
|
-
statementVerifies = verifyStatement(statementNode, context);
|
|
56
|
-
|
|
57
|
-
if (statementVerifies) {
|
|
58
|
-
context.debug(`...verified the '${combinatorString}' combinator.`, node);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return statementVerifies;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
43
|
static name = "CombinatorDeclaration";
|
|
65
44
|
});
|
|
@@ -112,10 +112,10 @@ export default define(class ComplexTypeDeclaration extends Declaration {
|
|
|
112
112
|
|
|
113
113
|
const nominalTypeName = superType.getNominalTypeName(),
|
|
114
114
|
typeName = nominalTypeName, ///
|
|
115
|
-
|
|
115
|
+
typeComparesToTypeName = this.type.compareTypeName(typeName);
|
|
116
116
|
|
|
117
|
-
if (
|
|
118
|
-
context.trace(`The super-type's name
|
|
117
|
+
if (typeComparesToTypeName) {
|
|
118
|
+
context.trace(`The super-type's name compares to the ${typeName}' complex type's name.`, node);
|
|
119
119
|
} else {
|
|
120
120
|
const oldSuperType = superType;
|
|
121
121
|
|
|
@@ -237,9 +237,9 @@ export default define(class ComplexTypeDeclaration extends Declaration {
|
|
|
237
237
|
|
|
238
238
|
const propertyName = property.getName(),
|
|
239
239
|
count = properties.reduce((count, property) => {
|
|
240
|
-
const
|
|
240
|
+
const propertyComparesToPropertyName = property.comparePropertyName(propertyName);
|
|
241
241
|
|
|
242
|
-
if (
|
|
242
|
+
if (propertyComparesToPropertyName) {
|
|
243
243
|
count++;
|
|
244
244
|
}
|
|
245
245
|
|
|
@@ -252,15 +252,15 @@ export default define(class ComplexTypeDeclaration extends Declaration {
|
|
|
252
252
|
const superTypes = this.type.getSuperTypes(),
|
|
253
253
|
superType = superTypes.find((superType) => {
|
|
254
254
|
const superTypeProperties = superType.getProperties(),
|
|
255
|
-
|
|
256
|
-
const
|
|
255
|
+
superTypePropertyComparesToPropertyName = superTypeProperties.some((superTypeProperty) => {
|
|
256
|
+
const superTypePropertyComparesToPropertyName = superTypeProperty.comparePropertyName(propertyName);
|
|
257
257
|
|
|
258
|
-
if (
|
|
258
|
+
if (superTypePropertyComparesToPropertyName) {
|
|
259
259
|
return true;
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
|
|
263
|
-
if (
|
|
263
|
+
if (superTypePropertyComparesToPropertyName) {
|
|
264
264
|
return true;
|
|
265
265
|
}
|
|
266
266
|
}) || null;
|
|
@@ -291,9 +291,9 @@ export default define(class ComplexTypeDeclaration extends Declaration {
|
|
|
291
291
|
|
|
292
292
|
context.trace(`Verifying the '${propertyString}' property's '${nominalTypeName}' nominal type name...`, node);
|
|
293
293
|
|
|
294
|
-
const
|
|
294
|
+
const typeComparesToNominalTypeName = this.type.compareNominalTypeName(nominalTypeName);
|
|
295
295
|
|
|
296
|
-
if (
|
|
296
|
+
if (typeComparesToNominalTypeName) {
|
|
297
297
|
propertyNominalTypeNameVerifies = true;
|
|
298
298
|
} else {
|
|
299
299
|
const typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import Declaration from "../declaration";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import {
|
|
6
|
+
import { validateTerm } from "../../process/validate";
|
|
7
7
|
|
|
8
8
|
export default define(class ConstructorDeclaration extends Declaration {
|
|
9
9
|
constructor(context, string, node, constructor) {
|
|
@@ -28,9 +28,9 @@ export default define(class ConstructorDeclaration extends Declaration {
|
|
|
28
28
|
const constructorTypeVerifies = this.verifyConstructorType();
|
|
29
29
|
|
|
30
30
|
if (constructorTypeVerifies) {
|
|
31
|
-
const
|
|
31
|
+
const constructorValidates = this.verifyConstructor();
|
|
32
32
|
|
|
33
|
-
if (
|
|
33
|
+
if (constructorValidates) {
|
|
34
34
|
context.addConstructor(this.constructor);
|
|
35
35
|
|
|
36
36
|
verifies = true;
|
|
@@ -45,7 +45,7 @@ export default define(class ConstructorDeclaration extends Declaration {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
verifyConstructor() {
|
|
48
|
-
let
|
|
48
|
+
let constructorValidates = false;
|
|
49
49
|
|
|
50
50
|
const node = this.getNode(),
|
|
51
51
|
context = this.getContext(),
|
|
@@ -54,15 +54,18 @@ export default define(class ConstructorDeclaration extends Declaration {
|
|
|
54
54
|
context.trace(`Verifying the '${constructorString}' constructor...`, node);
|
|
55
55
|
|
|
56
56
|
const term = this.constructor.getTerm(),
|
|
57
|
-
termNode = term.getNode()
|
|
57
|
+
termNode = term.getNode(),
|
|
58
|
+
termValidates = validateTerm(termNode, context);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
if (termValidates) {
|
|
61
|
+
constructorValidates = true;
|
|
62
|
+
}
|
|
60
63
|
|
|
61
|
-
if (
|
|
64
|
+
if (constructorValidates) {
|
|
62
65
|
context.debug(`...verified the '${constructorString}' constructor.`, node);
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
return
|
|
68
|
+
return constructorValidates;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
verifyConstructorType() {
|
|
@@ -90,9 +93,9 @@ export default define(class ConstructorDeclaration extends Declaration {
|
|
|
90
93
|
} else {
|
|
91
94
|
const includeSupertypes = false,
|
|
92
95
|
provisional = type.isProvisional(includeSupertypes),
|
|
93
|
-
|
|
96
|
+
typeComparesToProvisional = type.compareProvisional(provisional);
|
|
94
97
|
|
|
95
|
-
if (!
|
|
98
|
+
if (!typeComparesToProvisional) {
|
|
96
99
|
provisional ?
|
|
97
100
|
context.debug(`The '${typeString}' type is present but not provisional.`, node) :
|
|
98
101
|
context.debug(`The '${typeString}' type is present but provisional.`, node);
|
|
@@ -108,10 +108,10 @@ export default define(class SimpleTypeDeclaration extends Declaration {
|
|
|
108
108
|
|
|
109
109
|
const nominalTypeName = superType.getNominalTypeName(),
|
|
110
110
|
typeName = nominalTypeName, ///
|
|
111
|
-
|
|
111
|
+
typeComparesToTypeName = this.type.compareTypeName(typeName);
|
|
112
112
|
|
|
113
|
-
if (
|
|
114
|
-
context.trace(`The super-type's name
|
|
113
|
+
if (typeComparesToTypeName) {
|
|
114
|
+
context.trace(`The super-type's name compares to the ${typeName}' simple type's name.`, node);
|
|
115
115
|
} else {
|
|
116
116
|
const oldSuperType = superType;
|
|
117
117
|
|
|
@@ -30,7 +30,7 @@ export default define(class TypePrefixDeclaration extends Declaration {
|
|
|
30
30
|
typesLength = types.length;
|
|
31
31
|
|
|
32
32
|
if (typesLength > 0) {
|
|
33
|
-
context.debug(`
|
|
33
|
+
context.debug(`Unable to verify the '${typePrefixDeclarationString}' type prefix declaration because types have already been declared.`, node);
|
|
34
34
|
} else {
|
|
35
35
|
const typePrefixVerifies = this.verifyTypePrefix();
|
|
36
36
|
|
|
@@ -93,9 +93,9 @@ export default define(class VariableDeclaration extends Declaration {
|
|
|
93
93
|
} else {
|
|
94
94
|
const includeSupertypes = false,
|
|
95
95
|
provisional = type.isProvisional(includeSupertypes),
|
|
96
|
-
|
|
96
|
+
typeComparesToProvisional = type.compareProvisional(provisional);
|
|
97
97
|
|
|
98
|
-
if (!
|
|
98
|
+
if (!typeComparesToProvisional) {
|
|
99
99
|
provisional ?
|
|
100
100
|
context.debug(`The '${typeString}' type is present but not provisional.`, node) :
|
|
101
101
|
context.debug(`The '${typeString}' type is present but provisional.`, node);
|
package/src/element/deduction.js
CHANGED
|
@@ -24,24 +24,27 @@ export default define(class Deduction extends Element {
|
|
|
24
24
|
|
|
25
25
|
context = temporaryContext; ///
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const node = this.getNode(),
|
|
28
|
+
deductionString = this.getString(); ///
|
|
28
29
|
|
|
29
|
-
context.trace(`Verifying the '${deductionString}' deduction...`,
|
|
30
|
+
context.trace(`Verifying the '${deductionString}' deduction...`, node);
|
|
30
31
|
|
|
31
|
-
if (this.statement
|
|
32
|
+
if (this.statement === null) {
|
|
33
|
+
context.debug(`Unable to verify the '${deductionString}' deduction because it is nonsense.`, node);
|
|
34
|
+
} else {
|
|
32
35
|
const stated = true,
|
|
33
36
|
assignments = null,
|
|
34
|
-
|
|
37
|
+
statementVealidates = this.statement.validate(assignments, stated, context);
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
if (statementVealidates) {
|
|
40
|
+
verifies = true;
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
if (verifies) {
|
|
42
|
-
this.context
|
|
45
|
+
this.setContext(context);
|
|
43
46
|
|
|
44
|
-
context.debug(`...verified the '${deductionString}' deduction.`,
|
|
47
|
+
context.debug(`...verified the '${deductionString}' deduction.`, node);
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
return verifies;
|
|
@@ -35,16 +35,12 @@ export default define(class Derivation extends Element {
|
|
|
35
35
|
stepOrSubproofVerifies = stepOrSubproof.verify(substitutions, assignments, context);
|
|
36
36
|
|
|
37
37
|
if (stepOrSubproofVerifies) {
|
|
38
|
-
const
|
|
38
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
39
39
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
if (assignmentsAssigned) {
|
|
41
|
+
context.addStepOrSubproof(stepOrSubproof);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
context.addStepOrSubproof(stepOrSubproof);
|
|
45
|
-
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
43
|
+
return true;
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
});
|