occam-verify-cli 1.0.396 → 1.0.404
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/equality.js +2 -2
- package/lib/context/file.js +4 -5
- package/lib/context/local.js +17 -6
- package/lib/context/partial.js +10 -10
- package/lib/context/temporary.js +102 -52
- package/lib/mixins/step/unify.js +5 -6
- package/lib/node/argument.js +4 -4
- package/lib/node/assertion/contained.js +6 -6
- package/lib/node/assertion/defined.js +6 -6
- package/lib/node/assertion/property.js +6 -6
- package/lib/node/assertion/satisfies.js +6 -6
- package/lib/node/assertion/subproof.js +6 -6
- package/lib/node/assertion/type.js +6 -6
- package/lib/node/assertion.js +107 -0
- package/lib/node/assumption.js +134 -0
- package/lib/node/axiom.js +6 -6
- package/lib/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +12 -12
- package/lib/node/body.js +4 -5
- package/lib/node/combinator.js +4 -4
- package/lib/node/conclusion.js +4 -4
- package/lib/node/conjecture.js +6 -6
- package/lib/node/constructor.js +4 -4
- package/lib/node/declaration/combinator.js +6 -6
- package/lib/node/declaration/complexType.js +6 -6
- package/lib/node/declaration/constructor.js +6 -6
- package/lib/node/declaration/metavariable.js +6 -6
- package/lib/node/declaration/property.js +6 -6
- package/lib/node/declaration/simpleType.js +6 -6
- package/lib/node/declaration/typePrefix.js +6 -6
- package/lib/node/declaration/variable.js +6 -6
- package/lib/node/declaration.js +6 -22
- package/lib/node/deduction.js +4 -4
- package/lib/node/derivation.js +4 -4
- package/lib/node/document.js +107 -0
- package/lib/node/equality.js +4 -4
- package/lib/node/error.js +4 -4
- package/lib/node/frame.js +25 -14
- package/lib/node/header.js +4 -4
- package/lib/node/hypothesis.js +4 -4
- package/lib/node/judgement.js +8 -8
- package/lib/node/label.js +4 -4
- package/lib/node/labels.js +4 -4
- package/lib/node/lemma.js +6 -6
- package/lib/node/metaArgument.js +4 -4
- package/lib/node/metaLemma.js +6 -6
- package/lib/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +12 -12
- package/lib/node/metaType.js +4 -4
- package/lib/node/metatheorem.js +6 -6
- package/lib/node/metavariable.js +4 -4
- package/lib/node/nonsense.js +4 -4
- package/lib/node/parameter.js +4 -4
- package/lib/node/parenthesisedLabel.js +4 -4
- package/lib/node/parenthesisedLabels.js +4 -4
- package/lib/node/placeholder.js +107 -0
- package/lib/node/premise.js +4 -4
- package/lib/node/procedureCall.js +4 -4
- package/lib/node/procedureReference.js +4 -4
- package/lib/node/proof.js +4 -4
- package/lib/node/property.js +4 -4
- package/lib/node/propertyRelation.js +4 -4
- package/lib/node/qualification.js +4 -4
- package/lib/node/reference.js +4 -4
- package/lib/node/rule.js +4 -4
- package/lib/node/section.js +4 -4
- package/lib/node/signature.js +4 -4
- package/lib/node/statement.js +15 -4
- package/lib/node/step.js +4 -4
- package/lib/node/subDerivation.js +4 -4
- package/lib/node/subproof.js +4 -4
- package/lib/node/substitution/frame.js +6 -6
- package/lib/node/substitution/statement.js +6 -6
- package/lib/node/substitution/term.js +6 -6
- package/lib/node/substitution.js +107 -0
- package/lib/node/supposition.js +4 -4
- package/lib/node/term.js +27 -4
- package/lib/node/theorem.js +6 -6
- package/lib/node/type.js +4 -4
- package/lib/node/typePrefix.js +4 -4
- package/lib/node/types.js +4 -4
- package/lib/node/variable.js +4 -4
- package/lib/nominal/parser.js +3 -3
- package/lib/nonTerminalNode.js +222 -0
- package/lib/nonTerminalNodeMap.js +5 -3
- package/lib/ontology/assertion/contained.js +8 -9
- package/lib/ontology/assertion/defined.js +9 -10
- package/lib/ontology/assertion/satisfies.js +4 -4
- package/lib/ontology/assumption.js +379 -0
- package/lib/ontology/declaration/combinator.js +75 -33
- package/lib/ontology/declaration/complexType.js +110 -63
- package/lib/ontology/declaration/constructor.js +81 -38
- package/lib/ontology/declaration/metavariable.js +87 -39
- package/lib/ontology/declaration/simpleType.js +95 -48
- package/lib/ontology/declaration/typePrefix.js +87 -40
- package/lib/ontology/declaration/variable.js +87 -39
- package/lib/ontology/declaration.js +13 -338
- package/lib/ontology/equivalence.js +295 -0
- package/lib/ontology/equivalences.js +264 -0
- package/lib/ontology/frame.js +49 -54
- package/lib/ontology/judgement.js +8 -8
- package/lib/ontology/metavariable.js +4 -4
- package/lib/ontology/premise.js +14 -5
- package/lib/ontology/reference.js +3 -9
- package/lib/ontology/rule.js +3 -4
- package/lib/ontology/statement.js +28 -24
- package/lib/ontology/step.js +2 -3
- package/lib/ontology/subproof.js +2 -3
- package/lib/ontology/substitution/statement.js +77 -36
- package/lib/ontology/substitution/term.js +14 -34
- package/lib/ontology/substitution.js +18 -19
- package/lib/ontology/substitutions.js +425 -0
- package/lib/ontology/supposition.js +14 -5
- package/lib/ontology/term.js +33 -36
- package/lib/ontology/topLevelAssertion.js +2 -3
- package/lib/ontology/topLevelMetaAssertion.js +2 -3
- package/lib/ontology/variable.js +1 -34
- package/lib/preamble.js +7 -4
- package/lib/ruleNames.js +20 -12
- package/lib/unifier/intrinsicLevel.js +4 -12
- package/lib/unifier/metaLevel.js +14 -22
- package/lib/utilities/frame.js +18 -0
- package/lib/utilities/statement.js +18 -0
- package/lib/utilities/substitutions.js +43 -30
- package/lib/utilities/variable.js +5 -17
- package/package.json +10 -10
- package/src/assignment/equality.js +1 -1
- package/src/context/file.js +5 -4
- package/src/context/local.js +28 -5
- package/src/context/partial.js +9 -14
- package/src/context/temporary.js +120 -51
- package/src/mixins/step/unify.js +4 -4
- package/src/node/argument.js +1 -1
- package/src/node/assertion/contained.js +3 -3
- package/src/node/assertion/defined.js +3 -3
- package/src/node/assertion/property.js +3 -3
- package/src/node/assertion/satisfies.js +3 -3
- package/src/node/assertion/subproof.js +3 -3
- package/src/node/assertion/type.js +3 -3
- package/src/node/assertion.js +7 -0
- package/src/node/assumption.js +35 -0
- package/src/node/axiom.js +3 -3
- package/src/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +2 -2
- package/src/node/body.js +1 -3
- package/src/node/combinator.js +1 -1
- package/src/node/conclusion.js +1 -1
- package/src/node/conjecture.js +3 -3
- package/src/node/constructor.js +1 -1
- package/src/node/declaration/combinator.js +3 -3
- package/src/node/declaration/complexType.js +3 -3
- package/src/node/declaration/constructor.js +3 -3
- package/src/node/declaration/metavariable.js +3 -3
- package/src/node/declaration/property.js +3 -3
- package/src/node/declaration/simpleType.js +3 -3
- package/src/node/declaration/typePrefix.js +3 -3
- package/src/node/declaration/variable.js +3 -3
- package/src/node/declaration.js +2 -18
- package/src/node/deduction.js +1 -1
- package/src/node/derivation.js +1 -1
- package/src/node/document.js +7 -0
- package/src/node/equality.js +1 -1
- package/src/node/error.js +1 -1
- package/src/node/frame.js +23 -11
- package/src/node/header.js +1 -1
- package/src/node/hypothesis.js +1 -1
- package/src/node/judgement.js +6 -6
- package/src/node/label.js +1 -1
- package/src/node/labels.js +1 -1
- package/src/node/lemma.js +3 -3
- package/src/node/metaArgument.js +1 -1
- package/src/node/metaLemma.js +3 -3
- package/src/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +2 -2
- package/src/node/metaType.js +1 -1
- package/src/node/metatheorem.js +3 -3
- package/src/node/metavariable.js +1 -1
- package/src/node/nonsense.js +1 -1
- package/src/node/parameter.js +1 -1
- package/src/node/parenthesisedLabel.js +1 -1
- package/src/node/parenthesisedLabels.js +1 -1
- package/src/node/placeholder.js +7 -0
- package/src/node/premise.js +1 -1
- package/src/node/procedureCall.js +1 -1
- package/src/node/procedureReference.js +1 -1
- package/src/node/proof.js +1 -1
- package/src/node/property.js +1 -1
- package/src/node/propertyRelation.js +1 -1
- package/src/node/qualification.js +1 -1
- package/src/node/reference.js +1 -1
- package/src/node/rule.js +2 -2
- package/src/node/section.js +1 -1
- package/src/node/signature.js +1 -1
- package/src/node/statement.js +13 -1
- package/src/node/step.js +1 -1
- package/src/node/subDerivation.js +1 -1
- package/src/node/subproof.js +1 -1
- package/src/node/substitution/frame.js +3 -3
- package/src/node/substitution/statement.js +3 -3
- package/src/node/substitution/term.js +3 -3
- package/src/node/substitution.js +7 -0
- package/src/node/supposition.js +1 -1
- package/src/node/term.js +27 -1
- package/src/node/theorem.js +3 -3
- package/src/node/type.js +1 -1
- package/src/node/typePrefix.js +1 -1
- package/src/node/types.js +1 -1
- package/src/node/variable.js +1 -1
- package/src/nominal/parser.js +2 -2
- package/src/{node/nonTerminal.js → nonTerminalNode.js} +31 -25
- package/src/nonTerminalNodeMap.js +10 -5
- package/src/ontology/assertion/contained.js +14 -14
- package/src/ontology/assertion/defined.js +13 -13
- package/src/ontology/assertion/satisfies.js +2 -1
- package/src/ontology/assumption.js +385 -0
- package/src/ontology/declaration/combinator.js +15 -24
- package/src/ontology/declaration/complexType.js +57 -53
- package/src/ontology/declaration/constructor.js +25 -31
- package/src/ontology/declaration/metavariable.js +25 -30
- package/src/ontology/declaration/simpleType.js +34 -38
- package/src/ontology/declaration/typePrefix.js +23 -31
- package/src/ontology/declaration/variable.js +26 -31
- package/src/ontology/declaration.js +8 -372
- package/src/{equivalence.js → ontology/equivalence.js} +4 -3
- package/src/{equivalences.js → ontology/equivalences.js} +14 -12
- package/src/ontology/frame.js +53 -63
- package/src/ontology/judgement.js +8 -8
- package/src/ontology/metavariable.js +2 -2
- package/src/ontology/premise.js +18 -4
- package/src/ontology/reference.js +4 -3
- package/src/ontology/rule.js +4 -3
- package/src/ontology/statement.js +31 -27
- package/src/ontology/step.js +2 -2
- package/src/ontology/subproof.js +2 -2
- package/src/ontology/substitution/statement.js +56 -53
- package/src/ontology/substitution/term.js +9 -35
- package/src/ontology/substitution.js +11 -15
- package/src/{substitutions.js → ontology/substitutions.js} +4 -3
- package/src/ontology/supposition.js +18 -4
- package/src/ontology/term.js +27 -39
- package/src/ontology/topLevelAssertion.js +2 -2
- package/src/ontology/topLevelMetaAssertion.js +2 -2
- package/src/ontology/variable.js +0 -54
- package/src/preamble.js +6 -3
- package/src/ruleNames.js +10 -8
- package/src/unifier/intrinsicLevel.js +3 -14
- package/src/unifier/metaLevel.js +14 -25
- package/src/utilities/frame.js +13 -0
- package/src/utilities/statement.js +13 -0
- package/src/utilities/substitutions.js +59 -31
- package/src/utilities/variable.js +1 -10
- package/lib/equivalence.js +0 -294
- package/lib/equivalences.js +0 -263
- package/lib/node/nonTerminal.js +0 -218
- package/lib/substitutions.js +0 -424
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import ontology from "../../ontology";
|
|
4
4
|
import Assertion from "../assertion";
|
|
5
|
-
import TemporaryContext from "../../context/temporary";
|
|
6
5
|
|
|
7
6
|
import { define } from "../../ontology";
|
|
8
7
|
import { termFromTermAndSubstitutions, frameFromFrameAndSubstitutions } from "../../utilities/substitutions";
|
|
@@ -139,7 +138,10 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
139
138
|
|
|
140
139
|
context.trace(`Verifying the '${definedAssertionString}' derived defined assertion...`);
|
|
141
140
|
|
|
142
|
-
|
|
141
|
+
const generalContext = null,
|
|
142
|
+
specificContext = context; ///
|
|
143
|
+
|
|
144
|
+
verifiesWhenDerived = verifyWhenDerived(this.term, this.frame, this.negated, generalContext, specificContext);
|
|
143
145
|
|
|
144
146
|
if (verifiesWhenDerived) {
|
|
145
147
|
context.debug(`...verified the '${definedAssertionString}' derived defined assertion.`);
|
|
@@ -148,21 +150,17 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
148
150
|
return verifiesWhenDerived;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
unifyIndependently(substitutions,
|
|
153
|
+
unifyIndependently(substitutions, generalContext, specificContext) {
|
|
152
154
|
let unifiesIndependently;
|
|
153
155
|
|
|
154
|
-
const
|
|
156
|
+
const context = generalContext, ///
|
|
157
|
+
definedAssertionString = this.getString(); ///
|
|
155
158
|
|
|
156
159
|
context.trace(`Unifying the '${definedAssertionString}' defined assertion independently...`);
|
|
157
160
|
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
context = temporaryContext; ///
|
|
162
|
-
|
|
163
|
-
const term = termFromTermAndSubstitutions(this.term, substitutions, context),
|
|
164
|
-
frame = frameFromFrameAndSubstitutions(this.frame, substitutions, context),
|
|
165
|
-
verifiesWhenDerived = verifyWhenDerived(term, frame, this.negated, context);
|
|
161
|
+
const term = termFromTermAndSubstitutions(this.term, substitutions, generalContext, specificContext),
|
|
162
|
+
frame = frameFromFrameAndSubstitutions(this.frame, substitutions, generalContext, specificContext),
|
|
163
|
+
verifiesWhenDerived = verifyWhenDerived(term, frame, this.negated, generalContext, specificContext);
|
|
166
164
|
|
|
167
165
|
unifiesIndependently = verifiesWhenDerived; ///
|
|
168
166
|
|
|
@@ -196,9 +194,11 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
196
194
|
}
|
|
197
195
|
});
|
|
198
196
|
|
|
199
|
-
function verifyWhenDerived(term, frame, negated,
|
|
197
|
+
function verifyWhenDerived(term, frame, negated, generalContext, specificContext) {
|
|
200
198
|
let verifiesWhenDerived = false;
|
|
201
199
|
|
|
200
|
+
const context = specificContext; ///
|
|
201
|
+
|
|
202
202
|
if (term !== null) {
|
|
203
203
|
const { Variable } = ontology,
|
|
204
204
|
termNode = term.getNode(),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import ontology from "../../ontology";
|
|
4
4
|
import Assertion from "../assertion";
|
|
5
|
-
import Substitutions from "../../substitutions";
|
|
6
5
|
|
|
7
6
|
import { define } from "../../ontology";
|
|
8
7
|
|
|
@@ -98,6 +97,8 @@ export default define(class SatisfiesAssertion extends Assertion {
|
|
|
98
97
|
if (satisfiable) {
|
|
99
98
|
let substitutions;
|
|
100
99
|
|
|
100
|
+
const { Substitutions } = ontology;
|
|
101
|
+
|
|
101
102
|
substitutions = Substitutions.fromNothing();
|
|
102
103
|
|
|
103
104
|
const signatureMatches = axiom.matchSignature(this.signature, substitutions, context);
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import ontology from "../ontology";
|
|
4
|
+
|
|
5
|
+
import { define } from "../ontology";
|
|
6
|
+
import { unifyStatementIntrinsically } from "../utilities/unification";
|
|
7
|
+
import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
8
|
+
|
|
9
|
+
export default define(class Assumption {
|
|
10
|
+
constructor(string, node, statement, metavariable) {
|
|
11
|
+
this.string = string;
|
|
12
|
+
this.node = node;
|
|
13
|
+
this.statement = statement;
|
|
14
|
+
this.metavariable = metavariable;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getString() {
|
|
18
|
+
return this.string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getNode() {
|
|
22
|
+
return this.node;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getStatement() {
|
|
26
|
+
return this.statement;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getMetavariable() {
|
|
30
|
+
return this.metavariable;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
isSimple() {
|
|
34
|
+
const simple = (this.statement === null);
|
|
35
|
+
|
|
36
|
+
return simple;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
matchSubstitution(substitution, context) {
|
|
40
|
+
let substitutionMatches = false;
|
|
41
|
+
|
|
42
|
+
const assumptionString = this.string, ///
|
|
43
|
+
substitutionString = substitution.getString();
|
|
44
|
+
|
|
45
|
+
context.trace(`Matching the '${substitutionString}' substitution against the '${assumptionString}' assumption...`);
|
|
46
|
+
|
|
47
|
+
const simple = this.isSimple();
|
|
48
|
+
|
|
49
|
+
if (simple) {
|
|
50
|
+
const judgement = context.findJudgementByMetavariable(this.metavariable);
|
|
51
|
+
|
|
52
|
+
if (judgement !== null) {
|
|
53
|
+
const assumption = judgement.getDeclaration();
|
|
54
|
+
|
|
55
|
+
substitutionMatches = assumption.matchSubstitution(substitution, context);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
const statement = substitution.getStatement(),
|
|
59
|
+
metavariable = substitution.getMetavariable(),
|
|
60
|
+
statementEqualToStatement = this.statement.isEqualTo(statement),
|
|
61
|
+
metavariableEqualToMetavariable = this.metavariable.isEqualTo(metavariable);
|
|
62
|
+
|
|
63
|
+
if (metavariableEqualToMetavariable && statementEqualToStatement) {
|
|
64
|
+
substitutionMatches = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (substitutionMatches) {
|
|
69
|
+
context.debug(`...matches the '${assumptionString}' substitution against the '${substitutionString}' assumption.`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return substitutionMatches;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
verify(assignments, stated, context) {
|
|
76
|
+
let verifies = false;
|
|
77
|
+
|
|
78
|
+
const assumptionString = this.string; ///
|
|
79
|
+
|
|
80
|
+
context.trace(`Verifying the '${assumptionString}' assumption...`);
|
|
81
|
+
|
|
82
|
+
const simple = this.isSimple();
|
|
83
|
+
|
|
84
|
+
if (simple) {
|
|
85
|
+
const verifiesAsMetavariable = this.verifyAsMetavariable(assignments, stated, context);
|
|
86
|
+
|
|
87
|
+
verifies = verifiesAsMetavariable; ///
|
|
88
|
+
} else {
|
|
89
|
+
const metavariableVerifiesAsReference = this.verifyMetavariableAsReference(assignments, stated, context);
|
|
90
|
+
|
|
91
|
+
if (metavariableVerifiesAsReference) {
|
|
92
|
+
const statementVerifies = this.verifyStatement(assignments, stated, context);
|
|
93
|
+
|
|
94
|
+
if (statementVerifies) {
|
|
95
|
+
let verifiesWhenStated = false,
|
|
96
|
+
verifiesWhenDerived = false;
|
|
97
|
+
|
|
98
|
+
if (stated) {
|
|
99
|
+
verifiesWhenStated = this.verifyWhenStated(assignments, context);
|
|
100
|
+
} else {
|
|
101
|
+
verifiesWhenDerived = this.verifyWhenDerived(context);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (verifiesWhenStated || verifiesWhenDerived) {
|
|
105
|
+
verifies = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (verifies) {
|
|
111
|
+
context.debug(`...verified the '${assumptionString}' assumption.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return verifies;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
verifyMetavariableAsReference(assignments, stated, context) {
|
|
119
|
+
let metavariableVerifiesAsReference;
|
|
120
|
+
|
|
121
|
+
const assumptionString = this.string,
|
|
122
|
+
metavariableString = this.metavariable.getString();
|
|
123
|
+
|
|
124
|
+
context.trace(`Verifying the '${assumptionString}' assumption's '${metavariableString}' metavariable as a reference...`);
|
|
125
|
+
|
|
126
|
+
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
127
|
+
referenceVerifies = reference.verify(context);
|
|
128
|
+
|
|
129
|
+
metavariableVerifiesAsReference = referenceVerifies; ///
|
|
130
|
+
|
|
131
|
+
if (metavariableVerifiesAsReference) {
|
|
132
|
+
context.debug(`...verified the '${assumptionString}' assumption's '${metavariableString}' metavariable as a reference.`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return metavariableVerifiesAsReference;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
verifyStatement(assignments, stated, context) {
|
|
139
|
+
let statementVerifies;
|
|
140
|
+
|
|
141
|
+
if (this.statement === null) {
|
|
142
|
+
statementVerifies = true;
|
|
143
|
+
} else {
|
|
144
|
+
const statementString = this.statement.getString();
|
|
145
|
+
|
|
146
|
+
context.trace(`Verifying the '${statementString}' statement...`);
|
|
147
|
+
|
|
148
|
+
stated = true; ///
|
|
149
|
+
|
|
150
|
+
assignments = null; ///
|
|
151
|
+
|
|
152
|
+
statementVerifies = this.statement.verify(assignments, stated, context);
|
|
153
|
+
|
|
154
|
+
if (statementVerifies) {
|
|
155
|
+
context.debug(`...verified the '${statementString}' statement.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return statementVerifies;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
verifyAsMetavariable(assignments, stated, context) {
|
|
163
|
+
let verifiesAsMetavariable;
|
|
164
|
+
|
|
165
|
+
const assumptionString = this.string, ///
|
|
166
|
+
metavariableString = this.metavariable.getString();
|
|
167
|
+
|
|
168
|
+
context.trace(`Verifying the '${assumptionString}' assumption's '${metavariableString}' metavariable...`);
|
|
169
|
+
|
|
170
|
+
verifiesAsMetavariable = this.metavariable.verify(context);
|
|
171
|
+
|
|
172
|
+
if (verifiesAsMetavariable) {
|
|
173
|
+
context.debug(`...verified the '${assumptionString}' assumption's '${metavariableString}' metavariable.`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return verifiesAsMetavariable;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
verifyWhenStated(assignments, context) {
|
|
180
|
+
let verifiesWhenStated;
|
|
181
|
+
|
|
182
|
+
const assumptionString = this.string; ///
|
|
183
|
+
|
|
184
|
+
context.trace(`Verifying the '${assumptionString}' stated assumption...`);
|
|
185
|
+
|
|
186
|
+
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
187
|
+
metavariablePresent = context.isMetavariablePresentByReference(reference);
|
|
188
|
+
|
|
189
|
+
if (metavariablePresent) {
|
|
190
|
+
verifiesWhenStated = true;
|
|
191
|
+
} else {
|
|
192
|
+
const metaLemmaMetatheorems = context.findMetaLemmaMetatheoremsByReference(reference),
|
|
193
|
+
metaLemmaMetatheoremsUnify = metaLemmaMetatheorems.every((metaLemmaMetatheorem) => {
|
|
194
|
+
const metaLemmaMetatheoremUnifies = this.unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context);
|
|
195
|
+
|
|
196
|
+
if (metaLemmaMetatheoremUnifies) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
verifiesWhenStated = metaLemmaMetatheoremsUnify; ///
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (verifiesWhenStated) {
|
|
205
|
+
context.debug(`...verified the '${assumptionString}' stated assumption.`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return verifiesWhenStated;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
verifyWhenDerived(context) {
|
|
212
|
+
let verifiesWhenDerived;
|
|
213
|
+
|
|
214
|
+
const assumptionString = this.string; ///
|
|
215
|
+
|
|
216
|
+
context.trace(`Verifying the '${assumptionString}' derived assumption...`);
|
|
217
|
+
|
|
218
|
+
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
219
|
+
metaLemmaMetatheoremPresent = context.isMetaLemmaMetatheoremPresentByReference(reference);
|
|
220
|
+
|
|
221
|
+
verifiesWhenDerived = metaLemmaMetatheoremPresent; ///
|
|
222
|
+
|
|
223
|
+
if (verifiesWhenDerived) {
|
|
224
|
+
context.debug(`...verified the '${assumptionString}' derived assumption.`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return verifiesWhenDerived;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
231
|
+
let statementUnifies;
|
|
232
|
+
|
|
233
|
+
const simple = this.isSimple();
|
|
234
|
+
|
|
235
|
+
if (simple) {
|
|
236
|
+
statementUnifies = false;
|
|
237
|
+
} else {
|
|
238
|
+
const context = generalContext, ///
|
|
239
|
+
statementString = statement.getString(),
|
|
240
|
+
assumptionStatementString = this.statement.getString();
|
|
241
|
+
|
|
242
|
+
context.trace(`Unifying the '${statementString}' statement with the '${assumptionStatementString}' statement...`);
|
|
243
|
+
|
|
244
|
+
const generalStatement = this.statement,
|
|
245
|
+
specificStatement = statement, ///
|
|
246
|
+
statementUUnifiesIntrinsically = unifyStatementIntrinsically(generalStatement, specificStatement, substitutions, generalContext, specificContext);
|
|
247
|
+
|
|
248
|
+
statementUnifies = statementUUnifiesIntrinsically; ///
|
|
249
|
+
|
|
250
|
+
if (statementUnifies) {
|
|
251
|
+
context.debug(`...unified the '${statementString}' statement with the '${assumptionStatementString}' statement.`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return statementUnifies;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
unifyLabel(label, substitutions, generalContext, specificContext) {
|
|
259
|
+
let labelUnifiesWithReference;
|
|
260
|
+
|
|
261
|
+
const context = generalContext, ///
|
|
262
|
+
labelString = label.getString(),
|
|
263
|
+
assumptionString = this.string; //;/
|
|
264
|
+
|
|
265
|
+
context.trace(`Unifying the '${labelString}' label with the '${assumptionString}' assumption...`);
|
|
266
|
+
|
|
267
|
+
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
268
|
+
labelUnifies = reference.unifyLabel(label, substitutions, context);
|
|
269
|
+
|
|
270
|
+
labelUnifiesWithReference = labelUnifies; ///
|
|
271
|
+
|
|
272
|
+
if (labelUnifiesWithReference) {
|
|
273
|
+
context.debug(`...unified the '${labelString}' label with the '${assumptionString}' assumption.`);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return labelUnifiesWithReference;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context) {
|
|
280
|
+
let metaLemmaMetatheoremUnifies = false;
|
|
281
|
+
|
|
282
|
+
const assumptionString = this.string, ///
|
|
283
|
+
metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
|
|
284
|
+
|
|
285
|
+
context.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${assumptionString}' assumption...`);
|
|
286
|
+
|
|
287
|
+
const generalContext = context; ///
|
|
288
|
+
|
|
289
|
+
context = metaLemmaMetatheorem.getContext(); ///
|
|
290
|
+
|
|
291
|
+
const { Substitutions } = ontology,
|
|
292
|
+
specificContext = context, ///
|
|
293
|
+
labelSubstitutions = Substitutions.fromNothing(),
|
|
294
|
+
label = metaLemmaMetatheorem.getLabel(),
|
|
295
|
+
substitutions = labelSubstitutions, ///
|
|
296
|
+
labelUnifies = this.unifyLabel(label, substitutions, generalContext, specificContext);
|
|
297
|
+
|
|
298
|
+
if (labelUnifies) {
|
|
299
|
+
const statementSubstitutions = Substitutions.fromNothing(),
|
|
300
|
+
statement = metaLemmaMetatheorem.getStatement(),
|
|
301
|
+
substitutions = statementSubstitutions, ///
|
|
302
|
+
statementUUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
303
|
+
|
|
304
|
+
if (statementUUnifies) {
|
|
305
|
+
const labelSubstitutionsCorrelateStatementSubstitutions = labelSubstitutions.correlateSubstitutions(statementSubstitutions);
|
|
306
|
+
|
|
307
|
+
if (labelSubstitutionsCorrelateStatementSubstitutions) {
|
|
308
|
+
metaLemmaMetatheoremUnifies = true; ///
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (metaLemmaMetatheoremUnifies) {
|
|
314
|
+
context = generalContext; ///
|
|
315
|
+
|
|
316
|
+
context.trace(`...unified the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${assumptionString}' assumption...`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return metaLemmaMetatheoremUnifies;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
toJSON() {
|
|
323
|
+
let json = null;
|
|
324
|
+
|
|
325
|
+
const simple = this.isSimple();
|
|
326
|
+
|
|
327
|
+
if (simple) {
|
|
328
|
+
const metavariable = this.getMetavariable(),
|
|
329
|
+
metavariableJSON = metavariableToMetavariableJSON(metavariable);
|
|
330
|
+
|
|
331
|
+
json = metavariableJSON; ///
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return json;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
static name = "Assumption";
|
|
338
|
+
|
|
339
|
+
static fromJSON(json, context) {
|
|
340
|
+
let assumption = null;
|
|
341
|
+
|
|
342
|
+
if (json !== null) {
|
|
343
|
+
const string = null,
|
|
344
|
+
node = null,
|
|
345
|
+
statement = null,
|
|
346
|
+
metavariable = metavariableFromJSON(json, context);
|
|
347
|
+
|
|
348
|
+
assumption = new Assumption(string, node, statement, metavariable)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return assumption;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
static fromJudgementNode(judgementNode, context) {
|
|
355
|
+
const assumptionNode = judgementNode.getAssumptionNode(),
|
|
356
|
+
assumption = assumptionFromAssumptionNode(assumptionNode, context);
|
|
357
|
+
|
|
358
|
+
return assumption;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
static fromAssumptionNode(assumptionNode, context) {
|
|
362
|
+
const assumption = assumptionFromAssumptionNode(assumptionNode, context);
|
|
363
|
+
|
|
364
|
+
return assumption;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
function referenceFromMetavariable(metavariable, context) {
|
|
369
|
+
const { Reference } = ontology,
|
|
370
|
+
metavariableNode = metavariable.getNode(),
|
|
371
|
+
reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
372
|
+
|
|
373
|
+
return reference;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function assumptionFromAssumptionNode(assumptionNode, context) {
|
|
377
|
+
const { Metavariable, Assumption, Statement } = ontology,
|
|
378
|
+
node = assumptionNode, ///
|
|
379
|
+
string = context.nodeAsString(node),
|
|
380
|
+
statement = Statement.fromAssumptionNode(assumptionNode, context),
|
|
381
|
+
metavariable = Metavariable.fromAssumptionNode(assumptionNode, context),
|
|
382
|
+
assumption = new Assumption(string, node, statement, metavariable);
|
|
383
|
+
|
|
384
|
+
return assumption;
|
|
385
|
+
}
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import ontology from "../../ontology";
|
|
4
|
+
import Declaration from "../declaration";
|
|
4
5
|
|
|
5
6
|
import { define } from "../../ontology";
|
|
6
7
|
|
|
7
8
|
import combinatorVerifier from "../../verifier/combinator";
|
|
8
9
|
|
|
9
|
-
export default define(class CombinatorDeclaration {
|
|
10
|
+
export default define(class CombinatorDeclaration extends Declaration {
|
|
10
11
|
constructor(context, node, string, combinator) {
|
|
11
|
-
|
|
12
|
-
this.node = node;
|
|
13
|
-
this.string = string;
|
|
12
|
+
super(context, node, string);
|
|
14
13
|
this.combinator = combinator;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
getContext() {
|
|
18
|
-
return this.context;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getNode() {
|
|
22
|
-
return this.node;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getString() {
|
|
26
|
-
return this.string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
16
|
getCombinator() {
|
|
30
17
|
return this.combinator;
|
|
31
18
|
}
|
|
@@ -33,20 +20,22 @@ export default define(class CombinatorDeclaration {
|
|
|
33
20
|
verify() {
|
|
34
21
|
let verifies = false;
|
|
35
22
|
|
|
36
|
-
const
|
|
23
|
+
const node = this.getNode(),
|
|
24
|
+
context = this.getContext(),
|
|
25
|
+
combinatorDeclarationString = this.getString(); ///
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
context.trace(`Verifying the '${combinatorDeclarationString}' combinator declaration...`, node);
|
|
39
28
|
|
|
40
29
|
const combinatorVerifies = this.verifyCombinator();
|
|
41
30
|
|
|
42
31
|
if (combinatorVerifies) {
|
|
43
|
-
|
|
32
|
+
context.addCombinator(this.combinator);
|
|
44
33
|
|
|
45
34
|
verifies = true;
|
|
46
35
|
}
|
|
47
36
|
|
|
48
37
|
if (verifies) {
|
|
49
|
-
|
|
38
|
+
context.debug(`...verified the '${combinatorDeclarationString}' combinator declaration.`, node);
|
|
50
39
|
}
|
|
51
40
|
|
|
52
41
|
return verifies;
|
|
@@ -55,17 +44,19 @@ export default define(class CombinatorDeclaration {
|
|
|
55
44
|
verifyCombinator() {
|
|
56
45
|
let statementVerifies;
|
|
57
46
|
|
|
58
|
-
const
|
|
47
|
+
const node = this.getNode(),
|
|
48
|
+
context = this.getContext(),
|
|
49
|
+
combinatorString = this.combinator.getString();
|
|
59
50
|
|
|
60
|
-
|
|
51
|
+
context.trace(`Verifying the '${combinatorString}' combinator...`, node);
|
|
61
52
|
|
|
62
53
|
const statement = this.combinator.getStatement(),
|
|
63
54
|
statementNode = statement.getNode();
|
|
64
55
|
|
|
65
|
-
statementVerifies = combinatorVerifier.verifyStatement(statementNode,
|
|
56
|
+
statementVerifies = combinatorVerifier.verifyStatement(statementNode, context);
|
|
66
57
|
|
|
67
58
|
if (statementVerifies) {
|
|
68
|
-
|
|
59
|
+
context.debug(`...verified the '${combinatorString}' combinator.`, node);
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
return statementVerifies;
|