occam-verify-cli 1.0.230 → 1.0.234
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/assignment/variable.js +4 -2
- package/lib/context/file.js +5 -5
- package/lib/context/local.js +19 -14
- package/lib/dom/axiom.js +36 -27
- package/lib/dom/combinator.js +5 -5
- package/lib/dom/conclusion.js +5 -5
- package/lib/dom/conjecture.js +9 -9
- package/lib/dom/constructor.js +5 -5
- package/lib/dom/declaration/combinator.js +14 -14
- package/lib/dom/declaration/complexType.js +35 -35
- package/lib/dom/declaration/constructor.js +19 -19
- package/lib/dom/declaration/metavariable.js +22 -22
- package/lib/dom/declaration/simpleType.js +23 -23
- package/lib/dom/declaration/variable.js +20 -20
- package/lib/dom/declaration.js +4 -2
- package/lib/dom/deduction.js +5 -5
- package/lib/dom/derivation.js +5 -5
- package/lib/dom/error.js +9 -9
- package/lib/dom/hypothesis.js +184 -0
- package/lib/dom/label.js +18 -24
- package/lib/dom/lemma.js +7 -7
- package/lib/dom/metaLemma.js +9 -9
- package/lib/dom/metaType.js +4 -10
- package/lib/dom/metatheorem.js +9 -9
- package/lib/dom/metavariable.js +7 -8
- package/lib/dom/parameter.js +2 -2
- package/lib/dom/premise.js +5 -5
- package/lib/dom/procedureCall.js +3 -3
- package/lib/dom/proof.js +3 -3
- package/lib/dom/property.js +9 -9
- package/lib/dom/reference.js +23 -22
- package/lib/dom/rule.js +24 -24
- package/lib/dom/section.js +248 -0
- package/lib/dom/signature.js +5 -5
- package/lib/dom/statement.js +25 -20
- package/lib/dom/step.js +3 -3
- package/lib/dom/subDerivation.js +5 -5
- package/lib/dom/subproof.js +7 -7
- package/lib/dom/substitution/statement.js +3 -3
- package/lib/dom/supposition.js +5 -5
- package/lib/dom/term.js +5 -6
- package/lib/dom/theorem.js +9 -9
- package/lib/dom/topLevelAssertion.js +123 -31
- package/lib/dom/topLevelMetaAssertion.js +13 -13
- package/lib/dom/type.js +21 -21
- package/lib/dom/variable.js +9 -15
- package/lib/index.js +3 -1
- package/lib/mixins/step/unify.js +11 -11
- package/lib/mixins/term/verify.js +6 -6
- package/lib/node/hypothesis.js +123 -0
- package/lib/node/section.js +144 -0
- package/lib/nonTerminalNodeMap.js +5 -3
- package/lib/ruleNames.js +9 -1
- package/lib/utilities/context.js +1 -1
- package/lib/utilities/json.js +82 -59
- package/lib/utilities/releaseContext.js +3 -3
- package/lib/utilities/subproof.js +10 -10
- package/lib/verifier/combinator.js +9 -10
- package/lib/verifier/constructor.js +10 -11
- package/lib/verifier/topLevel.js +38 -31
- package/package.json +2 -2
- package/src/assignment/variable.js +6 -4
- package/src/context/file.js +3 -3
- package/src/context/local.js +6 -14
- package/src/dom/axiom.js +47 -42
- package/src/dom/combinator.js +4 -4
- package/src/dom/conclusion.js +5 -5
- package/src/dom/conjecture.js +8 -8
- package/src/dom/constructor.js +4 -4
- package/src/dom/declaration/combinator.js +14 -14
- package/src/dom/declaration/complexType.js +35 -35
- package/src/dom/declaration/constructor.js +20 -20
- package/src/dom/declaration/metavariable.js +22 -22
- package/src/dom/declaration/simpleType.js +22 -22
- package/src/dom/declaration/variable.js +21 -21
- package/src/dom/declaration.js +5 -3
- package/src/dom/deduction.js +5 -5
- package/src/dom/derivation.js +5 -5
- package/src/dom/error.js +8 -8
- package/src/dom/hypothesis.js +119 -0
- package/src/dom/label.js +17 -19
- package/src/dom/lemma.js +8 -8
- package/src/dom/metaLemma.js +8 -8
- package/src/dom/metaType.js +2 -6
- package/src/dom/metatheorem.js +8 -8
- package/src/dom/metavariable.js +9 -12
- package/src/dom/parameter.js +1 -1
- package/src/dom/premise.js +8 -8
- package/src/dom/procedureCall.js +3 -3
- package/src/dom/proof.js +2 -2
- package/src/dom/property.js +8 -8
- package/src/dom/reference.js +23 -27
- package/src/dom/rule.js +29 -29
- package/src/dom/section.js +197 -0
- package/src/dom/signature.js +4 -5
- package/src/dom/statement.js +24 -32
- package/src/dom/step.js +4 -4
- package/src/dom/subDerivation.js +5 -5
- package/src/dom/subproof.js +8 -8
- package/src/dom/substitution/statement.js +5 -5
- package/src/dom/supposition.js +7 -7
- package/src/dom/term.js +3 -8
- package/src/dom/theorem.js +7 -7
- package/src/dom/topLevelAssertion.js +113 -40
- package/src/dom/topLevelMetaAssertion.js +19 -19
- package/src/dom/type.js +22 -22
- package/src/dom/variable.js +8 -11
- package/src/index.js +2 -0
- package/src/mixins/step/unify.js +10 -10
- package/src/mixins/term/verify.js +4 -5
- package/src/node/hypothesis.js +23 -0
- package/src/node/section.js +44 -0
- package/src/nonTerminalNodeMap.js +7 -1
- package/src/ruleNames.js +2 -0
- package/src/utilities/context.js +2 -2
- package/src/utilities/json.js +86 -58
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/subproof.js +10 -10
- package/src/verifier/combinator.js +6 -11
- package/src/verifier/constructor.js +9 -12
- package/src/verifier/topLevel.js +42 -30
package/src/dom/statement.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import LocalContext from "../context/local";
|
|
6
5
|
import verifyMixins from "../mixins/statement/verify";
|
|
7
6
|
import StatementPartialContext from "../context/partial/statement";
|
|
8
7
|
|
|
@@ -250,10 +249,10 @@ export default domAssigned(class Statement {
|
|
|
250
249
|
|
|
251
250
|
static name = "Statement";
|
|
252
251
|
|
|
253
|
-
static fromJSON(json,
|
|
252
|
+
static fromJSON(json, context) {
|
|
254
253
|
const { string } = json,
|
|
255
|
-
lexer =
|
|
256
|
-
parser =
|
|
254
|
+
lexer = context.getLexer(),
|
|
255
|
+
parser = context.getParser(),
|
|
257
256
|
statementPartialContext = StatementPartialContext.fromStringLexerAndParser(string, lexer, parser),
|
|
258
257
|
node = statementPartialContext.getNode(),
|
|
259
258
|
tokens = statementPartialContext.getTokens(),
|
|
@@ -262,27 +261,24 @@ export default domAssigned(class Statement {
|
|
|
262
261
|
return statement;
|
|
263
262
|
}
|
|
264
263
|
|
|
265
|
-
static fromStepNode(stepNode,
|
|
264
|
+
static fromStepNode(stepNode, context) {
|
|
266
265
|
let statement = null;
|
|
267
266
|
|
|
268
267
|
const statementNode = stepNode.getStatementNode();
|
|
269
268
|
|
|
270
269
|
if (statementNode !== null) {
|
|
271
|
-
statement = statementFromStatementNode(statementNode,
|
|
270
|
+
statement = statementFromStatementNode(statementNode, context);
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
return statement;
|
|
275
274
|
}
|
|
276
275
|
|
|
277
|
-
static fromPremiseNode(premiseNode,
|
|
276
|
+
static fromPremiseNode(premiseNode, context) {
|
|
278
277
|
let statement = null;
|
|
279
278
|
|
|
280
279
|
const statementNode = premiseNode.getStatementNode();
|
|
281
280
|
|
|
282
281
|
if (statementNode !== null) {
|
|
283
|
-
const localContext = LocalContext.fromFileContext(fileContext),
|
|
284
|
-
context = localContext; ///
|
|
285
|
-
|
|
286
282
|
statement = statementFromStatementNode(statementNode, context);
|
|
287
283
|
}
|
|
288
284
|
|
|
@@ -295,84 +291,80 @@ export default domAssigned(class Statement {
|
|
|
295
291
|
return statement;
|
|
296
292
|
}
|
|
297
293
|
|
|
298
|
-
static fromDeductionNode(deductionNode,
|
|
294
|
+
static fromDeductionNode(deductionNode, context) {
|
|
299
295
|
let statement = null;
|
|
300
296
|
|
|
301
297
|
const statementNode = deductionNode.getStatementNode();
|
|
302
298
|
|
|
303
299
|
if (statementNode !== null) {
|
|
304
|
-
|
|
305
|
-
|
|
300
|
+
statement = statementFromStatementNode(statementNode, context);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return statement;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static fromHypothesisNode(hypothesisNode, context) {
|
|
307
|
+
let statement = null;
|
|
308
|
+
|
|
309
|
+
const statementNode = hypothesisNode.getStatementNode();
|
|
306
310
|
|
|
311
|
+
if (statementNode !== null) {
|
|
307
312
|
statement = statementFromStatementNode(statementNode, context);
|
|
308
313
|
}
|
|
309
314
|
|
|
310
315
|
return statement;
|
|
311
316
|
}
|
|
312
317
|
|
|
313
|
-
static fromConclusionNode(conclusionNode,
|
|
318
|
+
static fromConclusionNode(conclusionNode, context) {
|
|
314
319
|
let statement = null;
|
|
315
320
|
|
|
316
321
|
const statementNode = conclusionNode.getStatementNode();
|
|
317
322
|
|
|
318
323
|
if (statementNode !== null) {
|
|
319
|
-
const localContext = LocalContext.fromFileContext(fileContext),
|
|
320
|
-
context = localContext; ///
|
|
321
|
-
|
|
322
324
|
statement = statementFromStatementNode(statementNode, context);
|
|
323
325
|
}
|
|
324
326
|
|
|
325
327
|
return statement;
|
|
326
328
|
}
|
|
327
329
|
|
|
328
|
-
static fromSuppositionNode(suppositionNode,
|
|
330
|
+
static fromSuppositionNode(suppositionNode, context) {
|
|
329
331
|
let statement = null;
|
|
330
332
|
|
|
331
333
|
const statementNode = suppositionNode.getStatementNode();
|
|
332
334
|
|
|
333
335
|
if (statementNode !== null) {
|
|
334
|
-
const localContext = LocalContext.fromFileContext(fileContext),
|
|
335
|
-
context = localContext; ///
|
|
336
|
-
|
|
337
336
|
statement = statementFromStatementNode(statementNode, context);
|
|
338
337
|
}
|
|
339
338
|
|
|
340
339
|
return statement;
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
static fromDeclarationNode(declarationNode,
|
|
342
|
+
static fromDeclarationNode(declarationNode, context) {
|
|
344
343
|
let statementNode;
|
|
345
344
|
|
|
346
345
|
statementNode = declarationNode.getStatementNode(); ///
|
|
347
346
|
|
|
348
347
|
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
349
348
|
|
|
350
|
-
const
|
|
351
|
-
context = localContext, ///
|
|
352
|
-
statement = statementFromStatementNode(statementNode, context);
|
|
349
|
+
const statement = statementFromStatementNode(statementNode, context);
|
|
353
350
|
|
|
354
351
|
return statement;
|
|
355
352
|
}
|
|
356
353
|
|
|
357
|
-
static fromContainedAssertionNode(containedAssertionNode,
|
|
354
|
+
static fromContainedAssertionNode(containedAssertionNode, context) {
|
|
358
355
|
let statement = null;
|
|
359
356
|
|
|
360
357
|
const statementNode = containedAssertionNode.getStatementNode();
|
|
361
358
|
|
|
362
359
|
if (statementNode !== null) {
|
|
363
|
-
const localContext = LocalContext.fromFileContext(fileContext),
|
|
364
|
-
context = localContext; ///
|
|
365
|
-
|
|
366
360
|
statement = statementFromStatementNode(statementNode, context);
|
|
367
361
|
}
|
|
368
362
|
|
|
369
363
|
return statement;
|
|
370
364
|
}
|
|
371
365
|
|
|
372
|
-
static fromCombinatorDeclarationNode(combinatorDeclarationNode,
|
|
366
|
+
static fromCombinatorDeclarationNode(combinatorDeclarationNode, context) {
|
|
373
367
|
const statementNode = combinatorDeclarationNode.getStatementNode(),
|
|
374
|
-
localContext = LocalContext.fromFileContext(fileContext),
|
|
375
|
-
context = localContext, ///
|
|
376
368
|
statement = statementFromStatementNode(statementNode, context);
|
|
377
369
|
|
|
378
370
|
return statement;
|
package/src/dom/step.js
CHANGED
|
@@ -164,7 +164,7 @@ export default domAssigned(class Step {
|
|
|
164
164
|
return step;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
static fromStepOrSubproofNode(stepOrSubproofNode,
|
|
167
|
+
static fromStepOrSubproofNode(stepOrSubproofNode, context) {
|
|
168
168
|
let step = null;
|
|
169
169
|
|
|
170
170
|
const stepNode = stepOrSubproofNode.isStepNode();
|
|
@@ -173,9 +173,9 @@ export default domAssigned(class Step {
|
|
|
173
173
|
const { Statement, Reference } = dom,
|
|
174
174
|
stepNode = stepOrSubproofNode, ///
|
|
175
175
|
node = stepNode, ///
|
|
176
|
-
string =
|
|
177
|
-
statement = Statement.fromStepNode(stepNode,
|
|
178
|
-
reference = Reference.fromStepNode(stepNode,
|
|
176
|
+
string = context.nodeAsString(node),
|
|
177
|
+
statement = Statement.fromStepNode(stepNode, context),
|
|
178
|
+
reference = Reference.fromStepNode(stepNode, context);
|
|
179
179
|
|
|
180
180
|
step = new Step(string, statement, reference);
|
|
181
181
|
}
|
package/src/dom/subDerivation.js
CHANGED
|
@@ -52,20 +52,20 @@ export default domAssigned(class SubDerivation {
|
|
|
52
52
|
|
|
53
53
|
static name = "SubDerivation";
|
|
54
54
|
|
|
55
|
-
static fromSubDerivationNode(subDerivationNode,
|
|
56
|
-
const stepsOrSubproofs = stepOrSubproofFromSubDerivationNode(subDerivationNode,
|
|
55
|
+
static fromSubDerivationNode(subDerivationNode, context) {
|
|
56
|
+
const stepsOrSubproofs = stepOrSubproofFromSubDerivationNode(subDerivationNode, context),
|
|
57
57
|
subDerivation = new SubDerivation(stepsOrSubproofs);
|
|
58
58
|
|
|
59
59
|
return subDerivation;
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
function stepOrSubproofFromSubDerivationNode(subDerivationNode,
|
|
63
|
+
function stepOrSubproofFromSubDerivationNode(subDerivationNode, context) {
|
|
64
64
|
const { Step, Subproof } = dom,
|
|
65
65
|
stepOrSubproofNodes = subDerivationNode.getStepOrSubproofNodes(),
|
|
66
66
|
stepsOrSubproofs = stepOrSubproofNodes.map((stepOrSubproofNode) => {
|
|
67
|
-
const subproof = Subproof.fromStepOrSubproofNode(stepOrSubproofNode,
|
|
68
|
-
step = Step.fromStepOrSubproofNode(stepOrSubproofNode,
|
|
67
|
+
const subproof = Subproof.fromStepOrSubproofNode(stepOrSubproofNode, context),
|
|
68
|
+
step = Step.fromStepOrSubproofNode(stepOrSubproofNode, context),
|
|
69
69
|
stepOrSubproof = (step || subproof);
|
|
70
70
|
|
|
71
71
|
return stepOrSubproof;
|
package/src/dom/subproof.js
CHANGED
|
@@ -134,16 +134,16 @@ export default domAssigned(class Subproof {
|
|
|
134
134
|
|
|
135
135
|
static name = "Subproof";
|
|
136
136
|
|
|
137
|
-
static fromStepOrSubproofNode(sStepOrSubproofNode,
|
|
137
|
+
static fromStepOrSubproofNode(sStepOrSubproofNode, context) {
|
|
138
138
|
let subproof = null;
|
|
139
139
|
|
|
140
140
|
const subproofNode = sStepOrSubproofNode.isSubproofNode();
|
|
141
141
|
|
|
142
142
|
if (subproofNode) {
|
|
143
143
|
const subproofNode = sStepOrSubproofNode, ///
|
|
144
|
-
suppositions = suppositionsFromSubproofNode(subproofNode,
|
|
145
|
-
subDerivation = subDerivationFromSubproofNode(subproofNode,
|
|
146
|
-
subproofString = subproofStringFromSubproofNode(subproofNode,
|
|
144
|
+
suppositions = suppositionsFromSubproofNode(subproofNode, context),
|
|
145
|
+
subDerivation = subDerivationFromSubproofNode(subproofNode, context),
|
|
146
|
+
subproofString = subproofStringFromSubproofNode(subproofNode, context),
|
|
147
147
|
string = subproofString; ///
|
|
148
148
|
|
|
149
149
|
subproof = new Subproof(string, suppositions, subDerivation);
|
|
@@ -153,11 +153,11 @@ export default domAssigned(class Subproof {
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
function suppositionsFromSubproofNode(subproofNode,
|
|
156
|
+
function suppositionsFromSubproofNode(subproofNode, context) {
|
|
157
157
|
const { Supposition } = dom,
|
|
158
158
|
suppositionNodes = subproofNode.getSuppositionNodes(),
|
|
159
159
|
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
160
|
-
const supposition = Supposition.fromSuppositionNode(suppositionNode,
|
|
160
|
+
const supposition = Supposition.fromSuppositionNode(suppositionNode, context);
|
|
161
161
|
|
|
162
162
|
return supposition;
|
|
163
163
|
});
|
|
@@ -165,10 +165,10 @@ function suppositionsFromSubproofNode(subproofNode, fileContext) {
|
|
|
165
165
|
return suppositions;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
function subDerivationFromSubproofNode(subproofNode,
|
|
168
|
+
function subDerivationFromSubproofNode(subproofNode, context) {
|
|
169
169
|
const { SubDerivation } = dom,
|
|
170
170
|
subDerivationNode = subproofNode.getSubDerivationNode(),
|
|
171
|
-
subDerivation = SubDerivation.fromSubDerivationNode(subDerivationNode,
|
|
171
|
+
subDerivation = SubDerivation.fromSubDerivationNode(subDerivationNode, context);
|
|
172
172
|
|
|
173
173
|
return subDerivation;
|
|
174
174
|
}
|
|
@@ -171,16 +171,16 @@ export default domAssigned(class StatementSubstitution extends Substitution {
|
|
|
171
171
|
return json;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
static fromJSON(json,
|
|
174
|
+
static fromJSON(json, context) {
|
|
175
175
|
const { string } = json,
|
|
176
|
-
lexer =
|
|
177
|
-
parser =
|
|
176
|
+
lexer = context.getLexer(),
|
|
177
|
+
parser = context.getParser(),
|
|
178
178
|
statementSubstitutionPartialContext = StatementSubstitutionPartialContext.fromStringLexerAndParser(string, lexer, parser),
|
|
179
179
|
node = statementSubstitutionPartialContext.getNode(),
|
|
180
180
|
tokens = statementSubstitutionPartialContext.getTokens(),
|
|
181
181
|
resolved = true,
|
|
182
|
-
statement = statementFromJSON(json,
|
|
183
|
-
metavariable = metavariableFromJSON(json,
|
|
182
|
+
statement = statementFromJSON(json, context),
|
|
183
|
+
metavariable = metavariableFromJSON(json, context),
|
|
184
184
|
substitution = null, ///
|
|
185
185
|
statementSubstitution = new StatementSubstitution(string, node, tokens, resolved, statement, metavariable, substitution);
|
|
186
186
|
|
package/src/dom/supposition.js
CHANGED
|
@@ -220,9 +220,9 @@ export default domAssigned(class Supposition {
|
|
|
220
220
|
|
|
221
221
|
static name = "Supposition";
|
|
222
222
|
|
|
223
|
-
static fromJSON(json,
|
|
224
|
-
const statement = statementFromJSON(json,
|
|
225
|
-
procedureCall = procedureCallFromJSON(json,
|
|
223
|
+
static fromJSON(json, context) {
|
|
224
|
+
const statement = statementFromJSON(json, context),
|
|
225
|
+
procedureCall = procedureCallFromJSON(json, context);
|
|
226
226
|
|
|
227
227
|
let string;
|
|
228
228
|
|
|
@@ -239,12 +239,12 @@ export default domAssigned(class Supposition {
|
|
|
239
239
|
return supposition;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
static fromSuppositionNode(suppositionNode,
|
|
242
|
+
static fromSuppositionNode(suppositionNode, context) {
|
|
243
243
|
const { Statement, ProcedureCall } = dom,
|
|
244
244
|
node = suppositionNode, ///
|
|
245
|
-
string =
|
|
246
|
-
statement = Statement.fromSuppositionNode(suppositionNode,
|
|
247
|
-
procedureCall = ProcedureCall.fromSuppositionNode(suppositionNode,
|
|
245
|
+
string = context.nodeAsString(node),
|
|
246
|
+
statement = Statement.fromSuppositionNode(suppositionNode, context),
|
|
247
|
+
procedureCall = ProcedureCall.fromSuppositionNode(suppositionNode, context),
|
|
248
248
|
supposition = new Supposition(string, statement, procedureCall);
|
|
249
249
|
|
|
250
250
|
return supposition
|
package/src/dom/term.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
5
|
import dom from "../dom";
|
|
6
|
-
import LocalContext from "../context/local";
|
|
7
6
|
import verifyMixins from "../mixins/term/verify";
|
|
8
7
|
|
|
9
8
|
import { domAssigned } from "../dom";
|
|
@@ -188,14 +187,12 @@ export default domAssigned(class Term {
|
|
|
188
187
|
|
|
189
188
|
static name = "Term";
|
|
190
189
|
|
|
191
|
-
static fromJSON(json,
|
|
190
|
+
static fromJSON(json, context) {
|
|
192
191
|
const { string } = json,
|
|
193
|
-
localContext = LocalContext.fromFileContext(fileContext),
|
|
194
|
-
context = localContext, ///
|
|
195
192
|
termString = string, ///
|
|
196
193
|
termNode = termNodeFromTermString(termString, context),
|
|
197
194
|
node = termNode, ///
|
|
198
|
-
type = typeFromJSON(json,
|
|
195
|
+
type = typeFromJSON(json, context),
|
|
199
196
|
term = new Term(string, node, type);
|
|
200
197
|
|
|
201
198
|
return term;
|
|
@@ -265,11 +262,9 @@ export default domAssigned(class Term {
|
|
|
265
262
|
return term;
|
|
266
263
|
}
|
|
267
264
|
|
|
268
|
-
static fromConstructorDeclarationNode(constructorDeclarationNode,
|
|
265
|
+
static fromConstructorDeclarationNode(constructorDeclarationNode, context) {
|
|
269
266
|
const { Type } = dom,
|
|
270
267
|
termNode = constructorDeclarationNode.getTermNode(),
|
|
271
|
-
localContext = LocalContext.fromFileContext(fileContext),
|
|
272
|
-
context = localContext, ///
|
|
273
268
|
term = termFromTermNode(termNode, context),
|
|
274
269
|
type = Type.fromConstructorDeclarationNode(constructorDeclarationNode, context);
|
|
275
270
|
|
package/src/dom/theorem.js
CHANGED
|
@@ -8,19 +8,19 @@ export default domAssigned(class Theorem extends TopLevelAssertion {
|
|
|
8
8
|
verify() {
|
|
9
9
|
let verifies;
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const context = this.getContext(),
|
|
12
12
|
theoremString = this.string; ///
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
context.trace(`Verifying the '${theoremString}' theorem...`);
|
|
15
15
|
|
|
16
16
|
verifies = super.verify();
|
|
17
17
|
|
|
18
18
|
if (verifies) {
|
|
19
19
|
const theorem = this; ///
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
context.addTheorem(theorem);
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
context.debug(`...verified the '${theoremString}' theorem.`);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
return verifies;
|
|
@@ -28,11 +28,11 @@ export default domAssigned(class Theorem extends TopLevelAssertion {
|
|
|
28
28
|
|
|
29
29
|
static name = "Theorem";
|
|
30
30
|
|
|
31
|
-
static fromJSON(json,
|
|
31
|
+
static fromJSON(json, context) { return TopLevelAssertion.fromJSON(Theorem, json, context); }
|
|
32
32
|
|
|
33
|
-
static fromTheoremNode(theoremNode,
|
|
33
|
+
static fromTheoremNode(theoremNode, context) {
|
|
34
34
|
const node = theoremNode, ///
|
|
35
|
-
theorem = TopLevelAssertion.fromNode(Theorem, node,
|
|
35
|
+
theorem = TopLevelAssertion.fromNode(Theorem, node, context);
|
|
36
36
|
|
|
37
37
|
return theorem;
|
|
38
38
|
}
|
|
@@ -10,26 +10,29 @@ import { labelsFromJSON,
|
|
|
10
10
|
deductionFromJSON,
|
|
11
11
|
signatureFromJSON,
|
|
12
12
|
labelsToLabelsJSON,
|
|
13
|
+
hypothesesFromJSON,
|
|
13
14
|
suppositionsFromJSON,
|
|
14
15
|
deductionToDeductionJSON,
|
|
15
16
|
signatureToSignatureJSON,
|
|
17
|
+
hypothesesToHypothesesJSON,
|
|
16
18
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
17
19
|
|
|
18
|
-
const { reverse,
|
|
20
|
+
const { extract, reverse, correlate, backwardsEvery } = arrayUtilities;
|
|
19
21
|
|
|
20
22
|
export default class TopLevelAssertion {
|
|
21
|
-
constructor(
|
|
22
|
-
this.
|
|
23
|
+
constructor(context, string, labels, suppositions, deduction, proof, signature, hypotheses) {
|
|
24
|
+
this.context = context;
|
|
23
25
|
this.string = string;
|
|
24
26
|
this.labels = labels;
|
|
25
27
|
this.suppositions = suppositions;
|
|
26
28
|
this.deduction = deduction;
|
|
27
29
|
this.proof = proof;
|
|
28
30
|
this.signature = signature;
|
|
31
|
+
this.hypotheses = hypotheses;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
return this.
|
|
34
|
+
getContext() {
|
|
35
|
+
return this.context;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
getString() {
|
|
@@ -56,8 +59,35 @@ export default class TopLevelAssertion {
|
|
|
56
59
|
return this.signature;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
getHypotheses() {
|
|
63
|
+
return this.hypotheses;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setContext(context) { this.context = context; }
|
|
67
|
+
|
|
68
|
+
setString(string) { this.string = string; }
|
|
69
|
+
|
|
70
|
+
setLabels(labels) { this.labels = labels; }
|
|
71
|
+
|
|
72
|
+
setSuppositions(suppositions) { this.suppositions = suppositions; }
|
|
73
|
+
|
|
74
|
+
setDeduction(deduction) { this.deduction = deduction; }
|
|
75
|
+
|
|
76
|
+
setProof(proof) { this.proof = proof; }
|
|
77
|
+
|
|
78
|
+
setSignature(signature) { this.signature = signature; }
|
|
79
|
+
|
|
80
|
+
setHypotheses(hypotheses) { this.hypotheses = hypotheses; }
|
|
81
|
+
|
|
59
82
|
getStatement() { return this.deduction.getStatement(); }
|
|
60
83
|
|
|
84
|
+
isHypothetical() {
|
|
85
|
+
const hypothesesLength = this.hypotheses.length,
|
|
86
|
+
hypothetical = (hypothesesLength > 0);
|
|
87
|
+
|
|
88
|
+
return hypothetical;
|
|
89
|
+
}
|
|
90
|
+
|
|
61
91
|
isUnconditional() {
|
|
62
92
|
const suppositionsLength = this.suppositions.length,
|
|
63
93
|
unconditional = (suppositionsLength === 0);
|
|
@@ -89,7 +119,7 @@ export default class TopLevelAssertion {
|
|
|
89
119
|
const labelsVerify = this.verifyLabels();
|
|
90
120
|
|
|
91
121
|
if (labelsVerify) {
|
|
92
|
-
const localContext = LocalContext.
|
|
122
|
+
const localContext = LocalContext.fromContext(this.context),
|
|
93
123
|
context = localContext, ///
|
|
94
124
|
suppositionsVerify = this.verifySuppositions(context);
|
|
95
125
|
|
|
@@ -160,6 +190,36 @@ export default class TopLevelAssertion {
|
|
|
160
190
|
return proofVerifies;
|
|
161
191
|
}
|
|
162
192
|
|
|
193
|
+
correlateHypotheses(context) {
|
|
194
|
+
let hypothesesCorrelate;
|
|
195
|
+
|
|
196
|
+
const hypothetical = this.isHypothetical();
|
|
197
|
+
|
|
198
|
+
if (hypothetical) {
|
|
199
|
+
const steps = context.getSteps(),
|
|
200
|
+
topLevelAssertionString = this.string; ///
|
|
201
|
+
|
|
202
|
+
context.trace(`Correlating the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture...`);
|
|
203
|
+
|
|
204
|
+
hypothesesCorrelate = correlate(this.hypotheses, steps, (hypothesis, step) => {
|
|
205
|
+
const hypothesesEqualToStep = hypothesis.isEqualToStep(step, context);
|
|
206
|
+
|
|
207
|
+
if (hypothesesEqualToStep) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
if (hypothesesCorrelate) {
|
|
213
|
+
context.debug(`...correlated the hypotheses of the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture.`);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
hypothesesCorrelate = true
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
return hypothesesCorrelate;
|
|
221
|
+
}
|
|
222
|
+
|
|
163
223
|
unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext) {
|
|
164
224
|
let statementUnifiesWithDeduction = false;
|
|
165
225
|
|
|
@@ -175,21 +235,29 @@ export default class TopLevelAssertion {
|
|
|
175
235
|
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context) {
|
|
176
236
|
let statementAndStepsOrSubproofsUnify = false;
|
|
177
237
|
|
|
178
|
-
const
|
|
179
|
-
generalContext = localContext, ///
|
|
180
|
-
specificContext = context, ///
|
|
181
|
-
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
|
|
238
|
+
const hypothetical = this.isHypothetical();
|
|
182
239
|
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
240
|
+
if (!hypothetical) {
|
|
241
|
+
const generalContext = this.context, ///
|
|
242
|
+
specificContext = context, ///
|
|
243
|
+
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
|
|
185
244
|
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
245
|
+
if (statementUnifiesWithDeduction) {
|
|
246
|
+
const stepsOrSubproofsUnifyWithSuppositions = this.unifyStepsOrSubproofsWithSuppositions(stepsOrSubproofs, substitutions, generalContext, specificContext);
|
|
188
247
|
|
|
189
|
-
if (
|
|
190
|
-
|
|
248
|
+
if (stepsOrSubproofsUnifyWithSuppositions) {
|
|
249
|
+
const substitutionsResolved = substitutions.areResolved();
|
|
250
|
+
|
|
251
|
+
if (substitutionsResolved) {
|
|
252
|
+
statementAndStepsOrSubproofsUnify = true;
|
|
253
|
+
}
|
|
191
254
|
}
|
|
192
255
|
}
|
|
256
|
+
} else {
|
|
257
|
+
const statementString = statement.getString(),
|
|
258
|
+
topLevelAssertionString = this.string; ///
|
|
259
|
+
|
|
260
|
+
context.trace(`Cannot unify the '${topLevelAssertionString}' axiom, lemma, theorem or conjecture with the '${statementString}' and steps or subproofs because it is hypothetical.`);
|
|
193
261
|
}
|
|
194
262
|
|
|
195
263
|
return statementAndStepsOrSubproofsUnify;
|
|
@@ -239,62 +307,67 @@ export default class TopLevelAssertion {
|
|
|
239
307
|
deductionJSON = deductionToDeductionJSON(this.deduction),
|
|
240
308
|
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
241
309
|
signatureJSON = signatureToSignatureJSON(this.signature),
|
|
310
|
+
hypothesesJSON = hypothesesToHypothesesJSON(this.signature),
|
|
242
311
|
labels = labelsJSON, ///
|
|
243
312
|
deduction = deductionJSON, ///
|
|
244
313
|
suppositions = suppositionsJSON, ///
|
|
245
|
-
signature = signatureJSON,
|
|
314
|
+
signature = signatureJSON, ///
|
|
315
|
+
hypotheses = hypothesesJSON, ///
|
|
246
316
|
json = {
|
|
247
317
|
labels,
|
|
248
318
|
deduction,
|
|
249
319
|
suppositions,
|
|
250
320
|
signature,
|
|
321
|
+
hypotheses
|
|
251
322
|
};
|
|
252
323
|
|
|
253
324
|
return json;
|
|
254
325
|
}
|
|
255
326
|
|
|
256
|
-
static fromJSON(Class, json,
|
|
257
|
-
const labels = labelsFromJSON(json,
|
|
258
|
-
deduction = deductionFromJSON(json,
|
|
259
|
-
suppositions = suppositionsFromJSON(json,
|
|
260
|
-
signature = signatureFromJSON(json,
|
|
327
|
+
static fromJSON(Class, json, context) {
|
|
328
|
+
const labels = labelsFromJSON(json, context),
|
|
329
|
+
deduction = deductionFromJSON(json, context),
|
|
330
|
+
suppositions = suppositionsFromJSON(json, context),
|
|
331
|
+
signature = signatureFromJSON(json, context),
|
|
332
|
+
hypotheses = hypothesesFromJSON(json, context),
|
|
261
333
|
proof = null,
|
|
262
334
|
string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
|
|
263
|
-
topLevelAssertion = new Class(
|
|
335
|
+
topLevelAssertion = new Class(context, string, labels, suppositions, deduction, proof, signature, hypotheses);
|
|
264
336
|
|
|
265
337
|
return topLevelAssertion;
|
|
266
338
|
}
|
|
267
339
|
|
|
268
|
-
static fromNode(Class, node,
|
|
340
|
+
static fromNode(Class, node, context) {
|
|
269
341
|
const topLevelAssertionNode = node, ///
|
|
270
342
|
proofNode = topLevelAssertionNode.getProofNode(),
|
|
271
343
|
labelNodes = topLevelAssertionNode.getLabelNodes(),
|
|
272
344
|
deductionNode = topLevelAssertionNode.getDeductionNode(),
|
|
273
345
|
suppositionNodes = topLevelAssertionNode.getSuppositionNodes(),
|
|
274
346
|
signatureNode = topLevelAssertionNode.getSignatureNode(),
|
|
275
|
-
proof = proofFromProofNode(proofNode,
|
|
276
|
-
labels = labelsFromLabelNodes(labelNodes,
|
|
277
|
-
deduction = deductionFromDeductionNode(deductionNode,
|
|
278
|
-
suppositions = suppositionsFromSuppositionNodes(suppositionNodes,
|
|
279
|
-
signature = signatureFromSignatureNode(signatureNode,
|
|
347
|
+
proof = proofFromProofNode(proofNode, context),
|
|
348
|
+
labels = labelsFromLabelNodes(labelNodes, context),
|
|
349
|
+
deduction = deductionFromDeductionNode(deductionNode, context),
|
|
350
|
+
suppositions = suppositionsFromSuppositionNodes(suppositionNodes, context),
|
|
351
|
+
signature = signatureFromSignatureNode(signatureNode, context),
|
|
352
|
+
hypotheses = [],
|
|
280
353
|
string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
|
|
281
|
-
topLevelAssertion = new Class(
|
|
354
|
+
topLevelAssertion = new Class(context, string, labels, suppositions, deduction, proof, signature, hypotheses);
|
|
282
355
|
|
|
283
356
|
return topLevelAssertion;
|
|
284
357
|
}
|
|
285
358
|
}
|
|
286
359
|
|
|
287
|
-
export function proofFromProofNode(proofNode,
|
|
360
|
+
export function proofFromProofNode(proofNode, context) {
|
|
288
361
|
const { Proof } = dom,
|
|
289
|
-
proof = Proof.fromProofNode(proofNode,
|
|
362
|
+
proof = Proof.fromProofNode(proofNode, context);
|
|
290
363
|
|
|
291
364
|
return proof;
|
|
292
365
|
}
|
|
293
366
|
|
|
294
|
-
export function labelsFromLabelNodes(labelNodes,
|
|
367
|
+
export function labelsFromLabelNodes(labelNodes, context) {
|
|
295
368
|
const { Label } = dom,
|
|
296
369
|
labels = labelNodes.map((labelNode) => {
|
|
297
|
-
const label = Label.fromLabelNode(labelNode,
|
|
370
|
+
const label = Label.fromLabelNode(labelNode, context);
|
|
298
371
|
|
|
299
372
|
return label;
|
|
300
373
|
});
|
|
@@ -302,29 +375,29 @@ export function labelsFromLabelNodes(labelNodes, fileContext) {
|
|
|
302
375
|
return labels;
|
|
303
376
|
}
|
|
304
377
|
|
|
305
|
-
export function signatureFromSignatureNode(signatureNode,
|
|
378
|
+
export function signatureFromSignatureNode(signatureNode, context) {
|
|
306
379
|
let signature = null;
|
|
307
380
|
|
|
308
381
|
if (signatureNode !== null) {
|
|
309
382
|
const { Signature } = dom;
|
|
310
383
|
|
|
311
|
-
signature = Signature.fromSignatureNode(signatureNode,
|
|
384
|
+
signature = Signature.fromSignatureNode(signatureNode, context);
|
|
312
385
|
}
|
|
313
386
|
|
|
314
387
|
return signature;
|
|
315
388
|
}
|
|
316
389
|
|
|
317
|
-
export function deductionFromDeductionNode(deductionNode,
|
|
390
|
+
export function deductionFromDeductionNode(deductionNode, context) {
|
|
318
391
|
const { Deduction } = dom,
|
|
319
|
-
deduction = Deduction.fromDeductionNode(deductionNode,
|
|
392
|
+
deduction = Deduction.fromDeductionNode(deductionNode, context);
|
|
320
393
|
|
|
321
394
|
return deduction;
|
|
322
395
|
}
|
|
323
396
|
|
|
324
|
-
export function suppositionsFromSuppositionNodes(suppositionNodes,
|
|
397
|
+
export function suppositionsFromSuppositionNodes(suppositionNodes, context) {
|
|
325
398
|
const { Supposition } = dom,
|
|
326
399
|
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
327
|
-
const supposition = Supposition.fromSuppositionNode(suppositionNode,
|
|
400
|
+
const supposition = Supposition.fromSuppositionNode(suppositionNode, context);
|
|
328
401
|
|
|
329
402
|
return supposition;
|
|
330
403
|
});
|