occam-verify-cli 0.0.1074 → 0.0.1075
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/assertion/type.js +4 -5
- package/lib/assignment/variable.js +2 -2
- package/lib/axiom.js +9 -12
- package/lib/combinator/bracketed.js +3 -2
- package/lib/combinator.js +6 -6
- package/lib/conclusion.js +2 -3
- package/lib/conjecture.js +10 -15
- package/lib/consequent.js +2 -3
- package/lib/constructor/bracketed.js +3 -2
- package/lib/constructor.js +6 -6
- package/lib/context/file.js +48 -102
- package/lib/context/local.js +21 -20
- package/lib/declaration/combinator.js +5 -5
- package/lib/declaration/constructor.js +5 -5
- package/lib/declaration/metavariable.js +4 -5
- package/lib/declaration/type.js +3 -3
- package/lib/declaration/variable.js +5 -5
- package/lib/declaration.js +6 -2
- package/lib/derivation.js +6 -2
- package/lib/equality.js +6 -2
- package/lib/frame.js +11 -13
- package/lib/index.js +13 -1
- package/lib/judgement.js +11 -8
- package/lib/label.js +6 -7
- package/lib/lemma.js +10 -15
- package/lib/metaLemma.js +15 -15
- package/lib/metatheorem.js +9 -14
- package/lib/metavariable.js +17 -23
- package/lib/mixins/statement/qualified/unify.js +2 -2
- package/lib/mixins/statement/verify.js +8 -12
- package/lib/mixins/term/verify.js +3 -3
- package/lib/premise.js +2 -3
- package/lib/proof.js +8 -4
- package/lib/proofStep.js +3 -7
- package/lib/reference.js +3 -3
- package/lib/rule.js +11 -16
- package/lib/statement/qualified.js +6 -2
- package/lib/statement.js +5 -5
- package/lib/subDerivation.js +6 -2
- package/lib/subproof.js +10 -7
- package/lib/substitution/statementForMetavariable.js +14 -15
- package/lib/substitution.js +13 -13
- package/lib/substitutions.js +51 -47
- package/lib/supposition.js +2 -3
- package/lib/term.js +5 -5
- package/lib/theorem.js +10 -15
- package/lib/topLevelAssertion.js +3 -3
- package/lib/type.js +5 -5
- package/lib/unifier/equality.js +2 -2
- package/lib/unifier/metaLevel.js +6 -6
- package/lib/unifier/metavariable.js +5 -5
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/brackets.js +2 -2
- package/lib/utilities/node.js +2 -7
- package/lib/utilities/nominal.js +26 -0
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/tokens.js +3 -7
- package/lib/variable.js +5 -5
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verifier/termAsConstructor.js +2 -2
- package/lib/verifier/topLevel.js +9 -15
- package/package.json +1 -1
- package/src/assertion/type.js +2 -2
- package/src/assignment/variable.js +2 -1
- package/src/axiom.js +6 -8
- package/src/combinator/bracketed.js +6 -3
- package/src/combinator.js +4 -4
- package/src/conclusion.js +2 -2
- package/src/conjecture.js +8 -11
- package/src/consequent.js +2 -2
- package/src/constructor/bracketed.js +6 -3
- package/src/constructor.js +4 -4
- package/src/context/file.js +46 -84
- package/src/context/local.js +15 -17
- package/src/declaration/combinator.js +5 -4
- package/src/declaration/constructor.js +5 -4
- package/src/declaration/metavariable.js +3 -4
- package/src/declaration/type.js +2 -2
- package/src/declaration/variable.js +5 -4
- package/src/declaration.js +7 -1
- package/src/derivation.js +7 -1
- package/src/equality.js +7 -1
- package/src/frame.js +10 -9
- package/src/index.js +12 -0
- package/src/judgement.js +11 -5
- package/src/label.js +5 -5
- package/src/lemma.js +8 -11
- package/src/metaLemma.js +13 -11
- package/src/metatheorem.js +6 -10
- package/src/metavariable.js +18 -34
- package/src/mixins/statement/qualified/unify.js +1 -2
- package/src/mixins/statement/verify.js +19 -18
- package/src/mixins/term/verify.js +3 -2
- package/src/premise.js +2 -2
- package/src/proof.js +10 -3
- package/src/proofStep.js +4 -6
- package/src/reference.js +3 -2
- package/src/rule.js +10 -12
- package/src/statement/qualified.js +7 -1
- package/src/statement.js +3 -3
- package/src/subDerivation.js +8 -2
- package/src/subproof.js +12 -5
- package/src/substitution/statementForMetavariable.js +12 -12
- package/src/substitution.js +9 -9
- package/src/substitutions.js +42 -34
- package/src/supposition.js +2 -2
- package/src/term.js +3 -3
- package/src/theorem.js +8 -11
- package/src/topLevelAssertion.js +3 -2
- package/src/type.js +3 -3
- package/src/unifier/equality.js +1 -1
- package/src/unifier/metaLevel.js +8 -10
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +5 -5
- package/src/utilities/brackets.js +2 -2
- package/src/utilities/node.js +1 -10
- package/src/utilities/nominal.js +14 -0
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +2 -9
- package/src/variable.js +3 -3
- package/src/verifier/metaLevel.js +2 -2
- package/src/verifier/statementAsCombinator.js +3 -3
- package/src/verifier/termAsConstructor.js +2 -2
- package/src/verifier/topLevel.js +15 -14
- package/lib/assignment/metavariable.js +0 -62
- package/lib/unifier/intrinsicLevel.js +0 -144
- package/lib/utilities/unify.js +0 -24
- package/lib/verifier/intrinsicLevel.js +0 -140
- package/src/assignment/metavariable.js +0 -30
- package/src/unifier/intrinsicLevel.js +0 -54
- package/src/utilities/unify.js +0 -23
- package/src/verifier/intrinsicLevel.js +0 -42
package/src/subproof.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
4
5
|
import LocalContext from "./context/local";
|
|
5
|
-
import SubDerivation from "./subDerivation";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
|
-
import {
|
|
8
|
+
import { subproofStringFromSubproofNode } from "./utilities/subproof";
|
|
9
9
|
|
|
10
10
|
const suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
11
11
|
subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
class Subproof {
|
|
14
14
|
constructor(string, suppositions, subDerivation) {
|
|
15
15
|
this.string = string;
|
|
16
16
|
this.suppositions = suppositions;
|
|
@@ -79,7 +79,8 @@ export default class Subproof {
|
|
|
79
79
|
let subproof = null;
|
|
80
80
|
|
|
81
81
|
if (subproofNode !== null) {
|
|
82
|
-
const
|
|
82
|
+
const { Supposition, SubDerivation } = shim,
|
|
83
|
+
subproofString = subproofStringFromSubproofNode(subproofNode, fileContext),
|
|
83
84
|
suppositionNodes = suppositionNodesQuery(subproofNode),
|
|
84
85
|
subDerivationNode = subDerivationNodeQuery(subproofNode),
|
|
85
86
|
string = subproofString, ///
|
|
@@ -96,3 +97,9 @@ export default class Subproof {
|
|
|
96
97
|
return subproof;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
Object.assign(shim, {
|
|
102
|
+
Subproof
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export default Subproof;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
5
|
import LocalContext from "../context/local";
|
|
6
|
-
import Substitutions from "../substitutions";
|
|
7
6
|
import metaLevelUnifier from "../unifier/metaLevel";
|
|
8
7
|
|
|
9
8
|
import { stripBracketsFromStatementNode } from "../utilities/brackets";
|
|
@@ -30,10 +29,10 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
30
29
|
return this.substitution;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
const
|
|
32
|
+
getMetavariableNode() {
|
|
33
|
+
const metavariableNode = this.metavariable.getNode();
|
|
35
34
|
|
|
36
|
-
return
|
|
35
|
+
return metavariableNode;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
isSimple() {
|
|
@@ -49,8 +48,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
49
48
|
|
|
50
49
|
localContextB.trace(`Resolving the ${substitutionString} substitution...`);
|
|
51
50
|
|
|
52
|
-
const
|
|
53
|
-
simpleSubstitution = substitutions.
|
|
51
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
52
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
54
53
|
|
|
55
54
|
if (simpleSubstitution !== null) {
|
|
56
55
|
const substitution = simpleSubstitution, ///
|
|
@@ -104,7 +103,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
104
103
|
unifyStatement(statement, localContextA, localContextB) {
|
|
105
104
|
let substitution = null;
|
|
106
105
|
|
|
107
|
-
const
|
|
106
|
+
const { Substitutions } = shim,
|
|
107
|
+
substitutions = Substitutions.fromNothing(),
|
|
108
108
|
statementUnified = this.statement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
109
109
|
|
|
110
110
|
if (statementUnified) {
|
|
@@ -128,7 +128,7 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
128
128
|
return statementNodeMatches;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
132
132
|
|
|
133
133
|
matchSubstitutionNode(substitutionNode) {
|
|
134
134
|
let substitutionNodeMatches;
|
|
@@ -146,12 +146,12 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
146
146
|
return substitutionNodeMatches;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
const
|
|
149
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
150
|
+
const metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
151
151
|
substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
|
|
152
|
-
|
|
152
|
+
metavariableNodeAndSubstitutionNodeMatches = (metavariableNodeMatches && substitutionNodeMatches);
|
|
153
153
|
|
|
154
|
-
return
|
|
154
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
toJSON() {
|
package/src/substitution.js
CHANGED
|
@@ -35,10 +35,10 @@ class Substitution {
|
|
|
35
35
|
return substitutionNode;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
const
|
|
38
|
+
getMetavariableNode() {
|
|
39
|
+
const metavariableNode = null;
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return metavariableNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
isSimple() {
|
|
@@ -90,16 +90,16 @@ class Substitution {
|
|
|
90
90
|
return variableNameMatches;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
const
|
|
93
|
+
matchMetavariableNode(metavariableNode) {
|
|
94
|
+
const metavariableNodeMatches = false;
|
|
95
95
|
|
|
96
|
-
return
|
|
96
|
+
return metavariableNodeMatches;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
const
|
|
99
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
100
|
+
const metavariableNodeAndSubstitutionNodeMatches = false;
|
|
101
101
|
|
|
102
|
-
return
|
|
102
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
|
package/src/substitutions.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
3
5
|
import { arrayUtilities } from "necessary";
|
|
4
6
|
|
|
5
7
|
import { EMPTY_STRING } from "./constants";
|
|
6
8
|
|
|
7
9
|
const { find, first, prune, filter, compress } = arrayUtilities;
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
class Substitutions {
|
|
10
12
|
constructor(array, savedArray) {
|
|
11
13
|
this.array = array;
|
|
12
14
|
this.savedArray = savedArray;
|
|
@@ -34,24 +36,26 @@ export default class Substitutions {
|
|
|
34
36
|
return firstSubstitution;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
+
getMetavariableNodes() {
|
|
40
|
+
const metavariableNodes = [];
|
|
39
41
|
|
|
40
42
|
this.forEachSubstitution((substitution) => {
|
|
41
|
-
const
|
|
43
|
+
const metavariableNode = substitution.getMetavariableNode();
|
|
42
44
|
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
+
if (metavariableNode !== null) {
|
|
46
|
+
metavariableNodes.push(metavariableNode);
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
49
|
|
|
48
|
-
compress(
|
|
49
|
-
|
|
50
|
+
compress(metavariableNodes, (metavariableNodeA, metavariableNodeB) => {
|
|
51
|
+
const metavariableNodeAMatchesMetavariableNodeB = metavariableNodeB.match(metavariableNodeA);
|
|
52
|
+
|
|
53
|
+
if (metavariableNodeAMatchesMetavariableNodeB) {
|
|
50
54
|
return true;
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
|
|
54
|
-
return
|
|
58
|
+
return metavariableNodes;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
mapSubstitution(callback) { return this.array.map(callback); }
|
|
@@ -102,11 +106,11 @@ export default class Substitutions {
|
|
|
102
106
|
return substitution;
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
|
|
109
|
+
findSubstitutionByMetavariableNode(metavariableNode) {
|
|
106
110
|
const substitution = this.findSubstitution((substitution) => {
|
|
107
|
-
const
|
|
111
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
108
112
|
|
|
109
|
-
if (
|
|
113
|
+
if (metavariableNodeMatches) {
|
|
110
114
|
return true;
|
|
111
115
|
}
|
|
112
116
|
});
|
|
@@ -114,11 +118,11 @@ export default class Substitutions {
|
|
|
114
118
|
return substitution;
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
findSubstitutionsByMetavariableNode(metavariableNode) {
|
|
118
122
|
const substitutions = this.findSubstitutions((substitution) => {
|
|
119
|
-
const
|
|
123
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
120
124
|
|
|
121
|
-
if (
|
|
125
|
+
if (metavariableNodeMatches) {
|
|
122
126
|
return true;
|
|
123
127
|
}
|
|
124
128
|
});
|
|
@@ -126,8 +130,8 @@ export default class Substitutions {
|
|
|
126
130
|
return substitutions;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
const substitutions = this.
|
|
133
|
+
findSimpleSubstitutionByMetavariableNode(metavariableNode) {
|
|
134
|
+
const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
|
|
131
135
|
simpleSubstitutions = substitutions.filterSubstitution((substitution) => {
|
|
132
136
|
const substitutionSimple = substitution.isSimple();
|
|
133
137
|
|
|
@@ -141,8 +145,8 @@ export default class Substitutions {
|
|
|
141
145
|
return simpleSubstitution;
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
const substitutions = this.
|
|
148
|
+
findComplexSubstitutionsByMetavariableNode(metavariableNode) {
|
|
149
|
+
const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
|
|
146
150
|
complexSubstitutions = substitutions.filterSubstitution((substitution) => {
|
|
147
151
|
const substitutionComplex = substitution.isComplex();
|
|
148
152
|
|
|
@@ -154,11 +158,11 @@ export default class Substitutions {
|
|
|
154
158
|
return complexSubstitutions;
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
158
162
|
const substitutions = this.findSubstitutions((substitution) => {
|
|
159
|
-
const
|
|
163
|
+
const metavariableNodeAndSubstitutionNodeMatch = substitution.matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
160
164
|
|
|
161
|
-
if (
|
|
165
|
+
if (metavariableNodeAndSubstitutionNodeMatch) {
|
|
162
166
|
return true;
|
|
163
167
|
}
|
|
164
168
|
}),
|
|
@@ -168,15 +172,15 @@ export default class Substitutions {
|
|
|
168
172
|
return substitution;
|
|
169
173
|
}
|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
const simpleSubstitution = this.
|
|
175
|
+
isSimpleSubstitutionPresentByMetavariableNode(metavariableNode) {
|
|
176
|
+
const simpleSubstitution = this.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
173
177
|
simpleSubstitutionPresent = (simpleSubstitution !== null);
|
|
174
178
|
|
|
175
179
|
return simpleSubstitutionPresent;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
const substitution = this.
|
|
182
|
+
isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
183
|
+
const substitution = this.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
180
184
|
substitutionPresent = (substitution !== null);
|
|
181
185
|
|
|
182
186
|
return substitutionPresent;
|
|
@@ -220,9 +224,9 @@ export default class Substitutions {
|
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
resolve(localContextA, localContextB) {
|
|
223
|
-
const
|
|
224
|
-
resolved =
|
|
225
|
-
const complexSubstitutions = this.
|
|
227
|
+
const metavariableNodes = this.getMetavariableNodes(),
|
|
228
|
+
resolved = metavariableNodes.every((metavariableNode) => {
|
|
229
|
+
const complexSubstitutions = this.findComplexSubstitutionsByMetavariableNode(metavariableNode),
|
|
226
230
|
complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
|
|
227
231
|
const substitution = complexSubstitution, ///
|
|
228
232
|
substitutions = this, ///
|
|
@@ -252,7 +256,7 @@ export default class Substitutions {
|
|
|
252
256
|
...this.array
|
|
253
257
|
];
|
|
254
258
|
|
|
255
|
-
|
|
259
|
+
leftDifference(array, this.savedArray);
|
|
256
260
|
|
|
257
261
|
array.forEach((substitution) => {
|
|
258
262
|
this.removeSubstitution(substitution, localContext);
|
|
@@ -303,11 +307,15 @@ export default class Substitutions {
|
|
|
303
307
|
}
|
|
304
308
|
}
|
|
305
309
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
310
|
+
Object.assign(shim, {
|
|
311
|
+
Substitutions
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
function leftDifference(arrayA, arrayB) {
|
|
315
|
+
filter(arrayA, (elementA) => {
|
|
316
|
+
const arrayBIncludesElementA = arrayB.includes(elementA);
|
|
309
317
|
|
|
310
|
-
if (!
|
|
318
|
+
if (!arrayBIncludesElementA) {
|
|
311
319
|
return true;
|
|
312
320
|
}
|
|
313
321
|
});
|
package/src/supposition.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
import SubproofAssertion from "./assertion/subproof";
|
|
6
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
7
6
|
|
|
8
7
|
import { nodeQuery } from "./utilities/query";
|
|
9
8
|
import { assignAssignments } from "./utilities/assignments";
|
|
@@ -155,7 +154,8 @@ class Supposition {
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
158
|
-
const
|
|
157
|
+
const { UnqualifiedStatement } = shim,
|
|
158
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
159
159
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
160
160
|
supposition = new Supposition(fileContext, unqualifiedStatement);
|
|
161
161
|
|
package/src/term.js
CHANGED
|
@@ -213,12 +213,12 @@ class Term {
|
|
|
213
213
|
return verifiedGivenType;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
verifyWhenDeclared(fileContext) {
|
|
217
217
|
let verifiedAtTopLevel;
|
|
218
218
|
|
|
219
219
|
const termString = this.string; ///
|
|
220
220
|
|
|
221
|
-
fileContext.trace(`Verifying the '${termString}' term
|
|
221
|
+
fileContext.trace(`Verifying the '${termString}' term when declared...`);
|
|
222
222
|
|
|
223
223
|
const termNode = this.node, ///
|
|
224
224
|
termVerifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
|
|
@@ -230,7 +230,7 @@ class Term {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
if (verifiedAtTopLevel) {
|
|
233
|
-
fileContext.debug(`...verified the '${termString}' term
|
|
233
|
+
fileContext.debug(`...verified the '${termString}' term when declared.`);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
return verifiedAtTopLevel;
|
package/src/theorem.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Label from "./label";
|
|
5
|
-
import Proof from "./proof";
|
|
6
|
-
import Consequent from "./consequent";
|
|
7
|
-
import Supposition from "./supposition";
|
|
8
4
|
import LocalContext from "./context/local";
|
|
9
|
-
import Substitutions from "./substitutions";
|
|
10
5
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
11
6
|
|
|
12
7
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
@@ -25,15 +20,15 @@ class Theorem extends TopLevelAssertion {
|
|
|
25
20
|
|
|
26
21
|
this.fileContext.trace(`Verifying the '${theoremString}' theorem...`);
|
|
27
22
|
|
|
28
|
-
const
|
|
29
|
-
const
|
|
23
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
24
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
30
25
|
|
|
31
|
-
if (
|
|
26
|
+
if (labelVVerifiedWhenDeclared) {
|
|
32
27
|
return true;
|
|
33
28
|
}
|
|
34
29
|
});
|
|
35
30
|
|
|
36
|
-
if (
|
|
31
|
+
if (labelsVerifiedWhenDeclared) {
|
|
37
32
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
38
33
|
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
39
34
|
const suppositionVerified = supposition.verify(localContext);
|
|
@@ -47,7 +42,8 @@ class Theorem extends TopLevelAssertion {
|
|
|
47
42
|
const consequentVerified = this.consequent.verify(localContext);
|
|
48
43
|
|
|
49
44
|
if (consequentVerified) {
|
|
50
|
-
const
|
|
45
|
+
const { Substitutions } = shim,
|
|
46
|
+
substitutions = Substitutions.fromNothing(),
|
|
51
47
|
proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
|
|
52
48
|
|
|
53
49
|
if (proofVerified) {
|
|
@@ -71,7 +67,8 @@ class Theorem extends TopLevelAssertion {
|
|
|
71
67
|
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
|
|
72
68
|
|
|
73
69
|
static fromTheoremNode(theoremNode, fileContext) {
|
|
74
|
-
const
|
|
70
|
+
const { Label, Proof, Consequent, Supposition } = shim,
|
|
71
|
+
proofNode = proofNodeQuery(theoremNode),
|
|
75
72
|
labelNodes = labelNodesQuery(theoremNode),
|
|
76
73
|
consequentNode = consequentNodeQuery(theoremNode),
|
|
77
74
|
suppositionNodes = suppositionNodesQuery(theoremNode),
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import shim from "./shim";
|
|
6
6
|
|
|
7
7
|
import { EMPTY_STRING } from "./constants";
|
|
8
8
|
import { labelsFromJSON,
|
|
@@ -63,7 +63,8 @@ export default class TopLevelAssertion {
|
|
|
63
63
|
unifyStatement(statement, localContext) {
|
|
64
64
|
let statementUnified = false;
|
|
65
65
|
|
|
66
|
-
const
|
|
66
|
+
const { Substitutions } = shim,
|
|
67
|
+
proofSteps = localContext.getProofSteps(),
|
|
67
68
|
substitutions = Substitutions.fromNothing(),
|
|
68
69
|
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
69
70
|
|
package/src/type.js
CHANGED
|
@@ -109,12 +109,12 @@ class Type {
|
|
|
109
109
|
return typeNodeMatches;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
verifyWhenDeclared(fileContext) {
|
|
113
113
|
let verifiedAtTopLevel = false;
|
|
114
114
|
|
|
115
115
|
const typeString = this.string; ///
|
|
116
116
|
|
|
117
|
-
fileContext.trace(`Verifying the '${typeString}' type
|
|
117
|
+
fileContext.trace(`Verifying the '${typeString}' type when declared...`);
|
|
118
118
|
|
|
119
119
|
const typePresent = fileContext.isTypePresentByTypeName(this.name);
|
|
120
120
|
|
|
@@ -136,7 +136,7 @@ class Type {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (verifiedAtTopLevel) {
|
|
139
|
-
fileContext.debug(`...verified the '${typeString}' type
|
|
139
|
+
fileContext.debug(`...verified the '${typeString}' type when declared.`);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
return verifiedAtTopLevel;
|
package/src/unifier/equality.js
CHANGED
|
@@ -5,7 +5,7 @@ import Unifier from "../unifier";
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
6
|
import { findEquivalenceByTermNodes } from "../utilities/equivalences";
|
|
7
7
|
|
|
8
|
-
const termNodeQuery = nodeQuery("/term
|
|
8
|
+
const termNodeQuery = nodeQuery("/term");
|
|
9
9
|
|
|
10
10
|
class EqualityUnifier extends Unifier {
|
|
11
11
|
unify(leftTermNode, rightTermNode, localContext) {
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -6,11 +6,11 @@ import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
|
6
6
|
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
|
-
import { variableNameFromVariableNode
|
|
9
|
+
import { variableNameFromVariableNode } from "../utilities/name";
|
|
10
10
|
|
|
11
|
-
const termNodeQuery = nodeQuery("/term
|
|
12
|
-
frameNodeQuery = nodeQuery("/frame
|
|
13
|
-
statementNodeQuery = nodeQuery("/statement
|
|
11
|
+
const termNodeQuery = nodeQuery("/term"),
|
|
12
|
+
frameNodeQuery = nodeQuery("/frame"),
|
|
13
|
+
statementNodeQuery = nodeQuery("/statement"),
|
|
14
14
|
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
15
15
|
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
16
16
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
@@ -56,8 +56,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
56
56
|
|
|
57
57
|
const { Statement } = shim,
|
|
58
58
|
metavariableNode = statementMetavariableNode, ///
|
|
59
|
-
|
|
60
|
-
metavariable = localContextA.findMetavariableByMetavariableName(metavariableName);
|
|
59
|
+
metavariable = localContextA.findMetavariableByMetavariableNode(metavariableNode, localContextB);
|
|
61
60
|
|
|
62
61
|
localContext = localContextB; ///
|
|
63
62
|
|
|
@@ -67,7 +66,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
67
66
|
|
|
68
67
|
statementUnified = metavariable.unifyStatement(statement, substitution, substitutions, localContext);
|
|
69
68
|
} else {
|
|
70
|
-
statementUnified =
|
|
69
|
+
statementUnified = unifyChildNodes(statementNodeA, statementNodeB, substitutions, localContextA, localContextB);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
|
|
@@ -81,8 +80,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
81
80
|
let frameUnified = false;
|
|
82
81
|
|
|
83
82
|
const metavariableNode = frameMetavariableNodeA, ///
|
|
84
|
-
|
|
85
|
-
metavariablePresent = localContextA.isMetavariablePresentByMetavariableName(metavariableName);
|
|
83
|
+
metavariablePresent = localContextA.isMetavariablePresentByMetavariableNode(metavariableNode, localContextB);
|
|
86
84
|
|
|
87
85
|
if (metavariablePresent) {
|
|
88
86
|
const { Frame, Metavariable } = shim,
|
|
@@ -127,7 +125,7 @@ const metaLevelUnifier = new MetaLevelUnifier();
|
|
|
127
125
|
|
|
128
126
|
export default metaLevelUnifier;
|
|
129
127
|
|
|
130
|
-
function
|
|
128
|
+
function unifyChildNodes(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
|
|
131
129
|
const nonTerminalNodeA = statementNodeA, ///
|
|
132
130
|
nonTerminalNodeB = statementNodeB, ///
|
|
133
131
|
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
@@ -6,8 +6,8 @@ import Unifier from "../unifier";
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
8
8
|
|
|
9
|
-
const typeNodeQuery = nodeQuery("/type
|
|
10
|
-
termNodeQuery = nodeQuery("/term
|
|
9
|
+
const typeNodeQuery = nodeQuery("/type"),
|
|
10
|
+
termNodeQuery = nodeQuery("/term");
|
|
11
11
|
|
|
12
12
|
class MetavariableUnifier extends Unifier {
|
|
13
13
|
unify(metavariableNodeA, metavariableNodeB, localContext) {
|
|
@@ -27,7 +27,7 @@ class MetavariableUnifier extends Unifier {
|
|
|
27
27
|
nodeQueryA: typeNodeQuery,
|
|
28
28
|
nodeQueryB: termNodeQuery,
|
|
29
29
|
unify: (typeNodeA, termNodeB, localContext) => {
|
|
30
|
-
let
|
|
30
|
+
let termUnified = false;
|
|
31
31
|
|
|
32
32
|
const { Term } = shim,
|
|
33
33
|
typeNode = typeNodeA, ///
|
|
@@ -40,11 +40,11 @@ class MetavariableUnifier extends Unifier {
|
|
|
40
40
|
termVerifiedGivenType = term.verifyGivenType(type, localContext);
|
|
41
41
|
|
|
42
42
|
if (termVerifiedGivenType) {
|
|
43
|
-
|
|
43
|
+
termUnified = true;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return termUnified;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
];
|
|
@@ -6,11 +6,11 @@ import Unifier from "../unifier";
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
8
8
|
|
|
9
|
-
const termNodeQuery = nodeQuery("/term
|
|
10
|
-
typeNodeQuery = nodeQuery("/type
|
|
11
|
-
frameNodeQuery = nodeQuery("/frame
|
|
12
|
-
metaTypeNodeQuery = nodeQuery("/metaType
|
|
13
|
-
statementNodeQuery = nodeQuery("/statement
|
|
9
|
+
const termNodeQuery = nodeQuery("/term"),
|
|
10
|
+
typeNodeQuery = nodeQuery("/type"),
|
|
11
|
+
frameNodeQuery = nodeQuery("/frame"),
|
|
12
|
+
metaTypeNodeQuery = nodeQuery("/metaType"),
|
|
13
|
+
statementNodeQuery = nodeQuery("/statement");
|
|
14
14
|
|
|
15
15
|
class StatementWithCombinatorUnifier extends Unifier {
|
|
16
16
|
unify(combinatorStatementNode, statementNode, assignments, stated, localContext) {
|
|
@@ -5,8 +5,8 @@ import { bracketedTermNode } from "../constructor/bracketed";
|
|
|
5
5
|
import { bracketedStatementNode } from "../combinator/bracketed";
|
|
6
6
|
import { BRACKETED_TERM_DEPTH, BRACKETED_STATEMENT_DEPTH } from "../constants";
|
|
7
7
|
|
|
8
|
-
const bracketedTermChildNodeQuery = nodeQuery("/term/argument/term
|
|
9
|
-
bracketedStatementChildNodeQuery = nodeQuery("/statement/metaArgument/statement
|
|
8
|
+
const bracketedTermChildNodeQuery = nodeQuery("/term/argument/term"),
|
|
9
|
+
bracketedStatementChildNodeQuery = nodeQuery("/statement/metaArgument/statement");
|
|
10
10
|
|
|
11
11
|
export function stripBracketsFromTermNode(termNode) {
|
|
12
12
|
const bracketedTermChildNode = bracketedTermChildNodeFromTermNode(termNode);
|
package/src/utilities/node.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { parsersUtilities } from "occam-custom-grammars";
|
|
4
|
-
|
|
5
3
|
import { nodeQuery } from "../utilities/query";
|
|
6
|
-
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
4
|
import { VARIABLE_RULE_NAME,
|
|
8
5
|
METAVARIABLE_RULE_NAME,
|
|
9
6
|
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
10
7
|
CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
11
8
|
import { variableTokensFromVariableString,
|
|
12
9
|
metavariableTokensFromMetavariableString,
|
|
13
|
-
unqualifiedStatementTokensFromUnqualifiedStatementString,
|
|
14
10
|
constructorDeclarationTokensFromConstructorDeclarationString } from "../utilities/tokens";
|
|
15
11
|
|
|
16
|
-
const { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
17
|
-
|
|
18
|
-
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
19
|
-
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
20
|
-
|
|
21
12
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
|
|
22
13
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
|
|
23
14
|
substitutionNodeQuery = nodeQuery("/unqualifiedStatement/statement/substitution");
|
|
@@ -114,7 +105,7 @@ export function constructorDeclarationNodeFromConstructorDeclarationTokens(const
|
|
|
114
105
|
return constructorDeclarationNode;
|
|
115
106
|
}
|
|
116
107
|
|
|
117
|
-
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser
|
|
108
|
+
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser) {
|
|
118
109
|
const ruleMap = parser.getRuleMap(),
|
|
119
110
|
rule = ruleMap[ruleName],
|
|
120
111
|
node = parser.parse(tokens, rule);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
4
|
+
|
|
5
|
+
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
6
|
+
|
|
7
|
+
const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
8
|
+
{ nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
9
|
+
|
|
10
|
+
const combinedCustomGrammar = combinedCustomGrammarFromNothing();
|
|
11
|
+
|
|
12
|
+
export const nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
13
|
+
|
|
14
|
+
export const nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { nodeQuery, nodesQuery } from "./query";
|
|
4
4
|
import { nodeAsString, nodesAsString } from "./string";
|
|
5
5
|
|
|
6
|
-
const subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement
|
|
7
|
-
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement
|
|
6
|
+
const subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement"),
|
|
7
|
+
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement");
|
|
8
8
|
|
|
9
9
|
export function subproofStringFromSubproofNode(subproofNode, fileContext) {
|
|
10
10
|
const tokens = fileContext.getTokens(),
|