occam-verify-cli 0.0.940 → 0.0.942
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/frame.js +2 -2
- package/lib/premise.js +3 -3
- package/lib/proofStep.js +4 -3
- package/lib/rule.js +10 -3
- package/lib/substitution/termForVariable.js +3 -3
- package/lib/substitutions.js +186 -0
- package/lib/supposition.js +3 -3
- package/lib/topLevelAssertion.js +13 -12
- package/lib/unify/metavariableAgainstStatement.js +4 -4
- package/lib/unify/variableAgainstTerm.js +4 -4
- package/lib/utilities/array.js +13 -1
- package/lib/verifier/metaLevel.js +7 -7
- package/lib/verifier/statementAsCombinator.js +13 -7
- package/lib/verifier/termAsConstructor.js +5 -5
- package/lib/verifier/topLevel.js +236 -0
- package/lib/verify/axiom.js +3 -2
- package/lib/verify/conjecture.js +5 -3
- package/lib/verify/declaration/metavariable.js +70 -4
- package/lib/verify/declaration/type.js +36 -3
- package/lib/verify/declaration/variable.js +38 -3
- package/lib/verify/error.js +18 -0
- package/lib/verify/file.js +7 -21
- package/lib/verify/lemma.js +4 -3
- package/lib/verify/metaLemma.js +3 -2
- package/lib/verify/metatheorem.js +3 -2
- package/lib/verify/metavariable.js +4 -26
- package/lib/verify/rule.js +3 -2
- package/lib/verify/statement.js +4 -26
- package/lib/verify/term.js +4 -23
- package/lib/verify/theorem.js +4 -3
- package/lib/verify/type.js +10 -57
- package/lib/verify/variable.js +10 -59
- package/package.json +5 -5
- package/src/frame.js +1 -1
- package/src/premise.js +2 -2
- package/src/proofStep.js +3 -2
- package/src/rule.js +19 -3
- package/src/substitution/termForVariable.js +2 -2
- package/src/substitutions.js +103 -0
- package/src/supposition.js +2 -2
- package/src/topLevelAssertion.js +22 -15
- package/src/unify/metavariableAgainstStatement.js +3 -3
- package/src/unify/variableAgainstTerm.js +3 -3
- package/src/utilities/array.js +15 -0
- package/src/verifier/metaLevel.js +7 -9
- package/src/verifier/statementAsCombinator.js +18 -9
- package/src/verifier/termAsConstructor.js +6 -7
- package/src/verifier/topLevel.js +160 -0
- package/src/verify/axiom.js +2 -1
- package/src/verify/conjecture.js +5 -2
- package/src/verify/declaration/metavariable.js +112 -2
- package/src/verify/declaration/type.js +48 -1
- package/src/verify/declaration/variable.js +50 -1
- package/src/verify/error.js +11 -0
- package/src/verify/file.js +8 -29
- package/src/verify/lemma.js +3 -2
- package/src/verify/metaLemma.js +2 -1
- package/src/verify/metatheorem.js +2 -1
- package/src/verify/metavariable.js +0 -22
- package/src/verify/rule.js +2 -1
- package/src/verify/statement.js +0 -25
- package/src/verify/term.js +0 -19
- package/src/verify/theorem.js +3 -2
- package/src/verify/type.js +6 -56
- package/src/verify/variable.js +6 -58
- package/lib/verify/declaration/topLevel.js +0 -75
- package/src/verify/declaration/topLevel.js +0 -101
package/src/rule.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Label from "./label";
|
|
4
4
|
import Premise from "./premise";
|
|
5
5
|
import Conclusion from "./conclusion";
|
|
6
|
+
import Substitutions from "./substitutions";
|
|
6
7
|
|
|
7
8
|
import { reverse, correlate } from "./utilities/array";
|
|
8
9
|
|
|
@@ -34,7 +35,7 @@ export default class Rule {
|
|
|
34
35
|
let statementUnified = false;
|
|
35
36
|
|
|
36
37
|
const proofSteps = localContext.getProofSteps(),
|
|
37
|
-
substitutions =
|
|
38
|
+
substitutions = Substitutions.fromNothing(),
|
|
38
39
|
premisesUnified = unifyPremises(this.premises, proofSteps, substitutions, this.fileContext, localContext);
|
|
39
40
|
|
|
40
41
|
if (premisesUnified) {
|
|
@@ -133,6 +134,8 @@ function matchPremise(premise, proofStep, substitutions, fileContext, localConte
|
|
|
133
134
|
const subproofNode = proofStep.getSubproofNode(),
|
|
134
135
|
statementNode = proofStep.getStatementNode();
|
|
135
136
|
|
|
137
|
+
substitutions.snapshot();
|
|
138
|
+
|
|
136
139
|
if (subproofNode !== null) {
|
|
137
140
|
const subproofUnified = premise.unifySubproof(subproofNode, substitutions, fileContext, localContext);
|
|
138
141
|
|
|
@@ -145,6 +148,10 @@ function matchPremise(premise, proofStep, substitutions, fileContext, localConte
|
|
|
145
148
|
premiseUnified = statementUnified; ///
|
|
146
149
|
}
|
|
147
150
|
|
|
151
|
+
premiseUnified ?
|
|
152
|
+
substitutions.continue() :
|
|
153
|
+
substitutions.rollback();
|
|
154
|
+
|
|
148
155
|
return premiseUnified;
|
|
149
156
|
}
|
|
150
157
|
|
|
@@ -165,8 +172,17 @@ function unifyPremises(premises, proofSteps, substitutions, fileContext, localCo
|
|
|
165
172
|
}
|
|
166
173
|
|
|
167
174
|
function unifyConclusion(conclusion, statementNode, substitutions, fileContext, localContext) {
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
let conclusionUnified;
|
|
176
|
+
|
|
177
|
+
substitutions.snapshot();
|
|
178
|
+
|
|
179
|
+
const statementUnified = conclusion.unifyStatement(statementNode, substitutions, fileContext, localContext);
|
|
180
|
+
|
|
181
|
+
conclusionUnified = statementUnified; ///
|
|
182
|
+
|
|
183
|
+
conclusionUnified ?
|
|
184
|
+
substitutions.continue() :
|
|
185
|
+
substitutions.rollback();
|
|
170
186
|
|
|
171
187
|
return conclusionUnified;
|
|
172
188
|
}
|
|
@@ -106,7 +106,7 @@ function substituteTermNode(termNode, substitutions) {
|
|
|
106
106
|
const termVariableNode = variableNodeQuery(termNode);
|
|
107
107
|
|
|
108
108
|
if (termVariableNode !== null) {
|
|
109
|
-
substitutions.
|
|
109
|
+
substitutions.someSubstitution((substitution) => {
|
|
110
110
|
const substitutionMatchesVariableNode = substitution.matchVariableNode(termVariableNode);
|
|
111
111
|
|
|
112
112
|
if (substitutionMatchesVariableNode) {
|
|
@@ -121,7 +121,7 @@ function substituteTermNode(termNode, substitutions) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
function substituteVariableNode(variableNode, substitutions) {
|
|
124
|
-
substitutions.
|
|
124
|
+
substitutions.someSubstitution((substitution) => {
|
|
125
125
|
const substitutionMatchesVariableNode = substitution.matchVariableNode(variableNode);
|
|
126
126
|
|
|
127
127
|
if (substitutionMatchesVariableNode) {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
4
|
+
|
|
5
|
+
import { prune, compare } from "./utilities/array";
|
|
6
|
+
|
|
7
|
+
export default class Substitutions {
|
|
8
|
+
constructor(array, savedArray) {
|
|
9
|
+
this.array = array;
|
|
10
|
+
this.savedArray = savedArray;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getArray() {
|
|
14
|
+
return this.array;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getSavedArray() {
|
|
18
|
+
return this.savedArray;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
hasChanged() {
|
|
22
|
+
const compares = compare(this.array, this.savedArray),
|
|
23
|
+
changed = !compares; ///
|
|
24
|
+
|
|
25
|
+
return changed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
findSubstitution(callback) { return this.array.find(callback); }
|
|
29
|
+
|
|
30
|
+
someSubstitution(callback) { return this.array.some(callback); }
|
|
31
|
+
|
|
32
|
+
everySubstitution(callback) { return this.array.every(callback); }
|
|
33
|
+
|
|
34
|
+
addSubstitution(substitution) { this.array.push(substitution); }
|
|
35
|
+
|
|
36
|
+
removeSubstitution(substitution) {
|
|
37
|
+
const substitutionA = substitution; ///
|
|
38
|
+
|
|
39
|
+
prune(this.array, (substitution) => {
|
|
40
|
+
const substitutionB = substitution; ///
|
|
41
|
+
|
|
42
|
+
if (substitutionA !== substitutionB) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
snapshot() {
|
|
49
|
+
this.savedArray = [
|
|
50
|
+
...this.array
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
rollback() {
|
|
55
|
+
const start = 0,
|
|
56
|
+
end = Infinity;
|
|
57
|
+
|
|
58
|
+
this.array.splice(start, end, ...this.savedArray);
|
|
59
|
+
|
|
60
|
+
this.savedArray = null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
continue() {
|
|
64
|
+
this.savedArray = null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
transform() {
|
|
68
|
+
///
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
toJSON(tokens) {
|
|
72
|
+
const json = this.array.map((substitution) => {
|
|
73
|
+
const substitutionJSON = substitution.toJSON(tokens);
|
|
74
|
+
|
|
75
|
+
return substitutionJSON;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return json;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static fromNothing() {
|
|
82
|
+
const array = [],
|
|
83
|
+
savedArray = null,
|
|
84
|
+
substitutions = new Substitutions(array, savedArray);
|
|
85
|
+
|
|
86
|
+
return substitutions;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
90
|
+
const substitutionsJSON = json, ///
|
|
91
|
+
array = substitutionsJSON.map((substitutionJSON) => {
|
|
92
|
+
const json = substitutionJSON, ///
|
|
93
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromJSONAndFileContext(json, fileContext),
|
|
94
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
95
|
+
|
|
96
|
+
return substitution;
|
|
97
|
+
}),
|
|
98
|
+
savedArray = null,
|
|
99
|
+
substitutions = new Substitutions(array, savedArray);
|
|
100
|
+
|
|
101
|
+
return substitutions;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/supposition.js
CHANGED
|
@@ -47,7 +47,6 @@ export default class Supposition {
|
|
|
47
47
|
|
|
48
48
|
if (subproofAssertionNode !== null) {
|
|
49
49
|
const fileContextA = fileContext, ///
|
|
50
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
51
50
|
localContextB = localContext, ///
|
|
52
51
|
subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
53
52
|
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
@@ -58,7 +57,8 @@ export default class Supposition {
|
|
|
58
57
|
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode);
|
|
59
58
|
|
|
60
59
|
subproofUnified = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
|
|
61
|
-
const
|
|
60
|
+
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
61
|
+
nodeA = subproofAssertionStatementNode, ///
|
|
62
62
|
nodeB = subproofStatementNode, ///
|
|
63
63
|
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
64
64
|
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import Label from "./label";
|
|
4
4
|
import Consequent from "./consequent";
|
|
5
5
|
import Supposition from "./supposition";
|
|
6
|
-
import
|
|
6
|
+
import Substitutions from "./substitutions";
|
|
7
7
|
|
|
8
8
|
import { reverse, correlate } from "./utilities/array";
|
|
9
9
|
|
|
@@ -40,7 +40,7 @@ export default class TopLevelAssertion {
|
|
|
40
40
|
let statementUnified = false;
|
|
41
41
|
|
|
42
42
|
const proofSteps = localContext.getProofSteps(),
|
|
43
|
-
substitutions =
|
|
43
|
+
substitutions = Substitutions.fromNothing(),
|
|
44
44
|
suppositionsUnified = unifySuppositions(this.suppositions, proofSteps, substitutions, this.fileContext, localContext);
|
|
45
45
|
|
|
46
46
|
if (suppositionsUnified) {
|
|
@@ -76,11 +76,7 @@ export default class TopLevelAssertion {
|
|
|
76
76
|
return suppositionJSON;
|
|
77
77
|
}),
|
|
78
78
|
consequentJSON = this.consequent.toJSON(tokens),
|
|
79
|
-
substitutionsJSON = this.substitutions.
|
|
80
|
-
const substitutionJSON = substitution.toJSON();
|
|
81
|
-
|
|
82
|
-
return substitutionJSON;
|
|
83
|
-
}),
|
|
79
|
+
substitutionsJSON = this.substitutions.toJSON(tokens),
|
|
84
80
|
labels = labelsJSON, ///
|
|
85
81
|
suppositions = suppositionsJSON, ///
|
|
86
82
|
consequent = consequentJSON, ///
|
|
@@ -126,13 +122,9 @@ export default class TopLevelAssertion {
|
|
|
126
122
|
|
|
127
123
|
const substitutionsJSON = substitutions; ///
|
|
128
124
|
|
|
129
|
-
|
|
130
|
-
const json = substitutionJSON, ///
|
|
131
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromJSONAndFileContext(json, fileContext),
|
|
132
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
125
|
+
json = substitutionsJSON; ///
|
|
133
126
|
|
|
134
|
-
|
|
135
|
-
});
|
|
127
|
+
substitutions = Substitutions.fromJSONAndFileContext(json, fileContext);
|
|
136
128
|
|
|
137
129
|
return new Class(labels, suppositions, consequent, substitutions, fileContext); ///
|
|
138
130
|
}
|
|
@@ -159,6 +151,8 @@ function unifySuppositions(suppositions, proofSteps, substitutions, fileContext,
|
|
|
159
151
|
function unifySupposition(supposition, proofStep, substitutions, fileContext, localContext) {
|
|
160
152
|
let suppositionUnified = false;
|
|
161
153
|
|
|
154
|
+
substitutions.snapshot();
|
|
155
|
+
|
|
162
156
|
const subproofNode = proofStep.getSubproofNode(),
|
|
163
157
|
statementNode = proofStep.getStatementNode();
|
|
164
158
|
|
|
@@ -174,12 +168,25 @@ function unifySupposition(supposition, proofStep, substitutions, fileContext, lo
|
|
|
174
168
|
suppositionUnified = statementUnified; ///
|
|
175
169
|
}
|
|
176
170
|
|
|
171
|
+
suppositionUnified ?
|
|
172
|
+
substitutions.continue() :
|
|
173
|
+
substitutions.rollback();
|
|
174
|
+
|
|
177
175
|
return suppositionUnified;
|
|
178
176
|
}
|
|
179
177
|
|
|
180
178
|
function unifyConsequent(consequent, statementNode, substitutions, fileContext, localContext) {
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
let consequentUnified;
|
|
180
|
+
|
|
181
|
+
substitutions.snapshot();
|
|
182
|
+
|
|
183
|
+
const statementUnified = consequent.unifyStatement(statementNode, substitutions, fileContext, localContext);
|
|
184
|
+
|
|
185
|
+
consequentUnified = statementUnified; ///
|
|
186
|
+
|
|
187
|
+
consequentUnified ?
|
|
188
|
+
substitutions.continue() :
|
|
189
|
+
substitutions.rollback();
|
|
183
190
|
|
|
184
191
|
return consequentUnified;
|
|
185
192
|
}
|
|
@@ -7,7 +7,7 @@ import StatementForMetavariableSubstitution from "../substitution/statementForMe
|
|
|
7
7
|
export default function unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB, unifyAhead) {
|
|
8
8
|
let metavariableUnifiedAgainstStatement = false;
|
|
9
9
|
|
|
10
|
-
const substitution = substitutions.
|
|
10
|
+
const substitution = substitutions.findSubstitution((substitution) => {
|
|
11
11
|
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNodeA);
|
|
12
12
|
|
|
13
13
|
if (substitutionMatchesMetavariableNodeA) {
|
|
@@ -67,12 +67,12 @@ export default function unifyMetavariableAgainstStatement(metavariableNodeA, sta
|
|
|
67
67
|
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeStatementNodeAndSubstitutionNode(metavariableNode, statementNode, substitutionNode),
|
|
68
68
|
substitution = statementForMetavariableSubstitution; ///
|
|
69
69
|
|
|
70
|
-
substitutions.
|
|
70
|
+
substitutions.addSubstitution(substitution);
|
|
71
71
|
|
|
72
72
|
unifiedAhead = unifyAhead();
|
|
73
73
|
|
|
74
74
|
if (!unifiedAhead) {
|
|
75
|
-
substitutions.
|
|
75
|
+
substitutions.removeSubstitution(substitution);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
metavariableUnifiedAgainstStatement = unifiedAhead; ///
|
|
@@ -11,7 +11,7 @@ const variableNodeQuery = nodeQuery("/term/variable");
|
|
|
11
11
|
export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead) {
|
|
12
12
|
let variableUnifiedAgainstTerm = false;
|
|
13
13
|
|
|
14
|
-
const substitution = substitutions.
|
|
14
|
+
const substitution = substitutions.findSubstitution((substitution) => {
|
|
15
15
|
const substitutionMatchesVariableNodeA = substitution.matchVariableNode(variableNodeA);
|
|
16
16
|
|
|
17
17
|
if (substitutionMatchesVariableNodeA) {
|
|
@@ -54,12 +54,12 @@ export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, subst
|
|
|
54
54
|
termForVariableSubstitution = TermForVariableSubstitution.fromVariableNodeAndTermNode(variableNode, termNode),
|
|
55
55
|
substitution = termForVariableSubstitution; ///
|
|
56
56
|
|
|
57
|
-
substitutions.
|
|
57
|
+
substitutions.addSubstitution(substitution);
|
|
58
58
|
|
|
59
59
|
verifiedAhead = verifyAhead();
|
|
60
60
|
|
|
61
61
|
if (!verifiedAhead) {
|
|
62
|
-
substitutions.
|
|
62
|
+
substitutions.removeSubstitution(substitution);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/utilities/array.js
CHANGED
|
@@ -12,6 +12,21 @@ export function reverse(array) {
|
|
|
12
12
|
return array;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export function compare(arrayA, arrayB) {
|
|
16
|
+
let compares = false;
|
|
17
|
+
|
|
18
|
+
const arrayALength = arrayA.length,
|
|
19
|
+
arrayBLength = arrayB.length;
|
|
20
|
+
|
|
21
|
+
if (arrayALength === arrayBLength) {
|
|
22
|
+
const correlates = correlate(arrayA, arrayB);
|
|
23
|
+
|
|
24
|
+
compares = correlates; ///
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return compares;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
export function correlate(arrayA, arrayB, callback) {
|
|
16
31
|
arrayB = [ ///
|
|
17
32
|
...arrayB
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Verifier from "../verifier";
|
|
4
|
+
import verifyTerm from "../verify/term";
|
|
5
|
+
import verifyVariable from "../verify/variable";
|
|
6
|
+
import verifyMetavariable from "../verify/metavariable";
|
|
4
7
|
|
|
5
8
|
import { nodeQuery } from "../utilities/query";
|
|
6
|
-
import { verifyStandaloneTerm } from "../verify/term";
|
|
7
|
-
import { verifyStandaloneVariable } from "../verify/variable";
|
|
8
|
-
import { verifyStandaloneMetavariable } from "../verify/metavariable";
|
|
9
9
|
|
|
10
10
|
const termNodeQuery = nodeQuery("/term!"),
|
|
11
11
|
variableNodeQuery = nodeQuery("/variable!"),
|
|
@@ -31,8 +31,7 @@ class MetaLevelVerifier extends Verifier {
|
|
|
31
31
|
{
|
|
32
32
|
nodeQuery: metavariableNodeQuery,
|
|
33
33
|
verify: (metavariableNode, localContext, verifyAhead) => {
|
|
34
|
-
const
|
|
35
|
-
metavariableVerified = standaloneMetavariableVerified; ///
|
|
34
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, localContext, verifyAhead);
|
|
36
35
|
|
|
37
36
|
return metavariableVerified;
|
|
38
37
|
}
|
|
@@ -40,8 +39,7 @@ class MetaLevelVerifier extends Verifier {
|
|
|
40
39
|
{
|
|
41
40
|
nodeQuery: variableNodeQuery,
|
|
42
41
|
verify: (variableNode, localContext, verifyAhead) => {
|
|
43
|
-
const
|
|
44
|
-
variableVerified = standaloneVariableVerified; ///
|
|
42
|
+
const variableVerified = verifyVariable(variableNode, localContext, verifyAhead);
|
|
45
43
|
|
|
46
44
|
return variableVerified;
|
|
47
45
|
}
|
|
@@ -49,8 +47,8 @@ class MetaLevelVerifier extends Verifier {
|
|
|
49
47
|
{
|
|
50
48
|
nodeQuery: termNodeQuery,
|
|
51
49
|
verify: (termNode, localContext, verifyAhead) => {
|
|
52
|
-
const
|
|
53
|
-
termVerified =
|
|
50
|
+
const terms = [],
|
|
51
|
+
termVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
|
|
54
52
|
|
|
55
53
|
return termVerified;
|
|
56
54
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Verifier from "../verifier";
|
|
4
|
+
import verifyType from "../verify/type";
|
|
5
|
+
import verifyTerm from "../verify/term";
|
|
6
|
+
import verifyStatement from "../verify/statement";
|
|
4
7
|
|
|
5
8
|
import { nodeQuery } from "../utilities/query";
|
|
6
|
-
import { verifyStandaloneType } from "../verify/type";
|
|
7
|
-
import { verifyStandaloneTerm } from "../verify/term";
|
|
8
|
-
import { verifyStandaloneStatement } from "../verify/statement";
|
|
9
9
|
|
|
10
10
|
const termNodeQuery = nodeQuery("/term!"),
|
|
11
11
|
typeNodeQuery = nodeQuery("/type!"),
|
|
@@ -32,8 +32,8 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
32
32
|
{
|
|
33
33
|
nodeQuery: termNodeQuery,
|
|
34
34
|
verify: (termNode, localContext, verifyAhead) => {
|
|
35
|
-
const
|
|
36
|
-
termVerified =
|
|
35
|
+
const terms = [],
|
|
36
|
+
termVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
|
|
37
37
|
|
|
38
38
|
return termVerified;
|
|
39
39
|
}
|
|
@@ -41,8 +41,7 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
41
41
|
{
|
|
42
42
|
nodeQuery: typeNodeQuery,
|
|
43
43
|
verify: (typeNode, localContext, verifyAhead) => {
|
|
44
|
-
const
|
|
45
|
-
typeVerified = standaloneTypeVerified; ///
|
|
44
|
+
const typeVerified = verifyType(typeNode, localContext, verifyAhead);
|
|
46
45
|
|
|
47
46
|
return typeVerified;
|
|
48
47
|
}
|
|
@@ -50,8 +49,18 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
50
49
|
{
|
|
51
50
|
nodeQuery: statementNodeQuery,
|
|
52
51
|
verify: (statementNode, localContext, verifyAhead) => {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
let statementVerified;
|
|
53
|
+
|
|
54
|
+
const derived = false,
|
|
55
|
+
assignments = [];
|
|
56
|
+
|
|
57
|
+
statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
|
|
58
|
+
|
|
59
|
+
if (statementVerified) {
|
|
60
|
+
const verifiedAhead = verifyAhead();
|
|
61
|
+
|
|
62
|
+
statementVerified = verifiedAhead; ///
|
|
63
|
+
}
|
|
55
64
|
|
|
56
65
|
return statementVerified;
|
|
57
66
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Verifier from "../verifier";
|
|
4
|
+
import verifyTerm from "../verify/term";
|
|
5
|
+
import verifyType from "../verify/type";
|
|
4
6
|
import LocalContext from "../context/local";
|
|
5
7
|
|
|
6
8
|
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
import { verifyStandaloneType } from "../verify/type";
|
|
8
|
-
import { verifyStandaloneTerm } from "../verify/term";
|
|
9
9
|
|
|
10
10
|
const termNodeQuery = nodeQuery("/term!"),
|
|
11
11
|
typeNodeQuery = nodeQuery("/type!");
|
|
@@ -31,9 +31,9 @@ class TermAsConstructorVerifier extends Verifier {
|
|
|
31
31
|
{
|
|
32
32
|
nodeQuery: termNodeQuery,
|
|
33
33
|
verify: (termNode, fileContext, verifyAhead) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
termVerified =
|
|
34
|
+
const terms = [],
|
|
35
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
36
|
+
termVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
|
|
37
37
|
|
|
38
38
|
return termVerified;
|
|
39
39
|
}
|
|
@@ -42,8 +42,7 @@ class TermAsConstructorVerifier extends Verifier {
|
|
|
42
42
|
nodeQuery: typeNodeQuery,
|
|
43
43
|
verify: (typeNode, fileContext, verifyAhead) => {
|
|
44
44
|
const localContext = LocalContext.fromFileContext(fileContext),
|
|
45
|
-
|
|
46
|
-
typeVerified = standaloneTypeVerified; ///
|
|
45
|
+
typeVerified = verifyType(typeNode, localContext, verifyAhead);
|
|
47
46
|
|
|
48
47
|
return typeVerified;
|
|
49
48
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Verifier from "../verifier";
|
|
4
|
+
import verifyError from "../verify/error";
|
|
5
|
+
import verifyRule from "../verify/rule";
|
|
6
|
+
import verifyAxiom from "../verify/axiom";
|
|
7
|
+
import verifyLemma from "../verify/lemma";
|
|
8
|
+
import verifyTheorem from "../verify/theorem";
|
|
9
|
+
import verifyMetaLemma from "../verify/metaLemma";
|
|
10
|
+
import verifyConjecture from "../verify/conjecture";
|
|
11
|
+
import verifyMetatheorem from "../verify/metatheorem";
|
|
12
|
+
import verifyTypeDeclaration from "../verify/declaration/type";
|
|
13
|
+
import verifyVariableDeclaration from "../verify/declaration/variable";
|
|
14
|
+
import verifyCombinatorDeclaration from "../verify/declaration/combinator";
|
|
15
|
+
import verifyConstructorDeclaration from "../verify/declaration/constructor";
|
|
16
|
+
import verifyMetavariableDeclaration from "../verify/declaration/metavariable";
|
|
17
|
+
|
|
18
|
+
import { nodeQuery } from "../utilities/query";
|
|
19
|
+
|
|
20
|
+
const errorNodeQuery = nodeQuery("/error"),
|
|
21
|
+
ruleNodeQuery = nodeQuery("/rule!"),
|
|
22
|
+
axiomNodeQuery = nodeQuery("/axiom!"),
|
|
23
|
+
lemmaNodeQuery = nodeQuery("/lemma!"),
|
|
24
|
+
theoremNodeQuery = nodeQuery("/theorem!"),
|
|
25
|
+
metaLemmaNodeQuery = nodeQuery("/metaLemma!"),
|
|
26
|
+
conjectureNodeQuery = nodeQuery("/conjecture!"),
|
|
27
|
+
metatheoremNodeQuery = nodeQuery("/metatheorem!"),
|
|
28
|
+
typeDeclarationNodeQuery = nodeQuery("/typeDeclaration!"),
|
|
29
|
+
variableDeclarationNodeQuery = nodeQuery("/variableDeclaration!"),
|
|
30
|
+
combinatorDeclarationNodeQuery = nodeQuery("/combinatorDeclaration!"),
|
|
31
|
+
constructorDeclarationNodeQuery = nodeQuery("/constructorDeclaration!"),
|
|
32
|
+
metavariableDeclarationNodeQuery = nodeQuery("/metavariableDeclaration!");
|
|
33
|
+
|
|
34
|
+
class TopLevelVerifier extends Verifier {
|
|
35
|
+
verify(node, fileContext) {
|
|
36
|
+
let verified;
|
|
37
|
+
|
|
38
|
+
const nonTerminalNode = node, ///
|
|
39
|
+
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNode, fileContext, () => {
|
|
40
|
+
const verifiedAhead = true;
|
|
41
|
+
|
|
42
|
+
return verifiedAhead;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
verified = nonTerminalNodeVerified; ///
|
|
46
|
+
|
|
47
|
+
return verified;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static maps = [
|
|
51
|
+
{
|
|
52
|
+
nodeQuery: errorNodeQuery,
|
|
53
|
+
verify: (errorNode, fileContext) => {
|
|
54
|
+
const errorVerified = verifyError(errorNode, fileContext);
|
|
55
|
+
|
|
56
|
+
return errorVerified;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
nodeQuery: ruleNodeQuery,
|
|
61
|
+
verify: (ruleNode, fileContext) => {
|
|
62
|
+
const ruleVerified = verifyRule(ruleNode, fileContext);
|
|
63
|
+
|
|
64
|
+
return ruleVerified;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
nodeQuery: axiomNodeQuery,
|
|
69
|
+
verify: (axiomNode, fileContext) => {
|
|
70
|
+
const axiomVerified = verifyAxiom(axiomNode, fileContext);
|
|
71
|
+
|
|
72
|
+
return axiomVerified;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
nodeQuery: lemmaNodeQuery,
|
|
77
|
+
verify: (lemmaNode, fileContext) => {
|
|
78
|
+
const lemmaVerified = verifyLemma(lemmaNode, fileContext);
|
|
79
|
+
|
|
80
|
+
return lemmaVerified;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
nodeQuery: theoremNodeQuery,
|
|
85
|
+
verify: (theoremNode, fileContext) => {
|
|
86
|
+
const theoremVerified = verifyTheorem(theoremNode, fileContext);
|
|
87
|
+
|
|
88
|
+
return theoremVerified;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
nodeQuery: metaLemmaNodeQuery,
|
|
93
|
+
verify: (metaLemmaNode, fileContext) => {
|
|
94
|
+
const metaLemmaVerified = verifyMetaLemma(metaLemmaNode, fileContext);
|
|
95
|
+
|
|
96
|
+
return metaLemmaVerified;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
nodeQuery: conjectureNodeQuery,
|
|
101
|
+
verify: (conjectureNode, fileContext) => {
|
|
102
|
+
const conjectureVerified = verifyConjecture(conjectureNode, fileContext);
|
|
103
|
+
|
|
104
|
+
return conjectureVerified;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
nodeQuery: metatheoremNodeQuery,
|
|
109
|
+
verify: (metatheoremNode, fileContext) => {
|
|
110
|
+
const metatheoremVerified = verifyMetatheorem(metatheoremNode, fileContext);
|
|
111
|
+
|
|
112
|
+
return metatheoremVerified;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
nodeQuery: typeDeclarationNodeQuery,
|
|
117
|
+
verify: (typeDeclarationNode, fileContext) => {
|
|
118
|
+
const typeDeclarationVerified = verifyTypeDeclaration(typeDeclarationNode, fileContext);
|
|
119
|
+
|
|
120
|
+
return typeDeclarationVerified;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
nodeQuery: variableDeclarationNodeQuery,
|
|
125
|
+
verify: (variableDeclarationNode, fileContext) => {
|
|
126
|
+
const variableDeclarationVerified = verifyVariableDeclaration(variableDeclarationNode, fileContext);
|
|
127
|
+
|
|
128
|
+
return variableDeclarationVerified;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
nodeQuery: combinatorDeclarationNodeQuery,
|
|
133
|
+
verify: (combinatorDeclarationNode, fileContext) => {
|
|
134
|
+
const combinatorDeclarationVerified = verifyCombinatorDeclaration(combinatorDeclarationNode, fileContext);
|
|
135
|
+
|
|
136
|
+
return combinatorDeclarationVerified;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
nodeQuery: constructorDeclarationNodeQuery,
|
|
141
|
+
verify: (constructorDeclarationNode, fileContext) => {
|
|
142
|
+
const constructorDeclarationVerified = verifyConstructorDeclaration(constructorDeclarationNode, fileContext);
|
|
143
|
+
|
|
144
|
+
return constructorDeclarationVerified;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
nodeQuery: metavariableDeclarationNodeQuery,
|
|
149
|
+
verify: (metavariableDeclarationNode, fileContext) => {
|
|
150
|
+
const metavariableDeclarationVerified = verifyMetavariableDeclaration(metavariableDeclarationNode, fileContext);
|
|
151
|
+
|
|
152
|
+
return metavariableDeclarationVerified;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const topLevelVerifier = new TopLevelVerifier();
|
|
159
|
+
|
|
160
|
+
export default topLevelVerifier;
|
package/src/verify/axiom.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Axiom from "../axiom";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
|
+
import Substitutions from "../substitutions";
|
|
6
7
|
import verifyConsequent from "../verify/consequent";
|
|
7
8
|
import verifySuppositions from "../verify/suppositions";
|
|
8
9
|
|
|
@@ -37,8 +38,8 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
37
38
|
|
|
38
39
|
if (consequentVerified) {
|
|
39
40
|
const firstConsequent = first(consequents),
|
|
41
|
+
substitutions = Substitutions.fromNothing(),
|
|
40
42
|
consequent = firstConsequent, ///
|
|
41
|
-
substitutions = [],
|
|
42
43
|
axiom = Axiom.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
|
|
43
44
|
|
|
44
45
|
fileContext.addAxiom(axiom);
|