occam-verify-cli 0.0.1087 → 0.0.1089
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/contained.js +3 -3
- package/lib/assertion/defined.js +4 -4
- package/lib/axiom.js +33 -81
- package/lib/conjecture.js +33 -85
- package/lib/context/file.js +43 -1
- package/lib/context/local.js +38 -2
- package/lib/declaration.js +7 -41
- package/lib/frame.js +49 -26
- package/lib/judgement.js +28 -16
- package/lib/lemma.js +34 -85
- package/lib/metaLemma.js +35 -102
- package/lib/metatheorem.js +34 -60
- package/lib/mixins/statement/qualified/unify.js +21 -63
- package/lib/mixins/statement/verify.js +2 -17
- package/lib/proofStep.js +6 -6
- package/lib/reference.js +14 -4
- package/lib/statement.js +8 -8
- package/lib/term.js +8 -8
- package/lib/theorem.js +34 -85
- package/lib/topLevelAssertion.js +62 -5
- package/lib/utilities/json.js +2 -2
- package/lib/variable.js +2 -2
- package/package.json +1 -1
- package/src/assertion/contained.js +4 -4
- package/src/assertion/defined.js +4 -4
- package/src/axiom.js +10 -63
- package/src/conjecture.js +10 -72
- package/src/context/file.js +42 -0
- package/src/context/local.js +13 -2
- package/src/declaration.js +7 -55
- package/src/frame.js +58 -31
- package/src/judgement.js +40 -20
- package/src/lemma.js +12 -72
- package/src/metaLemma.js +12 -81
- package/src/metatheorem.js +10 -78
- package/src/mixins/statement/qualified/unify.js +37 -104
- package/src/mixins/statement/verify.js +0 -27
- package/src/proofStep.js +7 -5
- package/src/reference.js +25 -4
- package/src/statement.js +8 -8
- package/src/term.js +8 -8
- package/src/theorem.js +10 -71
- package/src/topLevelAssertion.js +86 -4
- package/src/utilities/json.js +1 -1
- package/src/variable.js +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import StatementForMetavariableSubstitution from "../../../substitution/statementForMetavariable";
|
|
4
4
|
|
|
5
5
|
import { trim } from "../../../utilities/string";
|
|
6
|
-
import { metavariableNameFromMetavariableNode } from "../../../utilities/name";
|
|
7
6
|
|
|
8
7
|
function unifyAWithRule(qualifiedStatement, substitutions, localContext) {
|
|
9
8
|
let unifiedWithRule = false;
|
|
@@ -30,143 +29,77 @@ function unifyAWithRule(qualifiedStatement, substitutions, localContext) {
|
|
|
30
29
|
return unifiedWithRule;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
function
|
|
34
|
-
let
|
|
32
|
+
function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
33
|
+
let unifiedWithReference = false;
|
|
35
34
|
|
|
36
35
|
const reference = qualifiedStatement.getReference(),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (axiom !== null) {
|
|
40
|
-
const referenceString = reference.getString(),
|
|
41
|
-
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
42
|
-
|
|
43
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom...`);
|
|
36
|
+
metavariableNode = reference.getMetavariableNode(),
|
|
37
|
+
metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
|
|
44
38
|
|
|
39
|
+
if (metavariablePresent) {
|
|
45
40
|
const statement = qualifiedStatement.getStatement(),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
unifiedWithAxiom = statementUnified; ///
|
|
49
|
-
|
|
50
|
-
if (unifiedWithAxiom) {
|
|
51
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom.`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return unifiedWithAxiom;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function unifyAWithLemma(qualifiedStatement, substitutions, localContext) {
|
|
59
|
-
let unifiedWithLemma = false;
|
|
60
|
-
|
|
61
|
-
const reference = qualifiedStatement.getReference(),
|
|
62
|
-
lemma = localContext.findLemmaByReference(reference);
|
|
41
|
+
statementString = statement.getString(),
|
|
42
|
+
referenceString = reference.getString();
|
|
63
43
|
|
|
64
|
-
|
|
65
|
-
const referenceString = reference.getString(),
|
|
66
|
-
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
44
|
+
localContext.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
|
|
67
45
|
|
|
68
|
-
|
|
46
|
+
const metavariable = reference.getMetavariable(),
|
|
47
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
48
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
69
49
|
|
|
70
|
-
|
|
71
|
-
statementUnified = lemma.unifyStatement(statement, localContext);
|
|
50
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
72
51
|
|
|
73
|
-
|
|
52
|
+
unifiedWithReference = true;
|
|
74
53
|
|
|
75
|
-
if (
|
|
76
|
-
localContext.debug(`...unified the '${
|
|
54
|
+
if (unifiedWithReference) {
|
|
55
|
+
localContext.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
|
|
77
56
|
}
|
|
78
57
|
}
|
|
79
58
|
|
|
80
|
-
return
|
|
59
|
+
return unifiedWithReference;
|
|
81
60
|
}
|
|
82
61
|
|
|
83
|
-
function
|
|
84
|
-
let
|
|
62
|
+
function unifyAWithAxiomLemmaTheoremOrConjecture(qualifiedStatement, substitutions, localContext) {
|
|
63
|
+
let unifiedWithAxiomLemmaTheoremOrConjecture = false;
|
|
85
64
|
|
|
86
65
|
const reference = qualifiedStatement.getReference(),
|
|
87
|
-
|
|
66
|
+
axiom = localContext.findAxiomByReference(reference),
|
|
67
|
+
lemma = localContext.findLemmaByReference(reference),
|
|
68
|
+
theorem = localContext.findTheoremByReference(reference),
|
|
69
|
+
conjecture = localContext.findConjectureByReference(reference),
|
|
70
|
+
axiomLemmaTheoremConjecture = (axiom || lemma || theorem || conjecture);
|
|
88
71
|
|
|
89
|
-
if (
|
|
72
|
+
if (axiomLemmaTheoremConjecture !== null) {
|
|
90
73
|
const referenceString = reference.getString(),
|
|
91
74
|
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
92
75
|
|
|
93
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' theorem...`);
|
|
76
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture...`);
|
|
94
77
|
|
|
95
78
|
const statement = qualifiedStatement.getStatement(),
|
|
96
|
-
statementUnified =
|
|
97
|
-
|
|
98
|
-
unifiedWithTheorem = statementUnified; ///
|
|
99
|
-
|
|
100
|
-
if (unifiedWithTheorem) {
|
|
101
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' theorem.`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return unifiedWithTheorem;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function unifyAWithConjecture(qualifiedStatement, substitutions, localContext) {
|
|
109
|
-
let unifiedWithConjecture = false;
|
|
110
|
-
|
|
111
|
-
const reference = qualifiedStatement.getReference(),
|
|
112
|
-
conjecture = localContext.findConjectureByReference(reference);
|
|
113
|
-
|
|
114
|
-
if (conjecture !== null) {
|
|
115
|
-
const referenceString = reference.getString(),
|
|
116
|
-
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
79
|
+
statementUnified = axiomLemmaTheoremConjecture.unifyStatement(statement, localContext);
|
|
117
80
|
|
|
118
|
-
|
|
81
|
+
if (statementUnified) {
|
|
82
|
+
const metavariable = reference.getMetavariable(),
|
|
83
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
84
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
119
85
|
|
|
120
|
-
|
|
121
|
-
statementUnified = conjecture.unifyStatement(statement, localContext);
|
|
86
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
122
87
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (unifiedWithConjecture) {
|
|
126
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' conjecture.`);
|
|
88
|
+
unifiedWithAxiomLemmaTheoremOrConjecture = true;
|
|
127
89
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return unifiedWithConjecture;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
134
|
-
let unifiedWithReference = false;
|
|
135
|
-
|
|
136
|
-
const reference = qualifiedStatement.getReference(),
|
|
137
|
-
metavariableNode = reference.getMetavariableNode(),
|
|
138
|
-
metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
|
|
139
90
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
statementString = statement.getString(),
|
|
143
|
-
referenceString = reference.getString();
|
|
144
|
-
|
|
145
|
-
localContext.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
|
|
146
|
-
|
|
147
|
-
const metavariable = reference.getMetavariable(),
|
|
148
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
149
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
150
|
-
|
|
151
|
-
substitutions.addSubstitution(substitution, localContext);
|
|
152
|
-
|
|
153
|
-
unifiedWithReference = true;
|
|
154
|
-
|
|
155
|
-
if (unifiedWithReference) {
|
|
156
|
-
localContext.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
|
|
91
|
+
if (unifiedWithAxiomLemmaTheoremOrConjecture) {
|
|
92
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture.`);
|
|
157
93
|
}
|
|
158
94
|
}
|
|
159
95
|
|
|
160
|
-
return
|
|
96
|
+
return unifiedWithAxiomLemmaTheoremOrConjecture;
|
|
161
97
|
}
|
|
162
98
|
|
|
163
99
|
const unifyMixins = [
|
|
164
100
|
unifyAWithRule,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
unifyAWithTheorem,
|
|
168
|
-
unifyAWithConjecture,
|
|
169
|
-
unifyAWithReference
|
|
101
|
+
unifyAWithReference,
|
|
102
|
+
unifyAWithAxiomLemmaTheoremOrConjecture
|
|
170
103
|
];
|
|
171
104
|
|
|
172
105
|
export default unifyMixins;
|
|
@@ -10,7 +10,6 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
10
10
|
|
|
11
11
|
const equalityNodeQuery = nodeQuery("/statement/equality"),
|
|
12
12
|
judgementNodeQuery = nodeQuery("/statement/judgement"),
|
|
13
|
-
declarationNodeQuery = nodeQuery("/statement/declaration"),
|
|
14
13
|
metavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
15
14
|
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion"),
|
|
16
15
|
definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion"),
|
|
@@ -92,31 +91,6 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
|
92
91
|
return verifiedAsJudgement;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
96
|
-
let verifiedAsDeclaration = false;
|
|
97
|
-
|
|
98
|
-
const { Declaration } = shim,
|
|
99
|
-
statementNode = statement.getNode(),
|
|
100
|
-
declarationNode = declarationNodeQuery(statementNode),
|
|
101
|
-
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
102
|
-
|
|
103
|
-
if (declaration !== null) {
|
|
104
|
-
const statementString = statement.getString();
|
|
105
|
-
|
|
106
|
-
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
107
|
-
|
|
108
|
-
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
109
|
-
|
|
110
|
-
verifiedAsDeclaration = declarationVerified; ///
|
|
111
|
-
|
|
112
|
-
if (verifiedAsDeclaration) {
|
|
113
|
-
localContext.debug(`...verified the '${statementString}' statement as a declaration.`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return verifiedAsDeclaration;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
94
|
function verifyAsTypeAssertion(statement, assignments, stated, localContext) {
|
|
121
95
|
let verifiedAsTypeAssertion = false;
|
|
122
96
|
|
|
@@ -217,7 +191,6 @@ const verifyMixins = [
|
|
|
217
191
|
verifyAsMetavariable,
|
|
218
192
|
verifyAsEquality,
|
|
219
193
|
verifyAsJudgement,
|
|
220
|
-
verifyAsDeclaration,
|
|
221
194
|
verifyAsTypeAssertion,
|
|
222
195
|
verifyAsDefinedAssertion,
|
|
223
196
|
verifyAsSubproofAssertion,
|
package/src/proofStep.js
CHANGED
|
@@ -137,15 +137,17 @@ class ProofStep {
|
|
|
137
137
|
qualifiedStatementVerified = false,
|
|
138
138
|
unqualifiedStatementVerified = false;
|
|
139
139
|
|
|
140
|
-
if (
|
|
141
|
-
///
|
|
142
|
-
} else if (this.subproof !== null) {
|
|
140
|
+
if (this.subproof !== null) {
|
|
143
141
|
subproofVerified = this.subproof.verify(substitutions, localContext);
|
|
144
|
-
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (this.qualifiedStatement !== null) {
|
|
145
145
|
stated = true;
|
|
146
146
|
|
|
147
147
|
qualifiedStatementVerified = this.qualifiedStatement.verify(substitutions, assignments, stated, localContext);
|
|
148
|
-
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (this.unqualifiedStatement !== null) {
|
|
149
151
|
stated = false;
|
|
150
152
|
|
|
151
153
|
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
package/src/reference.js
CHANGED
|
@@ -6,6 +6,7 @@ import LocalContext from "./context/local";
|
|
|
6
6
|
import { nodeQuery } from "./utilities/query";
|
|
7
7
|
import { referenceMetaType } from "./metaType";
|
|
8
8
|
import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
|
|
9
|
+
import local from "./context/local";
|
|
9
10
|
|
|
10
11
|
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
11
12
|
|
|
@@ -29,16 +30,36 @@ export default class Reference {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
verify(localContext) {
|
|
32
|
-
let verified;
|
|
33
|
+
let verified = false;
|
|
33
34
|
|
|
34
35
|
const referenceString = this.getString(); ///
|
|
35
36
|
|
|
36
37
|
localContext.trace(`Verifying the '${referenceString}' reference...`);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (!verified) {
|
|
40
|
+
const metaType = referenceMetaType, ///
|
|
41
|
+
metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, localContext);
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
verified = metavariableVerifiedGivenMetaType; ///
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!verified) {
|
|
47
|
+
const reference = this, ///
|
|
48
|
+
metaLemmaPresent = localContext.isMetaLemmaPresentByReference(reference),
|
|
49
|
+
metatheoremPresent = localContext.isMetatheoremPresentByReference(reference);
|
|
50
|
+
|
|
51
|
+
verified = (metaLemmaPresent || metatheoremPresent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!verified) {
|
|
55
|
+
const reference = this, ///
|
|
56
|
+
axiomPresent = localContext.isAxiomPresentByReference(reference),
|
|
57
|
+
lemmaPresent = localContext.isLemmaPresentByReference(reference),
|
|
58
|
+
theoremPresent = localContext.isTheoremPresentByReference(reference),
|
|
59
|
+
conjecturePresent = localContext.isConjecturePresentByReference(reference);
|
|
60
|
+
|
|
61
|
+
verified = (axiomPresent || lemmaPresent || theoremPresent || conjecturePresent);
|
|
62
|
+
}
|
|
42
63
|
|
|
43
64
|
if (verified) {
|
|
44
65
|
localContext.debug(`...verified the '${referenceString}' reference.`);
|
package/src/statement.js
CHANGED
|
@@ -173,25 +173,25 @@ class Statement {
|
|
|
173
173
|
localContext.trace(`Verifying the '${statementString}' statement...`);
|
|
174
174
|
|
|
175
175
|
if (!verified) {
|
|
176
|
-
|
|
177
|
-
const
|
|
176
|
+
verified = verifyMixins.some((verifyMixin) => {
|
|
177
|
+
const verified = verifyMixin(statement, assignments, stated, localContext);
|
|
178
178
|
|
|
179
|
-
if (
|
|
179
|
+
if (verified) {
|
|
180
180
|
return true;
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
|
-
|
|
184
|
-
verified = unified; ///
|
|
185
183
|
}
|
|
186
184
|
|
|
187
185
|
if (!verified) {
|
|
188
|
-
|
|
189
|
-
const
|
|
186
|
+
const unified = unifyMixins.some((unifyMixin) => {
|
|
187
|
+
const unified = unifyMixin(statement, assignments, stated, localContext);
|
|
190
188
|
|
|
191
|
-
if (
|
|
189
|
+
if (unified) {
|
|
192
190
|
return true;
|
|
193
191
|
}
|
|
194
192
|
});
|
|
193
|
+
|
|
194
|
+
verified = unified; ///
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
if (verified) {
|
package/src/term.js
CHANGED
|
@@ -138,25 +138,25 @@ class Term {
|
|
|
138
138
|
localContext.trace(`Verifying the '${termString}' term...`);
|
|
139
139
|
|
|
140
140
|
if (!verified) {
|
|
141
|
-
|
|
142
|
-
const
|
|
141
|
+
verified = verifyMixins.some((verifyMixin) => {
|
|
142
|
+
const verified = verifyMixin(term, localContext, verifyAhead);
|
|
143
143
|
|
|
144
|
-
if (
|
|
144
|
+
if (verified) {
|
|
145
145
|
return true;
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
|
-
|
|
149
|
-
verified = unified; ///
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
if (!verified) {
|
|
153
|
-
|
|
154
|
-
const
|
|
151
|
+
const unified = unifyMixins.some((unifyMixin) => { ///
|
|
152
|
+
const unified = unifyMixin(term, localContext, verifyAhead);
|
|
155
153
|
|
|
156
|
-
if (
|
|
154
|
+
if (unified) {
|
|
157
155
|
return true;
|
|
158
156
|
}
|
|
159
157
|
});
|
|
158
|
+
|
|
159
|
+
verified = unified; ///
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
if (verified) {
|
package/src/theorem.js
CHANGED
|
@@ -1,64 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import LocalContext from "./context/local";
|
|
5
4
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
6
5
|
|
|
7
|
-
import { stringFromLabels } from "./topLevelAssertion";
|
|
8
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
9
|
-
|
|
10
|
-
const proofNodeQuery = nodeQuery("/theorem/proof"),
|
|
11
|
-
labelNodesQuery = nodesQuery("/theorem/label"),
|
|
12
|
-
consequentNodeQuery = nodeQuery("/theorem/consequent"),
|
|
13
|
-
suppositionNodesQuery = nodesQuery("/theorem/supposition");
|
|
14
|
-
|
|
15
6
|
class Theorem extends TopLevelAssertion {
|
|
16
7
|
verify() {
|
|
17
|
-
let verified
|
|
18
|
-
|
|
19
|
-
const theoremString = this.string; ///
|
|
20
|
-
|
|
21
|
-
this.fileContext.trace(`Verifying the '${theoremString}' theorem...`);
|
|
22
|
-
|
|
23
|
-
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
24
|
-
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
25
|
-
|
|
26
|
-
if (labelVVerifiedWhenDeclared) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (labelsVerifiedWhenDeclared) {
|
|
32
|
-
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
33
|
-
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
34
|
-
const suppositionVerified = supposition.verify(localContext);
|
|
35
|
-
|
|
36
|
-
if (suppositionVerified) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
8
|
+
let verified;
|
|
40
9
|
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
const fileContext = this.getFileContext(),
|
|
11
|
+
theoremString = this.string; ///
|
|
43
12
|
|
|
44
|
-
|
|
45
|
-
const { Substitutions } = shim,
|
|
46
|
-
substitutions = Substitutions.fromNothing(),
|
|
47
|
-
proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
|
|
13
|
+
fileContext.trace(`Verifying the '${theoremString}' theorem...`);
|
|
48
14
|
|
|
49
|
-
|
|
50
|
-
const theorem = this; ///
|
|
15
|
+
verified = super.verify();
|
|
51
16
|
|
|
52
|
-
|
|
17
|
+
if (verified) {
|
|
18
|
+
const theorem = this; ///
|
|
53
19
|
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
20
|
+
fileContext.addTheorem(theorem);
|
|
59
21
|
|
|
60
|
-
|
|
61
|
-
this.fileContext.debug(`...verified the '${theoremString}' theorem.`);
|
|
22
|
+
fileContext.debug(`...verified the '${theoremString}' theorem.`);
|
|
62
23
|
}
|
|
63
24
|
|
|
64
25
|
return verified;
|
|
@@ -66,29 +27,7 @@ class Theorem extends TopLevelAssertion {
|
|
|
66
27
|
|
|
67
28
|
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
|
|
68
29
|
|
|
69
|
-
static fromTheoremNode(
|
|
70
|
-
const { Label, Proof, Consequent, Supposition } = shim,
|
|
71
|
-
proofNode = proofNodeQuery(theoremNode),
|
|
72
|
-
labelNodes = labelNodesQuery(theoremNode),
|
|
73
|
-
consequentNode = consequentNodeQuery(theoremNode),
|
|
74
|
-
suppositionNodes = suppositionNodesQuery(theoremNode),
|
|
75
|
-
labels = labelNodes.map((labelNode) => {
|
|
76
|
-
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
77
|
-
|
|
78
|
-
return label;
|
|
79
|
-
}),
|
|
80
|
-
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
81
|
-
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
82
|
-
|
|
83
|
-
return supposition;
|
|
84
|
-
}),
|
|
85
|
-
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
86
|
-
string = stringFromLabels(labels),
|
|
87
|
-
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
88
|
-
theorem = new Theorem(fileContext, string, labels, suppositions, consequent, proof);
|
|
89
|
-
|
|
90
|
-
return theorem;
|
|
91
|
-
}
|
|
30
|
+
static fromTheoremNode(metaLemmaNode, fileContext) { return TopLevelAssertion.fromNode(Theorem, metaLemmaNode, fileContext); }
|
|
92
31
|
}
|
|
93
32
|
|
|
94
33
|
Object.assign(shim, {
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -5,20 +5,30 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
import shim from "./shim";
|
|
6
6
|
|
|
7
7
|
import { EMPTY_STRING } from "./constants";
|
|
8
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
9
|
import { labelsFromJSON,
|
|
9
10
|
labelsToLabelsJSON,
|
|
10
11
|
consequentFromJSON,
|
|
11
12
|
suppositionsFromJSON,
|
|
13
|
+
substitutionsFromJSON,
|
|
12
14
|
consequentToConsequentJSON,
|
|
13
|
-
suppositionsToSuppositionsJSON
|
|
15
|
+
suppositionsToSuppositionsJSON,
|
|
16
|
+
substitutionsToSubstitutionsJSON } from "./utilities/json";
|
|
17
|
+
import LocalContext from "./context/local";
|
|
14
18
|
|
|
15
19
|
const { extract, reverse, backwardsEvery } = arrayUtilities;
|
|
16
20
|
|
|
21
|
+
const proofNodeQuery = nodeQuery("/*/proof"),
|
|
22
|
+
labelNodesQuery = nodesQuery("/*/label"),
|
|
23
|
+
consequentNodeQuery = nodeQuery("/*/consequent"),
|
|
24
|
+
suppositionNodesQuery = nodesQuery("/*/supposition");
|
|
25
|
+
|
|
17
26
|
export default class TopLevelAssertion {
|
|
18
|
-
constructor(fileContext, string, labels, suppositions, consequent, proof) {
|
|
27
|
+
constructor(fileContext, string, labels, substitutions, suppositions, consequent, proof) {
|
|
19
28
|
this.fileContext = fileContext;
|
|
20
29
|
this.string = string;
|
|
21
30
|
this.labels = labels;
|
|
31
|
+
this.substitutions = substitutions;
|
|
22
32
|
this.suppositions = suppositions;
|
|
23
33
|
this.consequent = consequent;
|
|
24
34
|
this.proof = proof;
|
|
@@ -36,6 +46,10 @@ export default class TopLevelAssertion {
|
|
|
36
46
|
return this.labels;
|
|
37
47
|
}
|
|
38
48
|
|
|
49
|
+
getSubstitutions() {
|
|
50
|
+
return this.substitutions;
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
getSuppositions() {
|
|
40
54
|
return this.suppositions;
|
|
41
55
|
}
|
|
@@ -148,17 +162,59 @@ export default class TopLevelAssertion {
|
|
|
148
162
|
return suppositionUnified;
|
|
149
163
|
}
|
|
150
164
|
|
|
165
|
+
verify() {
|
|
166
|
+
let verified = false;
|
|
167
|
+
|
|
168
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
169
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
170
|
+
|
|
171
|
+
if (labelVVerifiedWhenDeclared) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (labelsVerifiedWhenDeclared) {
|
|
177
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
178
|
+
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
179
|
+
const suppositionVerified = supposition.verify(localContext);
|
|
180
|
+
|
|
181
|
+
if (suppositionVerified) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
if (suppositionsVerified) {
|
|
187
|
+
const consequentVerified = this.consequent.verify(localContext);
|
|
188
|
+
|
|
189
|
+
if (consequentVerified) {
|
|
190
|
+
if (this.proof === null) {
|
|
191
|
+
verified = true;
|
|
192
|
+
} else {
|
|
193
|
+
const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
|
|
194
|
+
|
|
195
|
+
verified = proofVerified; ///
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return verified;
|
|
202
|
+
}
|
|
203
|
+
|
|
151
204
|
toJSON() {
|
|
152
205
|
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
153
206
|
consequentJSON = consequentToConsequentJSON(this.consequent),
|
|
154
207
|
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
208
|
+
substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
|
|
155
209
|
labels = labelsJSON, ///
|
|
156
210
|
consequent = consequentJSON, ///
|
|
157
211
|
suppositions = suppositionsJSON, ///
|
|
212
|
+
substitutions = substitutionsJSON, ///
|
|
158
213
|
json = {
|
|
159
214
|
labels,
|
|
160
215
|
consequent,
|
|
161
|
-
suppositions
|
|
216
|
+
suppositions,
|
|
217
|
+
substitutions
|
|
162
218
|
};
|
|
163
219
|
|
|
164
220
|
return json;
|
|
@@ -168,12 +224,38 @@ export default class TopLevelAssertion {
|
|
|
168
224
|
const labels = labelsFromJSON(json, fileContext),
|
|
169
225
|
consequent = consequentFromJSON(json, fileContext),
|
|
170
226
|
suppositions = suppositionsFromJSON(json, fileContext),
|
|
227
|
+
substitutions = substitutionsFromJSON(json, fileContext),
|
|
171
228
|
string = stringFromLabels(labels),
|
|
172
229
|
proof = null,
|
|
173
|
-
topLevelAssertion = new Class(fileContext, string, labels, suppositions, consequent, proof);
|
|
230
|
+
topLevelAssertion = new Class(fileContext, string, labels, substitutions, suppositions, consequent, proof);
|
|
174
231
|
|
|
175
232
|
return topLevelAssertion;
|
|
176
233
|
}
|
|
234
|
+
|
|
235
|
+
static fromNode(Class, node, fileContext) {
|
|
236
|
+
const { Label, Proof, Consequent, Supposition, Substitutions } = shim,
|
|
237
|
+
proofNode = proofNodeQuery(node),
|
|
238
|
+
labelNodes = labelNodesQuery(node),
|
|
239
|
+
consequentNode = consequentNodeQuery(node),
|
|
240
|
+
suppositionNodes = suppositionNodesQuery(node),
|
|
241
|
+
labels = labelNodes.map((labelNode) => {
|
|
242
|
+
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
243
|
+
|
|
244
|
+
return label;
|
|
245
|
+
}),
|
|
246
|
+
substitutions = Substitutions.fromNothing(),
|
|
247
|
+
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
248
|
+
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
249
|
+
|
|
250
|
+
return supposition;
|
|
251
|
+
}),
|
|
252
|
+
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
253
|
+
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
254
|
+
string = stringFromLabels(labels),
|
|
255
|
+
metaLemma = new Class(fileContext, string, labels, substitutions, suppositions, consequent, proof);
|
|
256
|
+
|
|
257
|
+
return metaLemma;
|
|
258
|
+
}
|
|
177
259
|
}
|
|
178
260
|
|
|
179
261
|
export function stringFromLabels(labels) {
|
package/src/utilities/json.js
CHANGED
|
@@ -302,7 +302,7 @@ export function suppositionsFromJSON(json, fileContext) {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
export function substitutionsFromJSON(json, fileContext) {
|
|
305
|
-
let { substitutions } = json;
|
|
305
|
+
let { substitutions = [] } = json; ///
|
|
306
306
|
|
|
307
307
|
const { Substitution } = shim,
|
|
308
308
|
substitutionsJSON = substitutions; ///
|
package/src/variable.js
CHANGED
|
@@ -83,7 +83,7 @@ class Variable {
|
|
|
83
83
|
if (verified) {
|
|
84
84
|
const typeName = this.type.getName();
|
|
85
85
|
|
|
86
|
-
localContext.debug(`...verified the '${variableString}
|
|
86
|
+
localContext.debug(`...verified the '${variableString}:${typeName}' variable.`);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return verified;
|