occam-verify-cli 0.0.526 → 0.0.529
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/README.md +4 -0
- package/bin/abbreviations.js +5 -1
- package/bin/action/help.js +4 -0
- package/bin/action/verify.js +35 -13
- package/bin/actions.js +11 -6
- package/bin/defaults.js +4 -0
- package/bin/options.js +4 -0
- package/bin/utilities/releaseContext.js +5 -7
- package/lib/assertion/type.js +10 -40
- package/lib/axiom.js +8 -8
- package/lib/axiomLemmaTheoremConjecture.js +190 -0
- package/lib/combinator.js +4 -3
- package/lib/conclusion.js +8 -7
- package/lib/conjecture.js +141 -0
- package/lib/consequence.js +6 -5
- package/lib/constants.js +11 -27
- package/lib/constructor.js +5 -4
- package/lib/context/file.js +88 -73
- package/lib/context/metaproof.js +51 -20
- package/lib/context/proof.js +48 -114
- package/lib/context/release/directory.js +25 -6
- package/lib/context/release/file.js +38 -25
- package/lib/context/release.js +32 -51
- package/lib/equality.js +79 -51
- package/lib/index.js +4 -16
- package/lib/kinds.js +5 -1
- package/lib/label.js +4 -3
- package/lib/lemma.js +8 -8
- package/lib/log.js +146 -0
- package/lib/matcher.js +25 -75
- package/lib/metaTypeNames.js +13 -0
- package/lib/mixins/file.js +62 -2
- package/lib/mixins/logging.js +13 -13
- package/lib/node/metastatement/bracketed.js +16 -0
- package/lib/node/statement/bracketed.js +16 -0
- package/lib/node/statement/combinator/bracketed.js +17 -0
- package/lib/node/statement/combinator/equality.js +17 -0
- package/lib/node/statement/equality.js +16 -0
- package/lib/ocmbinator/bracketed.js +3 -4
- package/lib/ocmbinator/equality.js +3 -4
- package/lib/premise.js +13 -12
- package/lib/rule.js +5 -5
- package/lib/ruleNames.js +1 -9
- package/lib/step/metaproof.js +28 -25
- package/lib/step/proof.js +23 -1
- package/lib/substitution/metastatementForMetavariable.js +16 -13
- package/lib/substitution/statementForMetavariable.js +16 -13
- package/lib/substitution/termForVariable.js +76 -0
- package/lib/supposition.js +7 -6
- package/lib/theorem.js +8 -8
- package/lib/type.js +12 -5
- package/lib/utilities/metaproof.js +60 -0
- package/lib/utilities/node.js +56 -0
- package/lib/utilities/proof.js +60 -0
- package/lib/utilities/releaseContext.js +24 -12
- package/lib/utilities/string.js +3 -38
- package/lib/variable.js +4 -38
- package/lib/{matcher → verifier}/metastatementForMetavariable/conclusion.js +12 -12
- package/lib/{matcher → verifier}/metastatementForMetavariable/premise.js +12 -12
- package/lib/verifier/metastatementForMetavariable.js +198 -0
- package/lib/{matcher → verifier}/statementForMetavariable/conclusion.js +12 -12
- package/lib/{matcher → verifier}/statementForMetavariable/premise.js +12 -12
- package/lib/verifier/statementForMetavariable.js +203 -0
- package/lib/{matcher/statementForVariable → verifier/termForVariable}/consequence.js +13 -13
- package/lib/{matcher/statementForVariable → verifier/termForVariable}/supposition.js +13 -13
- package/lib/verifier/termForVariable.js +198 -0
- package/lib/verifier.js +92 -0
- package/lib/verify/assertion/type.js +62 -41
- package/lib/verify/axiom.js +3 -6
- package/lib/verify/conclusion.js +2 -4
- package/lib/verify/conjecture.js +54 -0
- package/lib/verify/consequence.js +2 -4
- package/lib/verify/declaration/combinator.js +1 -3
- package/lib/verify/declaration/constructor.js +1 -3
- package/lib/verify/declaration/topLevel.js +7 -5
- package/lib/verify/declaration/type.js +1 -3
- package/lib/verify/declaration/variable.js +1 -3
- package/lib/verify/derivation.js +1 -5
- package/lib/verify/label.js +1 -3
- package/lib/verify/lemma.js +3 -6
- package/lib/verify/metastatement/qualified.js +2 -5
- package/lib/verify/metastatement/unqualified.js +2 -5
- package/lib/verify/metastatement.js +1 -3
- package/lib/verify/premise.js +2 -4
- package/lib/verify/proof.js +3 -5
- package/lib/verify/rule.js +3 -6
- package/lib/verify/ruleDerivation.js +1 -5
- package/lib/verify/ruleProof.js +3 -5
- package/lib/verify/statement/qualified.js +40 -13
- package/lib/verify/statement/unqualified.js +2 -5
- package/lib/verify/statement.js +56 -62
- package/lib/verify/statementAsCombinator.js +4 -6
- package/lib/verify/supposition.js +2 -4
- package/lib/verify/term.js +4 -10
- package/lib/verify/termAsConstructor.js +6 -9
- package/lib/verify/theorem.js +3 -6
- package/lib/verify/type.js +5 -9
- package/lib/verify/variable.js +5 -9
- package/package.json +1 -1
- package/src/assertion/type.js +7 -32
- package/src/axiom.js +4 -4
- package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +9 -9
- package/src/combinator.js +3 -3
- package/src/conclusion.js +7 -7
- package/src/conjecture.js +13 -0
- package/src/consequence.js +5 -5
- package/src/constants.js +3 -7
- package/src/constructor.js +4 -4
- package/src/context/file.js +85 -65
- package/src/context/metaproof.js +55 -15
- package/src/context/proof.js +53 -50
- package/src/context/release/directory.js +31 -7
- package/src/context/release/file.js +47 -31
- package/src/context/release.js +23 -32
- package/src/equality.js +108 -61
- package/src/index.js +2 -4
- package/src/kinds.js +1 -0
- package/src/label.js +3 -3
- package/src/lemma.js +4 -4
- package/src/log.js +116 -0
- package/src/matcher.js +32 -24
- package/src/metaTypeNames.js +3 -0
- package/src/mixins/file.js +46 -1
- package/src/mixins/logging.js +6 -6
- package/src/node/metastatement/bracketed.js +9 -0
- package/src/node/statement/bracketed.js +9 -0
- package/src/node/statement/combinator/bracketed.js +10 -0
- package/src/node/statement/combinator/equality.js +11 -0
- package/src/node/statement/equality.js +10 -0
- package/src/ocmbinator/bracketed.js +2 -5
- package/src/ocmbinator/equality.js +2 -5
- package/src/premise.js +13 -13
- package/src/rule.js +4 -4
- package/src/ruleNames.js +0 -2
- package/src/step/metaproof.js +32 -29
- package/src/step/proof.js +28 -0
- package/src/substitution/metastatementForMetavariable.js +10 -15
- package/src/substitution/statementForMetavariable.js +11 -16
- package/src/substitution/termForVariable.js +36 -0
- package/src/supposition.js +6 -6
- package/src/theorem.js +4 -4
- package/src/type.js +17 -7
- package/src/utilities/metaproof.js +62 -0
- package/src/utilities/node.js +73 -0
- package/src/utilities/proof.js +62 -0
- package/src/utilities/releaseContext.js +30 -12
- package/src/utilities/string.js +4 -53
- package/src/variable.js +4 -37
- package/src/verifier/metastatementForMetavariable/conclusion.js +9 -0
- package/src/verifier/metastatementForMetavariable/premise.js +9 -0
- package/src/verifier/metastatementForMetavariable.js +89 -0
- package/src/verifier/statementForMetavariable/conclusion.js +9 -0
- package/src/verifier/statementForMetavariable/premise.js +9 -0
- package/src/verifier/statementForMetavariable.js +105 -0
- package/src/verifier/termForVariable/consequence.js +9 -0
- package/src/verifier/termForVariable/supposition.js +9 -0
- package/src/verifier/termForVariable.js +89 -0
- package/src/verifier.js +74 -0
- package/src/verify/assertion/type.js +74 -74
- package/src/verify/axiom.js +2 -9
- package/src/verify/conclusion.js +1 -7
- package/src/verify/conjecture.js +67 -0
- package/src/verify/consequence.js +1 -7
- package/src/verify/declaration/combinator.js +0 -6
- package/src/verify/declaration/constructor.js +0 -6
- package/src/verify/declaration/topLevel.js +7 -6
- package/src/verify/declaration/type.js +0 -6
- package/src/verify/declaration/variable.js +0 -6
- package/src/verify/derivation.js +0 -12
- package/src/verify/label.js +0 -6
- package/src/verify/lemma.js +4 -11
- package/src/verify/metastatement/qualified.js +1 -8
- package/src/verify/metastatement/unqualified.js +1 -8
- package/src/verify/metastatement.js +0 -6
- package/src/verify/premise.js +1 -7
- package/src/verify/proof.js +1 -7
- package/src/verify/rule.js +2 -9
- package/src/verify/ruleDerivation.js +0 -12
- package/src/verify/ruleProof.js +1 -7
- package/src/verify/statement/qualified.js +54 -20
- package/src/verify/statement/unqualified.js +1 -8
- package/src/verify/statement.js +65 -95
- package/src/verify/statementAsCombinator.js +3 -9
- package/src/verify/supposition.js +1 -7
- package/src/verify/term.js +3 -21
- package/src/verify/termAsConstructor.js +5 -13
- package/src/verify/theorem.js +2 -9
- package/src/verify/type.js +4 -13
- package/src/verify/variable.js +4 -13
- package/bin/callbacks.js +0 -48
- package/lib/axiomLemmaTheorem.js +0 -190
- package/lib/callbacks.js +0 -75
- package/lib/context/release/combinator.js +0 -64
- package/lib/jsonTypes.js +0 -30
- package/lib/matcher/metastatementForMetavariable.js +0 -201
- package/lib/matcher/statementForMetavariable.js +0 -201
- package/lib/matcher/statementForVariable.js +0 -201
- package/lib/mixins/callbacks.js +0 -27
- package/lib/substitution/statementForVariable.js +0 -86
- package/lib/utilities/json.js +0 -187
- package/lib/utilities/substitution.js +0 -61
- package/lib/utilities/version.js +0 -32
- package/lib/versionChanges.js +0 -34
- package/src/callbacks.js +0 -39
- package/src/context/release/combinator.js +0 -39
- package/src/jsonTypes.js +0 -6
- package/src/matcher/metastatementForMetavariable/conclusion.js +0 -9
- package/src/matcher/metastatementForMetavariable/premise.js +0 -9
- package/src/matcher/metastatementForMetavariable.js +0 -99
- package/src/matcher/statementForMetavariable/conclusion.js +0 -9
- package/src/matcher/statementForMetavariable/premise.js +0 -9
- package/src/matcher/statementForMetavariable.js +0 -99
- package/src/matcher/statementForVariable/consequence.js +0 -9
- package/src/matcher/statementForVariable/supposition.js +0 -9
- package/src/matcher/statementForVariable.js +0 -99
- package/src/mixins/callbacks.js +0 -15
- package/src/substitution/statementForVariable.js +0 -64
- package/src/utilities/json.js +0 -264
- package/src/utilities/substitution.js +0 -79
- package/src/utilities/version.js +0 -30
- package/src/versionChanges.js +0 -11
|
@@ -7,7 +7,7 @@ import Consequence from "./consequence";
|
|
|
7
7
|
import { prune } from "./utilities/array";
|
|
8
8
|
import { someSubArray } from "./utilities/array";
|
|
9
9
|
|
|
10
|
-
export default class
|
|
10
|
+
export default class AxiomLemmaTheoremConjecture {
|
|
11
11
|
constructor(labels, suppositions, consequence) {
|
|
12
12
|
this.labels = labels;
|
|
13
13
|
this.suppositions = suppositions;
|
|
@@ -90,14 +90,14 @@ export default class AxiomLemmaTheorem {
|
|
|
90
90
|
return json;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
static fromJSON(Class, json,
|
|
93
|
+
static fromJSON(Class, json, lexer, parser) {
|
|
94
94
|
let { labels } = json;
|
|
95
95
|
|
|
96
96
|
const labelsJSON = labels; ///
|
|
97
97
|
|
|
98
98
|
labels = labelsJSON.map((labelJSON) => {
|
|
99
99
|
const json = labelJSON, ///
|
|
100
|
-
label = Label.fromJSON(json,
|
|
100
|
+
label = Label.fromJSON(json, lexer, parser);
|
|
101
101
|
|
|
102
102
|
return label;
|
|
103
103
|
});
|
|
@@ -108,7 +108,7 @@ export default class AxiomLemmaTheorem {
|
|
|
108
108
|
|
|
109
109
|
suppositions = suppositionsJSON.map((suppositionJSON) => {
|
|
110
110
|
const json = suppositionJSON, ///
|
|
111
|
-
supposition = Supposition.fromJSON(json,
|
|
111
|
+
supposition = Supposition.fromJSON(json, lexer, parser);
|
|
112
112
|
|
|
113
113
|
return supposition;
|
|
114
114
|
});
|
|
@@ -119,7 +119,7 @@ export default class AxiomLemmaTheorem {
|
|
|
119
119
|
|
|
120
120
|
json = consequenceJSON; ///
|
|
121
121
|
|
|
122
|
-
consequence = Consequence.fromJSON(json,
|
|
122
|
+
consequence = Consequence.fromJSON(json, lexer, parser);
|
|
123
123
|
|
|
124
124
|
return new Class(labels, suppositions, consequence); ///
|
|
125
125
|
}
|
|
@@ -156,7 +156,7 @@ function matchSupposition(supposition, proofSteps, substitutions) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
function matchSuppositions(supposition, proofSteps, substitutions) {
|
|
159
|
-
const
|
|
159
|
+
const suppositionsMatch = supposition.every((supposition) => {
|
|
160
160
|
const suppositionMatches = matchSupposition(supposition, proofSteps, substitutions);
|
|
161
161
|
|
|
162
162
|
if (suppositionMatches) {
|
|
@@ -164,7 +164,7 @@ function matchSuppositions(supposition, proofSteps, substitutions) {
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
return
|
|
167
|
+
return suppositionsMatch;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
function matchConsequence(consequence, statementNode, substitutions) {
|
|
@@ -178,9 +178,9 @@ function matchSuppositionsAndConsequence(suppositions, consequence, proofSteps,
|
|
|
178
178
|
let suppositionsMatchConsequence = false;
|
|
179
179
|
|
|
180
180
|
const substitutions = [],
|
|
181
|
-
|
|
181
|
+
suppositionsMatch = matchSuppositions(suppositions, proofSteps, substitutions);
|
|
182
182
|
|
|
183
|
-
if (
|
|
183
|
+
if (suppositionsMatch) {
|
|
184
184
|
const consequenceMatches = matchConsequence(consequence, statementNode, substitutions);
|
|
185
185
|
|
|
186
186
|
suppositionsMatchConsequence = consequenceMatches; ///
|
package/src/combinator.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { nodeAsString } from "./utilities/string";
|
|
4
4
|
import { COMBINATOR_KIND } from "./kinds";
|
|
5
|
-
import { statementNodeFromStatementString } from "./utilities/
|
|
5
|
+
import { statementNodeFromStatementString } from "./utilities/node";
|
|
6
6
|
|
|
7
7
|
export default class Combinator {
|
|
8
8
|
constructor(statementNode) {
|
|
@@ -35,10 +35,10 @@ export default class Combinator {
|
|
|
35
35
|
return json;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
static fromJSON(json,
|
|
38
|
+
static fromJSON(json, lexer, parser) {
|
|
39
39
|
const { statement } = json,
|
|
40
40
|
statementString = statement, ///
|
|
41
|
-
statementNode = statementNodeFromStatementString(statementString,
|
|
41
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
42
42
|
combinator = new Combinator(statementNode);
|
|
43
43
|
|
|
44
44
|
return combinator;
|
package/src/conclusion.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { nodeAsString } from "./utilities/string";
|
|
4
|
-
import { metastatementNodeFromMetastatementString } from "./utilities/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
5
|
+
import { conclusionStatementForMetavariableVerifier } from "./verifier/statementForMetavariable/conclusion";
|
|
6
|
+
import { conclusionMetastatementForMetavariableVerifier } from "./verifier/metastatementForMetavariable/conclusion";
|
|
7
7
|
|
|
8
8
|
export default class Conclusion {
|
|
9
9
|
constructor(metastatementNode) {
|
|
@@ -17,7 +17,7 @@ export default class Conclusion {
|
|
|
17
17
|
matchStatementNode(statementNode, substitutions) {
|
|
18
18
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
19
19
|
nonTerminalNodeB = statementNode, ///
|
|
20
|
-
nonTerminalNodeMatches =
|
|
20
|
+
nonTerminalNodeMatches = conclusionStatementForMetavariableVerifier.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
|
|
21
21
|
statementNodeMatches = nonTerminalNodeMatches; ///
|
|
22
22
|
|
|
23
23
|
return statementNodeMatches;
|
|
@@ -26,7 +26,7 @@ export default class Conclusion {
|
|
|
26
26
|
matchMetastatementNode(metastatementNode, substitutions) {
|
|
27
27
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
28
28
|
nonTerminalNodeB = metastatementNode, ///
|
|
29
|
-
nonTerminalNodeMatches =
|
|
29
|
+
nonTerminalNodeMatches = conclusionMetastatementForMetavariableVerifier.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
|
|
30
30
|
metastatementNodeMatches = nonTerminalNodeMatches; ///
|
|
31
31
|
|
|
32
32
|
return metastatementNodeMatches;
|
|
@@ -42,10 +42,10 @@ export default class Conclusion {
|
|
|
42
42
|
return json;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
static fromJSON(json,
|
|
45
|
+
static fromJSON(json, lexer, parser) {
|
|
46
46
|
const { metastatement } = json,
|
|
47
47
|
metastatementString = metastatement, ///
|
|
48
|
-
metastatementNode = metastatementNodeFromMetastatementString(metastatementString,
|
|
48
|
+
metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
|
|
49
49
|
conclusion = new Conclusion(metastatementNode);
|
|
50
50
|
|
|
51
51
|
return conclusion;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import AxiomLemmaTheoremConjecture from "./axiomLemmaTheoremConjecture";
|
|
4
|
+
|
|
5
|
+
import { CONJECTURE_KIND } from "./kinds";
|
|
6
|
+
|
|
7
|
+
export default class Conjecture extends AxiomLemmaTheoremConjecture {
|
|
8
|
+
static kind = CONJECTURE_KIND;
|
|
9
|
+
|
|
10
|
+
static fromJSON(json, lexer, parser) { return AxiomLemmaTheoremConjecture.fromJSON(Conjecture, json, lexer, parser); }
|
|
11
|
+
|
|
12
|
+
static fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsAndConsequence(Conjecture, labels, suppositions, consequence); }
|
|
13
|
+
}
|
package/src/consequence.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { nodeAsString } from "./utilities/string";
|
|
4
|
-
import { statementNodeFromStatementString } from "./utilities/
|
|
5
|
-
import {
|
|
4
|
+
import { statementNodeFromStatementString } from "./utilities/node";
|
|
5
|
+
import { consequenceTermForVariableVerifier } from "./verifier/termForVariable/consequence";
|
|
6
6
|
|
|
7
7
|
export default class Consequence {
|
|
8
8
|
constructor(statementNode) {
|
|
@@ -16,7 +16,7 @@ export default class Consequence {
|
|
|
16
16
|
matchStatementNode(statementNode, substitutions) {
|
|
17
17
|
const nonTerminalNodeA = this.statementNode, ///
|
|
18
18
|
nonTerminalNodeB = statementNode, ///
|
|
19
|
-
nonTerminalNodeMatches =
|
|
19
|
+
nonTerminalNodeMatches = consequenceTermForVariableVerifier.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
|
|
20
20
|
statementNodeMatches = nonTerminalNodeMatches; ///
|
|
21
21
|
|
|
22
22
|
return statementNodeMatches;
|
|
@@ -32,10 +32,10 @@ export default class Consequence {
|
|
|
32
32
|
return json;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
static fromJSON(json,
|
|
35
|
+
static fromJSON(json, lexer, parser) {
|
|
36
36
|
const { statement } = json,
|
|
37
37
|
statementString = statement, ///
|
|
38
|
-
statementNode = statementNodeFromStatementString(statementString,
|
|
38
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
39
39
|
consequence = new Consequence(statementNode);
|
|
40
40
|
|
|
41
41
|
return consequence;
|
package/src/constants.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const COMMA = ',';
|
|
4
|
-
export const STRING = "string";
|
|
5
|
-
export const NUMBER = "number";
|
|
6
|
-
export const BOOLEAN = "boolean";
|
|
7
4
|
export const EMPTY_STRING = "";
|
|
8
|
-
export const
|
|
9
|
-
export const RIGHT_BRACKET = ")";
|
|
10
|
-
export const EQUALS_CHARACTER = "=";
|
|
5
|
+
export const EQUALITY_DEPTH = 2;
|
|
11
6
|
export const MAXIMUM_INDEXES_LENGTH = 10;
|
|
7
|
+
export const BRACKETED_STATEMENT_DEPTH = 2;
|
|
12
8
|
export const MAXIMUM_PERMUTATION_LENGTH = 5;
|
|
13
|
-
export const
|
|
9
|
+
export const BRACKETED_METASTATEMENT_DEPTH = 1;
|
package/src/constructor.js
CHANGED
|
@@ -4,7 +4,7 @@ import Type from "./type";
|
|
|
4
4
|
|
|
5
5
|
import { nodeAsString } from "./utilities/string";
|
|
6
6
|
import { CONSTRUCTOR_KIND } from "./kinds";
|
|
7
|
-
import { termNodeFromTermString } from "./utilities/
|
|
7
|
+
import { termNodeFromTermString } from "./utilities/node";
|
|
8
8
|
|
|
9
9
|
export default class Constructor {
|
|
10
10
|
constructor(termNode, type) {
|
|
@@ -54,10 +54,10 @@ export default class Constructor {
|
|
|
54
54
|
return json;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
static fromJSON(json,
|
|
57
|
+
static fromJSON(json, lexer, parser) {
|
|
58
58
|
const { term } = json,
|
|
59
59
|
termString = term, ///
|
|
60
|
-
termNode = termNodeFromTermString(termString,
|
|
60
|
+
termNode = termNodeFromTermString(termString, lexer, parser);
|
|
61
61
|
|
|
62
62
|
let { type } = json;
|
|
63
63
|
|
|
@@ -66,7 +66,7 @@ export default class Constructor {
|
|
|
66
66
|
|
|
67
67
|
json = typeJSON; ///
|
|
68
68
|
|
|
69
|
-
type = Type.fromJSON(json,
|
|
69
|
+
type = Type.fromJSON(json, lexer, parser);
|
|
70
70
|
|
|
71
71
|
const typeName = type.getName();
|
|
72
72
|
|
package/src/context/file.js
CHANGED
|
@@ -4,10 +4,9 @@ import { rewriteNodes } from "occam-grammar-utilities";
|
|
|
4
4
|
|
|
5
5
|
import { push } from "../utilities/array";
|
|
6
6
|
import { nodeAsString, nodesAsString } from "../utilities/string";
|
|
7
|
-
import { leastLineIndexFromNodeAndTokens, greatestLineIndexFromNodeAndTokens } from "../utilities/tokens";
|
|
8
7
|
|
|
9
8
|
export default class FileContext {
|
|
10
|
-
constructor(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems,
|
|
9
|
+
constructor(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, conjectures, combinators, constructors, variables, metavariables) {
|
|
11
10
|
this.releaseContext = releaseContext;
|
|
12
11
|
this.filePath = filePath;
|
|
13
12
|
this.tokens = tokens;
|
|
@@ -17,9 +16,11 @@ export default class FileContext {
|
|
|
17
16
|
this.axioms = axioms;
|
|
18
17
|
this.lemmas = lemmas;
|
|
19
18
|
this.theorems = theorems;
|
|
20
|
-
this.
|
|
19
|
+
this.conjectures = conjectures;
|
|
21
20
|
this.combinators = combinators;
|
|
22
21
|
this.constructors = constructors;
|
|
22
|
+
this.variables = variables;
|
|
23
|
+
this.metavariables = metavariables;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
getReleaseContext() {
|
|
@@ -38,8 +39,16 @@ export default class FileContext {
|
|
|
38
39
|
return this.node;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
getProofSteps() {
|
|
43
|
+
const proofSteps = []; ///
|
|
44
|
+
|
|
45
|
+
return proofSteps;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getMetaproofSteps() {
|
|
49
|
+
const metaproofSteps = []; ///
|
|
50
|
+
|
|
51
|
+
return metaproofSteps;
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
getLabels(includeRelease = true) {
|
|
@@ -148,6 +157,20 @@ export default class FileContext {
|
|
|
148
157
|
return theorems;
|
|
149
158
|
}
|
|
150
159
|
|
|
160
|
+
getConjectures(includeRelease = true) {
|
|
161
|
+
const conjectures = [];
|
|
162
|
+
|
|
163
|
+
push(conjectures, this.conjectures);
|
|
164
|
+
|
|
165
|
+
if (includeRelease) {
|
|
166
|
+
const releaseContextConjectures = this.releaseContext.getConjectures();
|
|
167
|
+
|
|
168
|
+
push(conjectures, releaseContextConjectures);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return conjectures;
|
|
172
|
+
}
|
|
173
|
+
|
|
151
174
|
getCombinators(includeRelease = true) {
|
|
152
175
|
const combinators = [];
|
|
153
176
|
|
|
@@ -176,16 +199,12 @@ export default class FileContext {
|
|
|
176
199
|
return constructors;
|
|
177
200
|
}
|
|
178
201
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return proofSteps;
|
|
202
|
+
getVariables() {
|
|
203
|
+
return this.variables;
|
|
183
204
|
}
|
|
184
205
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return metaproofSteps;
|
|
206
|
+
getMetavariables() {
|
|
207
|
+
return this.metavariables;
|
|
189
208
|
}
|
|
190
209
|
|
|
191
210
|
findTypeByTypeName(typeName) {
|
|
@@ -271,18 +290,25 @@ export default class FileContext {
|
|
|
271
290
|
return theorem;
|
|
272
291
|
}
|
|
273
292
|
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
293
|
+
findConjectureByReferenceName(referenceName) {
|
|
294
|
+
const labelName = referenceName, ///
|
|
295
|
+
conjectures = this.getConjectures(),
|
|
296
|
+
conjecture = conjectures.find((conjecture) => {
|
|
297
|
+
const conjectureMatchesLabelName = conjecture.matchLabelName(labelName);
|
|
279
298
|
|
|
280
|
-
if (
|
|
299
|
+
if (conjectureMatchesLabelName) {
|
|
281
300
|
return true;
|
|
282
301
|
}
|
|
283
302
|
}) || null;
|
|
284
303
|
|
|
285
|
-
return
|
|
304
|
+
return conjecture;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
isLabelPresentByLabelName(labelName) {
|
|
308
|
+
const label = this.findLabelByLabelName(labelName),
|
|
309
|
+
labelPresent = (label !== null);
|
|
310
|
+
|
|
311
|
+
return labelPresent;
|
|
286
312
|
}
|
|
287
313
|
|
|
288
314
|
isTypePresentByTypeName(typeName) {
|
|
@@ -292,11 +318,30 @@ export default class FileContext {
|
|
|
292
318
|
return typePresent;
|
|
293
319
|
}
|
|
294
320
|
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
labelPresent = (label !== null);
|
|
321
|
+
nodeAsString(node) {
|
|
322
|
+
const string = nodeAsString(node, this.tokens);
|
|
298
323
|
|
|
299
|
-
return
|
|
324
|
+
return string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
nodesAsString(node) {
|
|
328
|
+
const string = nodesAsString(node, this.tokens);
|
|
329
|
+
|
|
330
|
+
return string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
findVariableByVariableName(variableName) {
|
|
334
|
+
const name = variableName, ///
|
|
335
|
+
variables = this.getVariables(),
|
|
336
|
+
variable = variables.find((variable) => {
|
|
337
|
+
const matches = variable.matchName(name);
|
|
338
|
+
|
|
339
|
+
if (matches) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
}) || null;
|
|
343
|
+
|
|
344
|
+
return variable;
|
|
300
345
|
}
|
|
301
346
|
|
|
302
347
|
isVariablePresentByVariableName(variableName) {
|
|
@@ -344,50 +389,17 @@ export default class FileContext {
|
|
|
344
389
|
this.constructors.push(constructor);
|
|
345
390
|
}
|
|
346
391
|
|
|
347
|
-
|
|
348
|
-
const string = nodeAsString(node, this.tokens);
|
|
349
|
-
|
|
350
|
-
return string;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
nodesAsString(node) {
|
|
354
|
-
const string = nodesAsString(node, this.tokens);
|
|
392
|
+
trace(message, node) { this.releaseContext.trace(message, node, this.tokens, this.filePath); }
|
|
355
393
|
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
trace(message) { this.releaseContext.trace(message); }
|
|
394
|
+
debug(message, node) { this.releaseContext.debug(message, node, this.tokens, this.filePath); }
|
|
360
395
|
|
|
361
|
-
|
|
396
|
+
info(message, node) { this.releaseContext.info(message, node, this.tokens, this.filePath); }
|
|
362
397
|
|
|
363
|
-
|
|
398
|
+
warning(message, node) { this.releaseContext.warning(message, node, this.tokens, this.filePath); }
|
|
364
399
|
|
|
365
|
-
|
|
400
|
+
error(message, node) { this.releaseContext.error(message, node, this.tokens, this.filePath); }
|
|
366
401
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
fatal(message) { this.releaseContext.fatal(message); }
|
|
370
|
-
|
|
371
|
-
halt(node) {
|
|
372
|
-
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
|
|
373
|
-
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
|
|
374
|
-
|
|
375
|
-
this.releaseContext.halt(this.filePath, leastLineIndex, greatestLineIndex);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
begin(node) {
|
|
379
|
-
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
|
|
380
|
-
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
|
|
381
|
-
|
|
382
|
-
this.releaseContext.begin(this.filePath, leastLineIndex, greatestLineIndex);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
complete(node) {
|
|
386
|
-
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
|
|
387
|
-
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
|
|
388
|
-
|
|
389
|
-
this.releaseContext.complete(this.filePath, leastLineIndex, greatestLineIndex);
|
|
390
|
-
}
|
|
402
|
+
fatal(message, node) { this.releaseContext.fatal(message, node, this.tokens, this.filePath); }
|
|
391
403
|
|
|
392
404
|
toJSON() {
|
|
393
405
|
const json = [];
|
|
@@ -422,6 +434,12 @@ export default class FileContext {
|
|
|
422
434
|
json.push(theoremJSON);
|
|
423
435
|
});
|
|
424
436
|
|
|
437
|
+
this.conjectures.forEach((conjecture) => {
|
|
438
|
+
const conjectureJSON = conjecture.toJSON(this.tokens);
|
|
439
|
+
|
|
440
|
+
json.push(conjectureJSON);
|
|
441
|
+
});
|
|
442
|
+
|
|
425
443
|
this.combinators.forEach((combinator) => {
|
|
426
444
|
const combinatorJSON = combinator.toJSON(this.tokens);
|
|
427
445
|
|
|
@@ -452,10 +470,12 @@ export default class FileContext {
|
|
|
452
470
|
axioms = [],
|
|
453
471
|
lemmas = [],
|
|
454
472
|
theorems = [],
|
|
455
|
-
|
|
473
|
+
conjectures = [],
|
|
456
474
|
combinators = [],
|
|
457
475
|
constructors = [],
|
|
458
|
-
|
|
476
|
+
variables = [],
|
|
477
|
+
metavariables = [],
|
|
478
|
+
fileContext = new FileContext(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, conjectures, combinators, constructors, variables, metavariables);
|
|
459
479
|
|
|
460
480
|
return fileContext;
|
|
461
481
|
}
|
package/src/context/metaproof.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import fileMixins from "../mixins/file";
|
|
4
4
|
import loggingMixins from "../mixins/logging";
|
|
5
|
-
import callbacksMixins from "../mixins/callbacks";
|
|
6
5
|
|
|
7
|
-
import { last } from "../utilities/array";
|
|
6
|
+
import { push, last } from "../utilities/array";
|
|
8
7
|
|
|
9
8
|
class MetaproofContext {
|
|
10
|
-
constructor(context, metaproofSteps) {
|
|
9
|
+
constructor(context, metavariables, metaproofSteps) {
|
|
11
10
|
this.context = context;
|
|
11
|
+
this.metavariables = metavariables;
|
|
12
12
|
this.metaproofSteps = metaproofSteps;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -16,6 +16,20 @@ class MetaproofContext {
|
|
|
16
16
|
return this.context;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
getVariables() { return this.context.getVariables(); }
|
|
20
|
+
|
|
21
|
+
getMetavariables() {
|
|
22
|
+
const metavariables = [];
|
|
23
|
+
|
|
24
|
+
push(metavariables, this.metavariables);
|
|
25
|
+
|
|
26
|
+
const contextMetavariables = this.context.getMetavariables();
|
|
27
|
+
|
|
28
|
+
push(metavariables, contextMetavariables);
|
|
29
|
+
|
|
30
|
+
return metavariables;
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
getMetaproofSteps() {
|
|
20
34
|
let metaproofSteps = this.context.getMetaproofSteps();
|
|
21
35
|
|
|
@@ -39,20 +53,28 @@ class MetaproofContext {
|
|
|
39
53
|
return lastMetaproofStep;
|
|
40
54
|
}
|
|
41
55
|
|
|
56
|
+
addMetavariable(metavariable) {
|
|
57
|
+
this.metavariables.push(metavariable);
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
addMetaproofStep(metaproofStep) {
|
|
43
61
|
this.metaproofSteps.push(metaproofStep);
|
|
44
62
|
}
|
|
45
63
|
|
|
46
64
|
matchMetastatement(metastatementNode) {
|
|
47
|
-
let metastatementMatches;
|
|
65
|
+
let metastatementMatches = false;
|
|
48
66
|
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
if (!metastatementMatches) {
|
|
68
|
+
const proofStepMatchesMetastatement = this.metaproofSteps.some((metaproofStep) => {
|
|
69
|
+
const proofStepMatchesMetastatement = metaproofStep.match(metastatementNode);
|
|
70
|
+
|
|
71
|
+
if (proofStepMatchesMetastatement) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
51
75
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
});
|
|
76
|
+
metastatementMatches = proofStepMatchesMetastatement; ///
|
|
77
|
+
}
|
|
56
78
|
|
|
57
79
|
if (!metastatementMatches) {
|
|
58
80
|
metastatementMatches = this.context.matchMetastatement(metastatementNode);
|
|
@@ -61,23 +83,42 @@ class MetaproofContext {
|
|
|
61
83
|
return metastatementMatches;
|
|
62
84
|
}
|
|
63
85
|
|
|
64
|
-
|
|
86
|
+
findMetavariableByMetavariableName(metavariableName) {
|
|
87
|
+
const name = metavariableName, ///
|
|
88
|
+
metavariables = this.getMetavariables(),
|
|
89
|
+
metavariable = metavariables.find((metavariable) => {
|
|
90
|
+
const matches = metavariable.matchName(name);
|
|
91
|
+
|
|
92
|
+
if (matches) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}) || null;
|
|
96
|
+
|
|
97
|
+
return metavariable;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isMetavariablePresentByVariableName(metavariableName) {
|
|
101
|
+
const metavariable = this.findMetavariableByMetavariableName(metavariableName),
|
|
102
|
+
metavariablePresent = (metavariable !== null);
|
|
65
103
|
|
|
66
|
-
|
|
104
|
+
return metavariablePresent;
|
|
105
|
+
}
|
|
67
106
|
|
|
68
107
|
static fromFileContext(fileContext) {
|
|
69
108
|
const context = fileContext, ///
|
|
109
|
+
metavariables = [],
|
|
70
110
|
metaproofSteps = [],
|
|
71
|
-
metaproofContext = new MetaproofContext(context, metaproofSteps);
|
|
111
|
+
metaproofContext = new MetaproofContext(context, metavariables, metaproofSteps);
|
|
72
112
|
|
|
73
113
|
return metaproofContext;
|
|
74
114
|
}
|
|
75
115
|
|
|
76
116
|
static fromMetaproofContext(metaproofContext) {
|
|
77
117
|
const context = metaproofContext, ///
|
|
118
|
+
metavariables = [],
|
|
78
119
|
metaproofSteps = [];
|
|
79
120
|
|
|
80
|
-
metaproofContext = new MetaproofContext(context, metaproofSteps); ///
|
|
121
|
+
metaproofContext = new MetaproofContext(context, metavariables, metaproofSteps); ///
|
|
81
122
|
|
|
82
123
|
return metaproofContext;
|
|
83
124
|
}
|
|
@@ -85,6 +126,5 @@ class MetaproofContext {
|
|
|
85
126
|
|
|
86
127
|
Object.assign(MetaproofContext.prototype, fileMixins);
|
|
87
128
|
Object.assign(MetaproofContext.prototype, loggingMixins);
|
|
88
|
-
Object.assign(MetaproofContext.prototype, callbacksMixins);
|
|
89
129
|
|
|
90
130
|
export default MetaproofContext;
|