occam-verify-cli 0.0.1111 → 0.0.1112
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/combinator/bracketed.js +15 -65
- package/lib/combinator.js +4 -8
- package/lib/constructor/bracketed.js +24 -101
- package/lib/constructor.js +4 -8
- package/lib/context/file.js +41 -12
- package/lib/context/local.js +45 -25
- package/lib/context/release.js +2 -2
- package/lib/dom/assertion/contained.js +246 -0
- package/lib/dom/assertion/defined.js +266 -0
- package/lib/dom/assertion/subproof.js +210 -0
- package/lib/dom/assertion/type.js +240 -0
- package/lib/{axiom.js → dom/axiom.js} +18 -8
- package/lib/dom/conclusion.js +171 -0
- package/lib/{conjecture.js → dom/conjecture.js} +18 -8
- package/lib/dom/consequent.js +171 -0
- package/lib/dom/declaration/combinator.js +105 -0
- package/lib/dom/declaration/constructor.js +140 -0
- package/lib/dom/declaration/metavariable.js +154 -0
- package/lib/dom/declaration/type.js +140 -0
- package/lib/dom/declaration/variable.js +155 -0
- package/lib/{declaration.js → dom/declaration.js} +62 -18
- package/lib/dom/derivation.js +137 -0
- package/lib/dom/equality.js +260 -0
- package/lib/dom/error.js +85 -0
- package/lib/dom/frame.js +372 -0
- package/lib/dom/judgement.js +198 -0
- package/lib/dom/label.js +190 -0
- package/lib/{lemma.js → dom/lemma.js} +19 -9
- package/lib/{metaLemma.js → dom/metaLemma.js} +19 -9
- package/lib/dom/metaType.js +261 -0
- package/lib/dom/metatheorem.js +273 -0
- package/lib/dom/metavariable.js +463 -0
- package/lib/dom/premise.js +221 -0
- package/lib/dom/proof.js +154 -0
- package/lib/dom/proofStep.js +239 -0
- package/lib/dom/reference.js +218 -0
- package/lib/dom/rule.js +311 -0
- package/lib/dom/statement.js +379 -0
- package/lib/dom/subDerivation.js +137 -0
- package/lib/dom/subproof.js +211 -0
- package/lib/dom/supposition.js +221 -0
- package/lib/dom/term.js +354 -0
- package/lib/{theorem.js → dom/theorem.js} +18 -8
- package/lib/dom/topLevelAssertion.js +306 -0
- package/lib/dom/type.js +327 -0
- package/lib/dom/variable.js +328 -0
- package/lib/dom.js +27 -0
- package/lib/equivalences.js +307 -0
- package/lib/index.js +40 -35
- package/lib/mixins/proofStep/unify.js +86 -0
- package/lib/mixins/statement/verify.js +27 -2
- package/lib/mixins/term/verify.js +24 -4
- package/lib/substitution/frame.js +3 -3
- package/lib/substitution/statement.js +17 -16
- package/lib/substitution/term.js +10 -7
- package/lib/substitution.js +4 -31
- package/lib/substitutions.js +24 -56
- package/lib/unifier/equality.js +2 -3
- package/lib/unifier/label.js +3 -3
- package/lib/unifier/metaLevel.js +9 -8
- package/lib/unifier/metavariable.js +3 -3
- package/lib/unifier/statementWithCombinator.js +5 -5
- package/lib/unifier/termWithConstructor.js +3 -3
- package/lib/utilities/json.js +26 -40
- package/lib/utilities/string.js +6 -8
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/substitutions.js +7 -6
- package/lib/utilities/verification.js +22 -14
- package/lib/verifier/combinator.js +4 -4
- package/lib/verifier/constructor.js +3 -3
- package/lib/verifier/topLevel.js +15 -21
- package/package.json +1 -1
- package/src/combinator/bracketed.js +11 -4
- package/src/combinator.js +3 -10
- package/src/constructor/bracketed.js +17 -5
- package/src/constructor.js +3 -9
- package/src/context/file.js +42 -11
- package/src/context/local.js +26 -34
- package/src/context/release.js +1 -1
- package/src/{assertion → dom/assertion}/contained.js +10 -8
- package/src/{assertion → dom/assertion}/defined.js +14 -11
- package/src/{assertion → dom/assertion}/subproof.js +11 -62
- package/src/{assertion → dom/assertion}/type.js +11 -8
- package/src/{axiom.js → dom/axiom.js} +6 -9
- package/src/dom/conclusion.js +95 -0
- package/src/{conjecture.js → dom/conjecture.js} +5 -8
- package/src/dom/consequent.js +95 -0
- package/src/{declaration → dom/declaration}/combinator.js +8 -5
- package/src/{declaration → dom/declaration}/constructor.js +8 -4
- package/src/{declaration → dom/declaration}/metavariable.js +8 -5
- package/src/{declaration → dom/declaration}/type.js +8 -4
- package/src/{declaration → dom/declaration}/variable.js +9 -6
- package/src/{declaration.js → dom/declaration.js} +11 -16
- package/src/{derivation.js → dom/derivation.js} +9 -12
- package/src/{equality.js → dom/equality.js} +11 -14
- package/src/{error.js → dom/error.js} +6 -3
- package/src/{frame.js → dom/frame.js} +14 -23
- package/src/{judgement.js → dom/judgement.js} +8 -11
- package/src/{label.js → dom/label.js} +9 -16
- package/src/{lemma.js → dom/lemma.js} +5 -9
- package/src/{metaLemma.js → dom/metaLemma.js} +6 -9
- package/src/{metaType.js → dom/metaType.js} +7 -10
- package/src/{metatheorem.js → dom/metatheorem.js} +6 -10
- package/src/{metavariable.js → dom/metavariable.js} +79 -77
- package/src/dom/premise.js +173 -0
- package/src/{proof.js → dom/proof.js} +8 -11
- package/src/dom/proofStep.js +173 -0
- package/src/{reference.js → dom/reference.js} +48 -20
- package/src/{rule.js → dom/rule.js} +13 -17
- package/src/{statement.js → dom/statement.js} +142 -71
- package/src/{subDerivation.js → dom/subDerivation.js} +9 -12
- package/src/{subproof.js → dom/subproof.js} +14 -47
- package/src/dom/supposition.js +173 -0
- package/src/{term.js → dom/term.js} +24 -45
- package/src/{theorem.js → dom/theorem.js} +5 -8
- package/src/{topLevelAssertion.js → dom/topLevelAssertion.js} +12 -14
- package/src/{type.js → dom/type.js} +9 -12
- package/src/{variable.js → dom/variable.js} +20 -28
- package/src/dom.js +13 -0
- package/src/equivalences.js +278 -0
- package/src/index.js +39 -34
- package/src/mixins/proofStep/unify.js +115 -0
- package/src/mixins/statement/verify.js +33 -1
- package/src/mixins/term/verify.js +33 -3
- package/src/substitution/frame.js +2 -2
- package/src/substitution/statement.js +20 -18
- package/src/substitution/term.js +12 -5
- package/src/substitution.js +4 -29
- package/src/substitutions.js +35 -73
- package/src/unifier/equality.js +1 -2
- package/src/unifier/label.js +2 -2
- package/src/unifier/metaLevel.js +9 -7
- package/src/unifier/metavariable.js +2 -2
- package/src/unifier/statementWithCombinator.js +4 -4
- package/src/unifier/termWithConstructor.js +2 -2
- package/src/utilities/json.js +23 -42
- package/src/utilities/string.js +8 -6
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/substitutions.js +7 -5
- package/src/utilities/verification.js +29 -13
- package/src/verifier/combinator.js +3 -3
- package/src/verifier/constructor.js +3 -3
- package/src/verifier/topLevel.js +20 -21
- package/lib/assertion/contained.js +0 -232
- package/lib/assertion/defined.js +0 -211
- package/lib/assertion/subproof.js +0 -203
- package/lib/assertion/type.js +0 -185
- package/lib/conclusion.js +0 -130
- package/lib/consequent.js +0 -130
- package/lib/declaration/combinator.js +0 -90
- package/lib/declaration/constructor.js +0 -90
- package/lib/declaration/metavariable.js +0 -104
- package/lib/declaration/type.js +0 -90
- package/lib/declaration/variable.js +0 -105
- package/lib/derivation.js +0 -91
- package/lib/equality.js +0 -209
- package/lib/error.js +0 -70
- package/lib/frame.js +0 -331
- package/lib/judgement.js +0 -147
- package/lib/label.js +0 -141
- package/lib/metaType.js +0 -255
- package/lib/metatheorem.js +0 -263
- package/lib/metavariable.js +0 -399
- package/lib/mixins/statement/qualified/unify.js +0 -69
- package/lib/mixins/statement/unify.js +0 -42
- package/lib/mixins/statement/unifyIndependenntly.js +0 -46
- package/lib/mixins/term/unify.js +0 -40
- package/lib/premise.js +0 -184
- package/lib/proof.js +0 -103
- package/lib/proofStep.js +0 -179
- package/lib/reference.js +0 -145
- package/lib/rule.js +0 -259
- package/lib/shim.js +0 -14
- package/lib/statement/qualified.js +0 -152
- package/lib/statement/unqualified.js +0 -175
- package/lib/statement.js +0 -270
- package/lib/subDerivation.js +0 -91
- package/lib/subproof.js +0 -181
- package/lib/supposition.js +0 -184
- package/lib/term.js +0 -318
- package/lib/topLevelAssertion.js +0 -305
- package/lib/type.js +0 -321
- package/lib/utilities/equivalences.js +0 -178
- package/lib/variable.js +0 -281
- package/src/conclusion.js +0 -96
- package/src/consequent.js +0 -96
- package/src/mixins/statement/qualified/unify.js +0 -103
- package/src/mixins/statement/unify.js +0 -41
- package/src/mixins/statement/unifyIndependenntly.js +0 -58
- package/src/mixins/term/unify.js +0 -36
- package/src/premise.js +0 -183
- package/src/proofStep.js +0 -181
- package/src/shim.js +0 -5
- package/src/statement/qualified.js +0 -133
- package/src/statement/unqualified.js +0 -166
- package/src/supposition.js +0 -183
- package/src/utilities/equivalences.js +0 -183
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import dom from "../dom";
|
|
6
|
+
import verifyMixins from "../mixins/statement/verify";
|
|
7
|
+
import combinatorVerifier from "../verifier/combinator";
|
|
8
|
+
import StatementNodeAndTokens from "../nodeAndTokens/statement";
|
|
9
|
+
|
|
10
|
+
import { domAssigned } from "../dom";
|
|
11
|
+
import { unifyStatement } from "../utilities/unification";
|
|
12
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
13
|
+
import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
14
|
+
import { definedAssertionFromStatement, subproofAssertionFromStatement, containedAssertionFromStatement } from "../utilities/verification";
|
|
15
|
+
|
|
16
|
+
const { match, backwardsSome } = arrayUtilities;
|
|
17
|
+
|
|
18
|
+
const statementNodeQuery = nodeQuery("/*/statement"),
|
|
15
19
|
statementTermNodesQuery = nodesQuery("/statement//term"),
|
|
16
20
|
statementFrameNodesQuery = nodesQuery("/statement//frame");
|
|
17
21
|
|
|
18
|
-
class Statement {
|
|
22
|
+
export default domAssigned(class Statement {
|
|
19
23
|
constructor(string, node, tokens) {
|
|
20
24
|
this.string = string;
|
|
21
25
|
this.node = node;
|
|
@@ -35,13 +39,8 @@ class Statement {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
isEqualTo(statement) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (statement !== null) {
|
|
41
|
-
const statementString = statement.getString();
|
|
42
|
-
|
|
43
|
-
equalTo = (statementString === this.string);
|
|
44
|
-
}
|
|
42
|
+
const statementString = statement.getString(),
|
|
43
|
+
equalTo = (statementString === this.string);
|
|
45
44
|
|
|
46
45
|
return equalTo;
|
|
47
46
|
}
|
|
@@ -106,27 +105,38 @@ class Statement {
|
|
|
106
105
|
return statementNodeMatches;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
let
|
|
108
|
+
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
109
|
+
let subproofUnified = false;
|
|
111
110
|
|
|
112
|
-
const
|
|
111
|
+
const context = specificContext, ///
|
|
112
|
+
statement = this, ///
|
|
113
|
+
subproofAssertion = subproofAssertionFromStatement(statement, context);
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
if (subproofAssertion !== null) {
|
|
116
|
+
const subproofString = subproof.getString(),
|
|
117
|
+
subproofAssertionString = subproofAssertion.getString();
|
|
115
118
|
|
|
116
|
-
|
|
117
|
-
const statement = this, ///
|
|
118
|
-
unifiedIndependently = resolveMixin(statement, substitutions, generalContext, specificContext);
|
|
119
|
+
specificContext.trace(`Unifying the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion...`);
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const subproofStatements = subproof.getStatements(),
|
|
122
|
+
subproofAssertionStatements = subproofAssertion.getStatements();
|
|
123
|
+
|
|
124
|
+
subproofUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
|
|
125
|
+
const generalStatement = subproofAssertionStatement, ///
|
|
126
|
+
specificStatement = subproofStatement, ///
|
|
127
|
+
statementUnified = unifyStatement(generalStatement, specificStatement, substitutions, generalContext, specificContext);
|
|
128
|
+
|
|
129
|
+
if (statementUnified) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
if (subproofUnified) {
|
|
135
|
+
specificContext.debug(`...unified the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion.`);
|
|
136
|
+
}
|
|
127
137
|
}
|
|
128
138
|
|
|
129
|
-
return
|
|
139
|
+
return subproofUnified;
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
@@ -148,41 +158,67 @@ class Statement {
|
|
|
148
158
|
return statementUnified;
|
|
149
159
|
}
|
|
150
160
|
|
|
151
|
-
|
|
152
|
-
let
|
|
161
|
+
unifyIndependently(substitutions, generalContext, specificContext) {
|
|
162
|
+
let unifiedIndependently = false;
|
|
153
163
|
|
|
154
|
-
const
|
|
164
|
+
const context = specificContext, ///
|
|
165
|
+
statement = this; ///
|
|
155
166
|
|
|
156
|
-
|
|
167
|
+
const definedAssertion = definedAssertionFromStatement(statement, context),
|
|
168
|
+
containedAssertion = containedAssertionFromStatement(statement, context);
|
|
157
169
|
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
const statement = this, ///
|
|
161
|
-
verified = verifyMixin(statement, assignments, stated, context);
|
|
170
|
+
if ((definedAssertion !== null) || (containedAssertion !== null)) {
|
|
171
|
+
const statementString = this.string;
|
|
162
172
|
|
|
163
|
-
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
173
|
+
specificContext.trace(`Unifying the '${statementString}' statement independently...`);
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const statement = this, ///
|
|
172
|
-
unified = unifyMixin(statement, assignments, stated, context);
|
|
175
|
+
if (definedAssertion !== null) {
|
|
176
|
+
const definedAssertionUnifiedIndependently = definedAssertion.unifyIndependently(substitutions, context);
|
|
173
177
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
+
unifiedIndependently = definedAssertionUnifiedIndependently; ///
|
|
179
|
+
}
|
|
178
180
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
if (containedAssertion !== null) {
|
|
182
|
+
const containedAssertionUnifiedIndependently = containedAssertion.unifyIndependently(substitutions, context);
|
|
181
183
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
unifiedIndependently = containedAssertionUnifiedIndependently; ///
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (unifiedIndependently) {
|
|
188
|
+
specificContext.debug(`...unified the '${statementString}' statement independently.`);
|
|
189
|
+
}
|
|
184
190
|
}
|
|
185
191
|
|
|
192
|
+
return unifiedIndependently;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
unifyWithProofSteps(proofSteps, context) {
|
|
196
|
+
let unifiedWithProofSteps;
|
|
197
|
+
|
|
198
|
+
unifiedWithProofSteps = backwardsSome(proofSteps, (proofStep) => {
|
|
199
|
+
const statement = this, ///
|
|
200
|
+
statementUnified =proofStep.unifyStatement(statement, context);
|
|
201
|
+
|
|
202
|
+
if (statementUnified) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return unifiedWithProofSteps;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
verify(assignments, stated, context) {
|
|
211
|
+
let verified;
|
|
212
|
+
|
|
213
|
+
verified = verifyMixins.some((verifyMixin) => {
|
|
214
|
+
const statement = this, ///
|
|
215
|
+
verified = verifyMixin(statement, assignments, stated, context);
|
|
216
|
+
|
|
217
|
+
if (verified) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
186
222
|
return verified;
|
|
187
223
|
}
|
|
188
224
|
|
|
@@ -235,6 +271,8 @@ class Statement {
|
|
|
235
271
|
return json;
|
|
236
272
|
}
|
|
237
273
|
|
|
274
|
+
static name = "Statement";
|
|
275
|
+
|
|
238
276
|
static fromJSON(json, fileContext) {
|
|
239
277
|
const { string } = json,
|
|
240
278
|
context = fileContext, ///
|
|
@@ -246,6 +284,20 @@ class Statement {
|
|
|
246
284
|
return statement;
|
|
247
285
|
}
|
|
248
286
|
|
|
287
|
+
static fromPremiseNode(premiseNode, fileContext) {
|
|
288
|
+
const node = premiseNode, ///
|
|
289
|
+
statement = statementFromNode(node, fileContext);
|
|
290
|
+
|
|
291
|
+
return statement;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static fromProofStepNode(proofStepNode, fileContext) {
|
|
295
|
+
const node = proofStepNode, ///
|
|
296
|
+
statement = statementFromNode(node, fileContext);
|
|
297
|
+
|
|
298
|
+
return statement;
|
|
299
|
+
}
|
|
300
|
+
|
|
249
301
|
static fromStatementNode(statementNode, context) {
|
|
250
302
|
let statement = null;
|
|
251
303
|
|
|
@@ -260,12 +312,23 @@ class Statement {
|
|
|
260
312
|
return statement;
|
|
261
313
|
}
|
|
262
314
|
|
|
263
|
-
static
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
315
|
+
static fromConclusionNode(conclusionNode, fileContext) {
|
|
316
|
+
const node = conclusionNode, ///
|
|
317
|
+
statement = statementFromNode(node, fileContext);
|
|
318
|
+
|
|
319
|
+
return statement;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
static fromConsequentNode(consequentNode, fileContext) {
|
|
323
|
+
const node = consequentNode, ///
|
|
324
|
+
statement = statementFromNode(node, fileContext);
|
|
325
|
+
|
|
326
|
+
return statement;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
330
|
+
const node = suppositionNode, ///
|
|
331
|
+
statement = statementFromNode(node, fileContext);
|
|
269
332
|
|
|
270
333
|
return statement;
|
|
271
334
|
}
|
|
@@ -279,13 +342,21 @@ class Statement {
|
|
|
279
342
|
|
|
280
343
|
return statement;
|
|
281
344
|
}
|
|
282
|
-
}
|
|
345
|
+
});
|
|
283
346
|
|
|
284
|
-
|
|
347
|
+
function statementFromNode(node, fileContext) {
|
|
348
|
+
let statement = null;
|
|
285
349
|
|
|
286
|
-
|
|
287
|
-
Statement
|
|
288
|
-
});
|
|
350
|
+
const statementNode = statementNodeQuery(node);
|
|
289
351
|
|
|
290
|
-
|
|
352
|
+
if (statementNode !== null) {
|
|
353
|
+
const { Statement } = dom,
|
|
354
|
+
node = statementNode, ///
|
|
355
|
+
tokens = fileContext.nodeAsTokens(node),
|
|
356
|
+
string = fileContext.tokensAsString(tokens);
|
|
357
|
+
|
|
358
|
+
statement = new Statement(string, node, tokens);
|
|
359
|
+
}
|
|
291
360
|
|
|
361
|
+
return statement;
|
|
362
|
+
}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import dom from "../dom";
|
|
6
6
|
|
|
7
|
-
import { nodesQuery } from "
|
|
7
|
+
import { nodesQuery } from "../utilities/query";
|
|
8
|
+
import { domAssigned } from "../dom";
|
|
8
9
|
|
|
9
10
|
const { last } = arrayUtilities;
|
|
10
11
|
|
|
11
12
|
const proofStepNodesQuery = nodesQuery("/subDerivation/proofStep|lastProofStep");
|
|
12
13
|
|
|
13
|
-
class SubDerivation {
|
|
14
|
+
export default domAssigned(class SubDerivation {
|
|
14
15
|
constructor(proofSteps) {
|
|
15
16
|
this.proofSteps = proofSteps;
|
|
16
17
|
}
|
|
@@ -29,9 +30,9 @@ class SubDerivation {
|
|
|
29
30
|
let verified;
|
|
30
31
|
|
|
31
32
|
verified = this.proofSteps.every((proofStep) => { ///
|
|
32
|
-
const
|
|
33
|
+
const proofStepVerifiedAndUnified = proofStep.verifyAndUnify(substitutions, context);
|
|
33
34
|
|
|
34
|
-
if (
|
|
35
|
+
if (proofStepVerifiedAndUnified) {
|
|
35
36
|
return true;
|
|
36
37
|
}
|
|
37
38
|
});
|
|
@@ -39,8 +40,10 @@ class SubDerivation {
|
|
|
39
40
|
return verified;
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
static name = "SubDerivation";
|
|
44
|
+
|
|
42
45
|
static fromSubDerivationNode(subDerivationNode, fileContext) {
|
|
43
|
-
const { ProofStep } =
|
|
46
|
+
const { ProofStep } = dom,
|
|
44
47
|
proofStepNodes = proofStepNodesQuery(subDerivationNode),
|
|
45
48
|
proofSteps = proofStepNodes.map((proofStepNode) => {
|
|
46
49
|
const proofStep = ProofStep.fromProofStepNode(proofStepNode, fileContext);
|
|
@@ -51,10 +54,4 @@ class SubDerivation {
|
|
|
51
54
|
|
|
52
55
|
return subDerivation;
|
|
53
56
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
Object.assign(shim, {
|
|
57
|
-
SubDerivation
|
|
58
57
|
});
|
|
59
|
-
|
|
60
|
-
export default SubDerivation;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
import LocalContext from "../context/local";
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
6
|
+
import { domAssigned } from "../dom";
|
|
7
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
8
|
+
import { subproofStringFromSubproofNode } from "../utilities/subproof";
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { subproofStringFromSubproofNode } from "./utilities/subproof";
|
|
11
|
-
|
|
12
|
-
const { match } = arrayUtilities;
|
|
13
|
-
|
|
14
|
-
const suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
10
|
+
const subproofNodeQuery = nodeQuery("/proofStep/subproof"),
|
|
11
|
+
suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
15
12
|
subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
|
|
16
13
|
|
|
17
|
-
class Subproof {
|
|
14
|
+
export default domAssigned(class Subproof {
|
|
18
15
|
constructor(string, suppositions, subDerivation) {
|
|
19
16
|
this.string = string;
|
|
20
17
|
this.suppositions = suppositions;
|
|
@@ -55,34 +52,6 @@ class Subproof {
|
|
|
55
52
|
return statements;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
unifySubproofAssertion(subproofAssertion, substitutions, generalContext, specificContext) {
|
|
59
|
-
let subproofAssertionUnified;
|
|
60
|
-
|
|
61
|
-
const subproofString = this.string,
|
|
62
|
-
subproofAssertionString = subproofAssertion.getString();
|
|
63
|
-
|
|
64
|
-
specificContext.trace(`Unifying the '${subproofAssertionString}' subproof assertion with the '${subproofString}' subproof...`);
|
|
65
|
-
|
|
66
|
-
const subproofStatements = this.getStatements(),
|
|
67
|
-
subproofAssertionStatements = subproofAssertion.getStatements();
|
|
68
|
-
|
|
69
|
-
subproofAssertionUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
|
|
70
|
-
const generalStatement = subproofAssertionStatement, ///
|
|
71
|
-
specificStatement = subproofStatement, ///
|
|
72
|
-
statementUnified = unifyStatement(generalStatement, specificStatement, substitutions, generalContext, specificContext);
|
|
73
|
-
|
|
74
|
-
if (statementUnified) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
if (subproofAssertionUnified) {
|
|
80
|
-
specificContext.trace(`...unified the '${subproofAssertionString}' subproof assertion with the '${subproofString}' subproof.`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return subproofAssertionUnified;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
55
|
verify(substitutions, context) {
|
|
87
56
|
let subproofVerified = false;
|
|
88
57
|
|
|
@@ -109,11 +78,15 @@ class Subproof {
|
|
|
109
78
|
return subproofVerified;
|
|
110
79
|
}
|
|
111
80
|
|
|
112
|
-
static
|
|
81
|
+
static name = "Subproof";
|
|
82
|
+
|
|
83
|
+
static fromProofStepNode(proofStepNode, fileContext) {
|
|
113
84
|
let subproof = null;
|
|
114
85
|
|
|
86
|
+
const subproofNode = subproofNodeQuery(proofStepNode);
|
|
87
|
+
|
|
115
88
|
if (subproofNode !== null) {
|
|
116
|
-
const { Supposition, SubDerivation } =
|
|
89
|
+
const { Supposition, SubDerivation } = dom,
|
|
117
90
|
subproofString = subproofStringFromSubproofNode(subproofNode, fileContext),
|
|
118
91
|
suppositionNodes = suppositionNodesQuery(subproofNode),
|
|
119
92
|
subDerivationNode = subDerivationNodeQuery(subproofNode),
|
|
@@ -130,10 +103,4 @@ class Subproof {
|
|
|
130
103
|
|
|
131
104
|
return subproof;
|
|
132
105
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
Object.assign(shim, {
|
|
136
|
-
Subproof
|
|
137
106
|
});
|
|
138
|
-
|
|
139
|
-
export default Subproof;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
|
|
5
|
+
import { domAssigned } from "../dom";
|
|
6
|
+
import { assignAssignments } from "../utilities/assignments";
|
|
7
|
+
import { subproofAssertionFromStatement } from "../utilities/verification";
|
|
8
|
+
import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
|
|
9
|
+
|
|
10
|
+
export default domAssigned(class Supposition {
|
|
11
|
+
constructor(string, statement) {
|
|
12
|
+
this.string = string;
|
|
13
|
+
this.statement = statement;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getString() {
|
|
17
|
+
return this.string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getStatement() {
|
|
21
|
+
return this.statement;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
unifyIndependently(substitutions, generalContext, specificContext) {
|
|
25
|
+
let unifiedIndependently;
|
|
26
|
+
|
|
27
|
+
const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
|
|
28
|
+
|
|
29
|
+
unifiedIndependently = statementResolvedIndependently; ///
|
|
30
|
+
|
|
31
|
+
return unifiedIndependently;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
unifyProofStep(proofStep, substitutions, generalContext, specificContext) {
|
|
35
|
+
let proofStepUnified = false;
|
|
36
|
+
|
|
37
|
+
const subproof = proofStep.getSubproof(),
|
|
38
|
+
statement = proofStep.getStatement();
|
|
39
|
+
|
|
40
|
+
substitutions.snapshot();
|
|
41
|
+
|
|
42
|
+
if (subproof !== null) {
|
|
43
|
+
const subproofUnified = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
44
|
+
|
|
45
|
+
proofStepUnified = subproofUnified; ///
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (statement !== null) {
|
|
49
|
+
const statementUnified = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
50
|
+
|
|
51
|
+
proofStepUnified = statementUnified; ///
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (proofStepUnified) {
|
|
55
|
+
substitutions.resolve(generalContext, specificContext);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const context = specificContext; ///
|
|
59
|
+
|
|
60
|
+
proofStepUnified ?
|
|
61
|
+
substitutions.continue() :
|
|
62
|
+
substitutions.rollback(context);
|
|
63
|
+
|
|
64
|
+
return proofStepUnified;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
68
|
+
let statementUnified;
|
|
69
|
+
|
|
70
|
+
const supposition = this, ///
|
|
71
|
+
suppositionString = supposition.getString(),
|
|
72
|
+
statementString = statement.getString();
|
|
73
|
+
|
|
74
|
+
specificContext.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
|
|
75
|
+
|
|
76
|
+
statementUnified = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
77
|
+
|
|
78
|
+
if (statementUnified) {
|
|
79
|
+
specificContext.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return statementUnified;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
86
|
+
let subproofUnified = false;
|
|
87
|
+
|
|
88
|
+
const supposition = this, ///
|
|
89
|
+
subproofString = subproof.getString(),
|
|
90
|
+
suppositionStatement = supposition.getStatement(),
|
|
91
|
+
suppositionStatementString = suppositionStatement.getString();
|
|
92
|
+
|
|
93
|
+
specificContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
94
|
+
|
|
95
|
+
const context = generalContext,
|
|
96
|
+
subproofAssertion = subproofAssertionFromStatement(this.statement, context);
|
|
97
|
+
|
|
98
|
+
if (subproofAssertion !== null) {
|
|
99
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (subproofUnified) {
|
|
103
|
+
specificContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return subproofUnified;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
verify(context) {
|
|
110
|
+
let verified = false;
|
|
111
|
+
|
|
112
|
+
const suppositionString = this.string; ///
|
|
113
|
+
|
|
114
|
+
if (this.statement !== null) {
|
|
115
|
+
context.trace(`Verifying the '${suppositionString}' supposition...`);
|
|
116
|
+
|
|
117
|
+
const stated = true,
|
|
118
|
+
assignments = [],
|
|
119
|
+
statementVerified = this.statement.verify(assignments, stated, context);
|
|
120
|
+
|
|
121
|
+
if (statementVerified) {
|
|
122
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
123
|
+
|
|
124
|
+
if (assignmentsAssigned) {
|
|
125
|
+
const { ProofStep } = dom,
|
|
126
|
+
proofStep = ProofStep.fromStatement(this.statement, context);
|
|
127
|
+
|
|
128
|
+
context.addProofStep(proofStep);
|
|
129
|
+
|
|
130
|
+
verified = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (verified) {
|
|
135
|
+
context.debug(`...verified the '${suppositionString}' supposition.`);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return verified;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
toJSON() {
|
|
145
|
+
const statementJSON = statementToStatementJSON(this.statement),
|
|
146
|
+
statement = statementJSON, ///
|
|
147
|
+
json = {
|
|
148
|
+
statement
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return json;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static name = "Supposition";
|
|
155
|
+
|
|
156
|
+
static fromJSON(json, fileContext) {
|
|
157
|
+
const statement = statementFromJSON(json, fileContext),
|
|
158
|
+
string = statement.getString(),
|
|
159
|
+
supposition = new Supposition(string, statement);
|
|
160
|
+
|
|
161
|
+
return supposition;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
165
|
+
const { Statement } = dom,
|
|
166
|
+
statement = Statement.fromSuppositionNode(suppositionNode, fileContext),
|
|
167
|
+
statementString = statement.getString(),
|
|
168
|
+
string = statementString, ///
|
|
169
|
+
supposition = new Supposition(string, statement);
|
|
170
|
+
|
|
171
|
+
return supposition
|
|
172
|
+
}
|
|
173
|
+
});
|