occam-verify-cli 1.0.924 → 1.0.932
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/context/bounded.js +19 -18
- package/lib/context/file/nominal.js +1 -13
- package/lib/context/mnemic.js +1 -5
- package/lib/context.js +17 -26
- package/lib/element/assertion/contained.js +4 -6
- package/lib/element/assertion/defined.js +19 -21
- package/lib/element/assertion/type.js +43 -14
- package/lib/element/constructor/bracketed.js +3 -2
- package/lib/element/constructor.js +5 -3
- package/lib/element/declaration/variable.js +2 -1
- package/lib/element/hypothesis.js +55 -40
- package/lib/element/metavariable.js +13 -7
- package/lib/element/proofAssertion/step.js +1 -5
- package/lib/element/section.js +21 -27
- package/lib/element/statement.js +8 -3
- package/lib/element/substitution/statement.js +14 -15
- package/lib/element/substitution.js +17 -1
- package/lib/element/term.js +22 -13
- package/lib/element/topLevelAssertion.js +6 -2
- package/lib/element/type.js +4 -4
- package/lib/element/variable.js +57 -33
- package/lib/utilities/assignment.js +25 -9
- package/lib/utilities/element.js +37 -23
- package/lib/utilities/equivalences.js +2 -2
- package/lib/utilities/string.js +36 -35
- package/lib/utilities/substitutions.js +14 -26
- package/lib/utilities/unification.js +45 -44
- package/lib/utilities/validation.js +5 -3
- package/package.json +1 -1
- package/src/context/bounded.js +19 -17
- package/src/context/file/nominal.js +0 -18
- package/src/context/mnemic.js +0 -7
- package/src/context.js +24 -43
- package/src/element/assertion/contained.js +6 -11
- package/src/element/assertion/defined.js +32 -36
- package/src/element/assertion/type.js +61 -18
- package/src/element/constructor/bracketed.js +4 -1
- package/src/element/constructor.js +7 -2
- package/src/element/declaration/variable.js +2 -0
- package/src/element/hypothesis.js +71 -54
- package/src/element/metavariable.js +20 -11
- package/src/element/proofAssertion/step.js +0 -6
- package/src/element/section.js +24 -31
- package/src/element/statement.js +11 -1
- package/src/element/substitution/statement.js +23 -21
- package/src/element/substitution.js +24 -0
- package/src/element/term.js +29 -11
- package/src/element/topLevelAssertion.js +8 -2
- package/src/element/type.js +4 -4
- package/src/element/variable.js +81 -44
- package/src/utilities/assignment.js +34 -8
- package/src/utilities/element.js +44 -29
- package/src/utilities/equivalences.js +1 -1
- package/src/utilities/string.js +59 -53
- package/src/utilities/substitutions.js +14 -40
- package/src/utilities/unification.js +60 -60
- package/src/utilities/validation.js +7 -2
package/src/context.js
CHANGED
|
@@ -353,42 +353,6 @@ export default class Context extends ContextBase {
|
|
|
353
353
|
return metaLevelAssumption;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
findSubstitutionByVariableNode(variableNode) {
|
|
357
|
-
const context = this.getContext(),
|
|
358
|
-
substitution = context.findSubstitutionByVariableNode(variableNode);
|
|
359
|
-
|
|
360
|
-
return substitution;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
findSubstitutionByMetavariableNode(metavariableNode) {
|
|
364
|
-
const context = this.getContext(),
|
|
365
|
-
substitution = context.findSubstitutionByMetavariableNode(metavariableNode);
|
|
366
|
-
|
|
367
|
-
return substitution;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
findSimpleSubstitutionByMetavariableNode(metavariableNode) {
|
|
371
|
-
const context = this.getContext(),
|
|
372
|
-
simpleSubstitution = context.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
373
|
-
|
|
374
|
-
return simpleSubstitution;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
findComplexSubstitutionsByMetavariableNode(metavariableNode) {
|
|
378
|
-
const context = this.getContext(),
|
|
379
|
-
complexSubstitution = context.findComplexSubstitutionsByMetavariableNode(metavariableNode);
|
|
380
|
-
|
|
381
|
-
return complexSubstitution;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
findSubstitutionByMetavariableNodeAndSubstitution(metavariableNode, substitution) {
|
|
385
|
-
const context = this.getContext();
|
|
386
|
-
|
|
387
|
-
substitution = context.findSubstitutionByMetavariableNodeAndSubstitution(metavariableNode, substitution); ///
|
|
388
|
-
|
|
389
|
-
return substitution;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
356
|
findTypeByTypeName(typeName) {
|
|
393
357
|
const context = this.getContext(),
|
|
394
358
|
type = context.findTypeByTypeName(typeName);
|
|
@@ -529,13 +493,6 @@ export default class Context extends ContextBase {
|
|
|
529
493
|
return metavariablePresent;
|
|
530
494
|
}
|
|
531
495
|
|
|
532
|
-
isSubstitutionPresentBySubstitutionNode(substitutionNode) {
|
|
533
|
-
const context = this.getContext(),
|
|
534
|
-
substitutionPresent = context.isSubstitutionPresentBySubstitutionNode(substitutionNode);
|
|
535
|
-
|
|
536
|
-
return substitutionPresent;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
496
|
isTypePresentByNominalTypeName(nominalTypeName) {
|
|
540
497
|
const context = this.getContext(),
|
|
541
498
|
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
@@ -611,6 +568,30 @@ export default class Context extends ContextBase {
|
|
|
611
568
|
context.addDerivedSubstitutions(derivedSubstitutions);
|
|
612
569
|
}
|
|
613
570
|
|
|
571
|
+
addAxiom(axiom) {
|
|
572
|
+
const context = this.getContext();
|
|
573
|
+
|
|
574
|
+
context.addAxiom(axiom);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
addLemma(lemma) {
|
|
578
|
+
const context = this.getContext();
|
|
579
|
+
|
|
580
|
+
context.addLemma(lemma);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
addTheorem(theorem) {
|
|
584
|
+
const context = this.getContext();
|
|
585
|
+
|
|
586
|
+
context.addTheorem(theorem);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
addConjecture(conjecture) {
|
|
590
|
+
const context = this.getContext();
|
|
591
|
+
|
|
592
|
+
context.addConjecture(conjecture);
|
|
593
|
+
}
|
|
594
|
+
|
|
614
595
|
addTerm(term) {
|
|
615
596
|
const context = this.getContext();
|
|
616
597
|
|
|
@@ -211,10 +211,7 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
211
211
|
|
|
212
212
|
context.trace(`Validating the '${containedAssertionString}' derived contained assertion...`);
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
specificContext = context; ///
|
|
216
|
-
|
|
217
|
-
validatesWhenDerived = validateWhenDerived(this.term, this.frame, this.statement, this.negated, generalCotnext, specificContext);
|
|
214
|
+
validatesWhenDerived = validateWhenDerived(this.term, this.frame, this.statement, this.negated, context);
|
|
218
215
|
|
|
219
216
|
if (validatesWhenDerived) {
|
|
220
217
|
context.debug(`...validated the '${containedAssertionString}' derived contained assertion.`);
|
|
@@ -231,10 +228,10 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
231
228
|
|
|
232
229
|
context.trace(`Unifying the '${containedAssertionString}' contained assertion independently...`);
|
|
233
230
|
|
|
234
|
-
const term = termFromTermAndSubstitutions(this.term,
|
|
235
|
-
frame = frameFromFrameAndSubstitutions(this.frame,
|
|
236
|
-
statement = statementFromStatementAndSubstitutions(this.statement,
|
|
237
|
-
validatesWhenDerived = validateWhenDerived(term, frame, statement, this.negated,
|
|
231
|
+
const term = termFromTermAndSubstitutions(this.term, context),
|
|
232
|
+
frame = frameFromFrameAndSubstitutions(this.frame, context),
|
|
233
|
+
statement = statementFromStatementAndSubstitutions(this.statement, context),
|
|
234
|
+
validatesWhenDerived = validateWhenDerived(term, frame, statement, this.negated, context);
|
|
238
235
|
|
|
239
236
|
if (validatesWhenDerived) {
|
|
240
237
|
unifiesIndependently = true;
|
|
@@ -281,11 +278,9 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
281
278
|
}
|
|
282
279
|
});
|
|
283
280
|
|
|
284
|
-
function validateWhenDerived(term, frame, statement, negated,
|
|
281
|
+
function validateWhenDerived(term, frame, statement, negated, context) {
|
|
285
282
|
let validatesWhenDerived = false;
|
|
286
283
|
|
|
287
|
-
const context = specificContext; ///
|
|
288
|
-
|
|
289
284
|
if (statement !== null) {
|
|
290
285
|
if (term !== null) {
|
|
291
286
|
const termContained = statement.isTermContained(term, context);
|
|
@@ -180,10 +180,7 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
180
180
|
|
|
181
181
|
context.trace(`Validating the '${definedAssertionString}' derived defined assertion...`);
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
specificContext = context; ///
|
|
185
|
-
|
|
186
|
-
validatesWhenDerived = validateWhenDerived(this.term, this.frame, this.negated, generalContext, specificContext);
|
|
183
|
+
validatesWhenDerived = validateWhenDerived(this.term, this.frame, this.negated, context);
|
|
187
184
|
|
|
188
185
|
if (validatesWhenDerived) {
|
|
189
186
|
context.debug(`...validates the '${definedAssertionString}' derived defined assertion.`);
|
|
@@ -200,9 +197,9 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
200
197
|
|
|
201
198
|
context.trace(`Unifying the '${definedAssertionString}' defined assertion independently...`);
|
|
202
199
|
|
|
203
|
-
const term = termFromTermAndSubstitutions(this.term,
|
|
204
|
-
frame = frameFromFrameAndSubstitutions(this.frame,
|
|
205
|
-
validatesWhenDerived = validateWhenDerived(term, frame, this.negated,
|
|
200
|
+
const term = termFromTermAndSubstitutions(this.term, context),
|
|
201
|
+
frame = frameFromFrameAndSubstitutions(this.frame, context),
|
|
202
|
+
validatesWhenDerived = validateWhenDerived(term, frame, this.negated, context);
|
|
206
203
|
|
|
207
204
|
if (validatesWhenDerived) {
|
|
208
205
|
unifiesIndependently = true;
|
|
@@ -248,10 +245,35 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
248
245
|
}
|
|
249
246
|
});
|
|
250
247
|
|
|
251
|
-
function
|
|
252
|
-
|
|
248
|
+
function isVariableDefined(variable, context) {
|
|
249
|
+
const equivalences = context.getEquivalences(),
|
|
250
|
+
groundedTerms = [],
|
|
251
|
+
definedVariables = [];
|
|
252
|
+
|
|
253
|
+
separateGroundedTermsAndDefinedVariables(equivalences, groundedTerms, definedVariables, context);
|
|
254
|
+
|
|
255
|
+
const variableMatchesDefinedVariable = definedVariables.some((definedVariable) => {
|
|
256
|
+
const definedVariableComparesToVariable = definedVariable.compareVariable(variable);
|
|
257
|
+
|
|
258
|
+
if (definedVariableComparesToVariable === variable) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
variableDefined = variableMatchesDefinedVariable; ///
|
|
263
|
+
|
|
264
|
+
return variableDefined;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function isMetavariableDefined(metavariable, context) {
|
|
268
|
+
const metavariableNode = metavariable.getNode(),
|
|
269
|
+
declaredJudgementPresent = context.isDeclaredJudgementPresentByMetavariableNode(metavariableNode),
|
|
270
|
+
metavariableDefined = declaredJudgementPresent; ///
|
|
253
271
|
|
|
254
|
-
|
|
272
|
+
return metavariableDefined
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function validateWhenDerived(term, frame, negated, context) {
|
|
276
|
+
let validatesWhenDerived = false;
|
|
255
277
|
|
|
256
278
|
if (term !== null) {
|
|
257
279
|
const variableIdentifier = term.getVariableIdentifier(),
|
|
@@ -284,29 +306,3 @@ function validateWhenDerived(term, frame, negated, generalContext, specificConte
|
|
|
284
306
|
return validatesWhenDerived;
|
|
285
307
|
}
|
|
286
308
|
|
|
287
|
-
function isVariableDefined(variable, context) {
|
|
288
|
-
const equivalences = context.getEquivalences(),
|
|
289
|
-
groundedTerms = [],
|
|
290
|
-
definedVariables = [];
|
|
291
|
-
|
|
292
|
-
separateGroundedTermsAndDefinedVariables(equivalences, groundedTerms, definedVariables, context);
|
|
293
|
-
|
|
294
|
-
const variableMatchesDefinedVariable = definedVariables.some((definedVariable) => {
|
|
295
|
-
const definedVariableComparesToVariable = definedVariable.compareVariable(variable);
|
|
296
|
-
|
|
297
|
-
if (definedVariableComparesToVariable === variable) {
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
}),
|
|
301
|
-
variableDefined = variableMatchesDefinedVariable; ///
|
|
302
|
-
|
|
303
|
-
return variableDefined;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function isMetavariableDefined(metavariable, context) {
|
|
307
|
-
const metavariableNode = metavariable.getNode(),
|
|
308
|
-
declaredJudgementPresent = context.isDeclaredJudgementPresentByMetavariableNode(metavariableNode),
|
|
309
|
-
metavariableDefined = declaredJudgementPresent; ///
|
|
310
|
-
|
|
311
|
-
return metavariableDefined
|
|
312
|
-
}
|
|
@@ -6,6 +6,7 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiateTypeAssertion } from "../../process/instantiate";
|
|
8
8
|
import { typeFromJSON, typeToTypeJSON } from "../../utilities/json";
|
|
9
|
+
import { termFromTermAndSubstitutions } from "../../utilities/substitutions";
|
|
9
10
|
import { variableAssignmentFromTypeAssertion } from "../../process/assign";
|
|
10
11
|
import { termFromTypeAssertionNode, typeAssertionFromStatementNode } from "../../utilities/element";
|
|
11
12
|
|
|
@@ -125,10 +126,19 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
125
126
|
let validatesForwards = false;
|
|
126
127
|
|
|
127
128
|
const termType = term.getType(),
|
|
128
|
-
|
|
129
|
+
termTypeEqualToType = termType.isEqualTo(this.type),
|
|
130
|
+
termTypeSuperTypeOfType = termType.isSuperTypeOf(this.type);
|
|
129
131
|
|
|
130
|
-
if (
|
|
132
|
+
if (false) {
|
|
133
|
+
///
|
|
134
|
+
} else if (termTypeEqualToType) {
|
|
131
135
|
validatesForwards = true;
|
|
136
|
+
} else if (termTypeSuperTypeOfType) {
|
|
137
|
+
const termEstablished = term.isEstablished();
|
|
138
|
+
|
|
139
|
+
if (termEstablished) {
|
|
140
|
+
validatesForwards = true;
|
|
141
|
+
}
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
return validatesForwards;
|
|
@@ -154,22 +164,7 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
154
164
|
|
|
155
165
|
context.trace(`Validating the '${typeAssertionString}' derived type assertion...`);
|
|
156
166
|
|
|
157
|
-
const term = this.term.
|
|
158
|
-
let validatesForwards = false;
|
|
159
|
-
|
|
160
|
-
const termType = term.getType(),
|
|
161
|
-
termTypeProvisional = termType.isProvisional();
|
|
162
|
-
|
|
163
|
-
if (!termTypeProvisional) {
|
|
164
|
-
const termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(this.type);
|
|
165
|
-
|
|
166
|
-
if (termTypeEqualToOrSubTypeOfType) {
|
|
167
|
-
validatesForwards = true;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return validatesForwards;
|
|
172
|
-
});
|
|
167
|
+
const term = validateWhenDerived(this.term, this.type, context);
|
|
173
168
|
|
|
174
169
|
if (term !== null) {
|
|
175
170
|
this.term = term;
|
|
@@ -184,6 +179,31 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
184
179
|
return validatesWhenDerived;
|
|
185
180
|
}
|
|
186
181
|
|
|
182
|
+
unifyIndependently(generalContext, specificContext) {
|
|
183
|
+
let unifiesIndependently = false;
|
|
184
|
+
|
|
185
|
+
const context = specificContext, ///
|
|
186
|
+
typeAssertionString = this.getString(); ///
|
|
187
|
+
|
|
188
|
+
context.trace(`Unifying the '${typeAssertionString}' type assertion independently...`);
|
|
189
|
+
|
|
190
|
+
let term;
|
|
191
|
+
|
|
192
|
+
term = termFromTermAndSubstitutions(this.term, context);
|
|
193
|
+
|
|
194
|
+
term = validateWhenDerived(term, this.type, context); //
|
|
195
|
+
|
|
196
|
+
if (term !== null) {
|
|
197
|
+
unifiesIndependently = true;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (unifiesIndependently) {
|
|
201
|
+
context.debug(`...unified the '${typeAssertionString}' type assertion independently.`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return unifiesIndependently;
|
|
205
|
+
}
|
|
206
|
+
|
|
187
207
|
assign(context) {
|
|
188
208
|
const stated = context.isStated();
|
|
189
209
|
|
|
@@ -244,3 +264,26 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
244
264
|
return typeAssertion;
|
|
245
265
|
}
|
|
246
266
|
});
|
|
267
|
+
|
|
268
|
+
function validateWhenDerived(term, type, context) {
|
|
269
|
+
if (term !== null) {
|
|
270
|
+
term = term.validate(context, (term) => {
|
|
271
|
+
let validatesForwards = false;
|
|
272
|
+
|
|
273
|
+
const termType = term.getType(),
|
|
274
|
+
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
275
|
+
|
|
276
|
+
if (termTypeEqualToOrSubTypeOfType) {
|
|
277
|
+
const termEstablished = term.isEstablished();
|
|
278
|
+
|
|
279
|
+
if (termEstablished) {
|
|
280
|
+
validatesForwards = true;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return validatesForwards;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return term;
|
|
289
|
+
}
|
|
@@ -37,10 +37,13 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
37
37
|
bracketlessTerm = bracketlessTerm.validate(context, (bracketlessTerm) => { ///
|
|
38
38
|
let validatesForwards;
|
|
39
39
|
|
|
40
|
-
const type = bracketlessTerm.getType()
|
|
40
|
+
const type = bracketlessTerm.getType(),
|
|
41
|
+
provisional = bracketlessTerm.isProvisional();
|
|
41
42
|
|
|
42
43
|
bracketedTerm.setType(type);
|
|
43
44
|
|
|
45
|
+
bracketedTerm.setProvisional(provisional);
|
|
46
|
+
|
|
44
47
|
validatesForwards = validateForwards(bracketedTerm);
|
|
45
48
|
|
|
46
49
|
return validatesForwards;
|
|
@@ -8,6 +8,7 @@ import { termFromConstructorNode } from "../utilities/element";
|
|
|
8
8
|
import { unifyTermWithConstructor } from "../process/unify";
|
|
9
9
|
import { validateTermAsConstructor } from "../process/validate";
|
|
10
10
|
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
11
|
+
import { provisionallyStringFromProvisional } from "../utilities/string";
|
|
11
12
|
import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
13
|
|
|
13
14
|
export default define(class Constructor extends Element {
|
|
@@ -123,12 +124,16 @@ export default define(class Constructor extends Element {
|
|
|
123
124
|
if (termUnifiesWithConstructor) {
|
|
124
125
|
let validatesForwards;
|
|
125
126
|
|
|
126
|
-
const typeString = this.type.getString()
|
|
127
|
+
const typeString = this.type.getString(),
|
|
128
|
+
provisional = this.type.isProvisional(),
|
|
129
|
+
provisionallyString = provisionallyStringFromProvisional(provisional)
|
|
127
130
|
|
|
128
|
-
context.trace(`Setting the '${termString}' term's type to the '${constructorString}' constructor's '${typeString}' type.`);
|
|
131
|
+
context.trace(`Setting the '${termString}' term's type to the '${constructorString}' constructor's '${typeString}' type${provisionallyString}.`);
|
|
129
132
|
|
|
130
133
|
term.setType(this.type);
|
|
131
134
|
|
|
135
|
+
term.setProvisional(provisional);
|
|
136
|
+
|
|
132
137
|
validatesForwards = validateForwards(term);
|
|
133
138
|
|
|
134
139
|
if (validatesForwards) {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { descend, instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateHypothesis } from "../process/instantiate";
|
|
8
7
|
import { statementFromHypothesisNode } from "../utilities/element";
|
|
8
|
+
import { declare, attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
9
9
|
|
|
10
10
|
export default define(class Hypothesis extends Element {
|
|
11
11
|
constructor(context, string, node, lineIndex, statement) {
|
|
@@ -25,95 +25,112 @@ export default define(class Hypothesis extends Element {
|
|
|
25
25
|
return hypothesisNode;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
let
|
|
28
|
+
async verify(context) {
|
|
29
|
+
let verifies = false;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
proofAssertionString = proofAssertion.getString();
|
|
31
|
+
await this.break(context);
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
const hypothesisString = this.getString(); ///
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
statementEqualToStepStatement = this.statement.isEqualTo(proofAssertionStatement);
|
|
35
|
+
context.trace(`Verifying the '${hypothesisString}' hypothesis...`);
|
|
38
36
|
|
|
39
|
-
if (
|
|
40
|
-
|
|
37
|
+
if (this.statement !== null) {
|
|
38
|
+
const validates = this.validate(context);
|
|
39
|
+
|
|
40
|
+
if (validates) {
|
|
41
|
+
verifies = true;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
context.debug(`Unable to verify the '${hypothesisString}' hypothesis because it is nonsense.`);
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
if (
|
|
44
|
-
context.
|
|
47
|
+
if (verifies) {
|
|
48
|
+
context.debug(`...verified the '${hypothesisString}' hypothesis.`);
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
return
|
|
51
|
+
return verifies;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
await this.break(context);
|
|
54
|
+
validate(context) {
|
|
55
|
+
let validates = false;
|
|
54
56
|
|
|
55
57
|
const hypothesisString = this.getString(); ///
|
|
56
58
|
|
|
57
|
-
context.trace(`
|
|
59
|
+
context.trace(`Validating the '${hypothesisString}' hypothesis...`);
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let statementValidates = false;
|
|
61
|
+
declare((context) => {
|
|
62
|
+
attempt((context) => {
|
|
63
|
+
const statementValidates = this.validateStatement(context);
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
if (statementValidates) {
|
|
66
|
+
validates = true;
|
|
67
|
+
}
|
|
66
68
|
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
+
if (validates) {
|
|
70
|
+
this.commit(context);
|
|
69
71
|
}
|
|
70
72
|
}, context);
|
|
73
|
+
}, context)
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (validates) {
|
|
76
|
+
context.debug(`...validated the '${hypothesisString}' hypothesis.`);
|
|
77
|
+
}
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
return validates;
|
|
80
|
+
}
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
validateStatement(context) {
|
|
83
|
+
let statementValidates = false;
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
85
|
+
const hypothesisString = this.getString();
|
|
86
|
+
|
|
87
|
+
context.trace(`Validating the '${hypothesisString}' hypothesis's statement... `);
|
|
88
|
+
|
|
89
|
+
const statement = this.statement.validate(context); ///
|
|
90
|
+
|
|
91
|
+
if (statement !== null) {
|
|
92
|
+
statementValidates = true;
|
|
83
93
|
}
|
|
84
94
|
|
|
85
|
-
if (
|
|
86
|
-
context.debug(`...
|
|
95
|
+
if (statementValidates) {
|
|
96
|
+
context.debug(`...validated the '${hypothesisString}' hypothesis's statement. `);
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
return
|
|
99
|
+
return statementValidates;
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
static name = "Hypothesis";
|
|
93
103
|
|
|
94
104
|
toJSON() {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
lineIndex
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
const context = this.getContext();
|
|
106
|
+
|
|
107
|
+
return serialise((context) => {
|
|
108
|
+
const string = this.getString(),
|
|
109
|
+
lineIndex = this.getLineIndex(),
|
|
110
|
+
json = {
|
|
111
|
+
context,
|
|
112
|
+
string,
|
|
113
|
+
lineIndex
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return json;
|
|
117
|
+
}, context);
|
|
103
118
|
}
|
|
104
119
|
|
|
105
120
|
static fromJSON(json, context) {
|
|
106
|
-
|
|
107
|
-
const { string, lineIndex } = json,
|
|
108
|
-
hypothesisNode = instantiateHypothesis(string, context),
|
|
109
|
-
node = hypothesisNode, ///
|
|
110
|
-
statement = statementFromHypothesisNode(hypothesisNode, context);
|
|
121
|
+
let hypothesis;
|
|
111
122
|
|
|
112
|
-
|
|
123
|
+
unserialise((json, context) => {
|
|
124
|
+
instantiate((context) => {
|
|
125
|
+
const { string, lineIndex } = json,
|
|
126
|
+
hypothesisNode = instantiateHypothesis(string, context),
|
|
127
|
+
node = hypothesisNode, ///
|
|
128
|
+
statement = statementFromHypothesisNode(hypothesisNode, context);
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
hypothesis = new Hypothesis(context, string, node, lineIndex, statement);
|
|
131
|
+
}, context);
|
|
132
|
+
}, json, context);
|
|
115
133
|
|
|
116
|
-
|
|
117
|
-
}, context);
|
|
134
|
+
return hypothesis;
|
|
118
135
|
}
|
|
119
136
|
});
|
|
@@ -353,10 +353,13 @@ export default define(class Metavariable extends Element {
|
|
|
353
353
|
frameUnifies = true;
|
|
354
354
|
}
|
|
355
355
|
} else {
|
|
356
|
-
const { FrameSubstitution } = elements
|
|
357
|
-
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, generalContext, specificContext);
|
|
356
|
+
const { FrameSubstitution } = elements;
|
|
358
357
|
|
|
359
|
-
frameSubstitution
|
|
358
|
+
let frameSubstitution;
|
|
359
|
+
|
|
360
|
+
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, generalContext, specificContext);
|
|
361
|
+
|
|
362
|
+
frameSubstitution = frameSubstitution.validate(context); ///
|
|
360
363
|
|
|
361
364
|
const derivedSubstitution = frameSubstitution; ///
|
|
362
365
|
|
|
@@ -407,12 +410,15 @@ export default define(class Metavariable extends Element {
|
|
|
407
410
|
statementUnifies = true;
|
|
408
411
|
}
|
|
409
412
|
} else {
|
|
410
|
-
const { StatementSubstitution } = elements
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, generalContext, specificContext);
|
|
413
|
+
const { StatementSubstitution } = elements;
|
|
414
|
+
|
|
415
|
+
let statementSubstitution;
|
|
414
416
|
|
|
415
|
-
statementSubstitution
|
|
417
|
+
statementSubstitution = (substitution !== null) ?
|
|
418
|
+
StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, generalContext, specificContext) :
|
|
419
|
+
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, generalContext, specificContext);
|
|
420
|
+
|
|
421
|
+
statementSubstitution = statementSubstitution.validate(substitution, context); ///
|
|
416
422
|
|
|
417
423
|
const derivedSubstitution = statementSubstitution; ///
|
|
418
424
|
|
|
@@ -458,10 +464,13 @@ export default define(class Metavariable extends Element {
|
|
|
458
464
|
referenceUnifies = true;
|
|
459
465
|
}
|
|
460
466
|
} else {
|
|
461
|
-
const { ReferenceSubstitution } = elements
|
|
462
|
-
|
|
467
|
+
const { ReferenceSubstitution } = elements;
|
|
468
|
+
|
|
469
|
+
let referenceSubstitution;
|
|
470
|
+
|
|
471
|
+
referenceSubstitution = ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, generalContext, specificContext);
|
|
463
472
|
|
|
464
|
-
referenceSubstitution.validate(context);
|
|
473
|
+
referenceSubstitution = referenceSubstitution.validate(context); ///
|
|
465
474
|
|
|
466
475
|
const derivedSubstitution = referenceSubstitution; ///
|
|
467
476
|
|
|
@@ -43,12 +43,6 @@ export default define(class Step extends ProofAssertion {
|
|
|
43
43
|
return statementNode;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
isSatisfied() {
|
|
47
|
-
const satisfied = (this.signatureAssertion !== null);
|
|
48
|
-
|
|
49
|
-
return satisfied;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
46
|
isQualified() {
|
|
53
47
|
const qualified = ((this.reference !== null) || (this.signatureAssertion !== null));
|
|
54
48
|
|