occam-verify-cli 0.0.1111 → 0.0.1114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/combinator/bracketed.js +15 -65
- package/lib/combinator.js +4 -8
- package/lib/constructor/bracketed.js +24 -101
- package/lib/constructor.js +4 -8
- package/lib/context/file.js +41 -12
- package/lib/context/local.js +45 -25
- package/lib/context/release.js +2 -2
- package/lib/dom/assertion/contained.js +287 -0
- package/lib/dom/assertion/defined.js +266 -0
- package/lib/dom/assertion/subproof.js +210 -0
- package/lib/dom/assertion/type.js +240 -0
- package/lib/{axiom.js → dom/axiom.js} +18 -8
- package/lib/dom/conclusion.js +171 -0
- package/lib/{conjecture.js → dom/conjecture.js} +18 -8
- package/lib/dom/consequent.js +171 -0
- package/lib/dom/declaration/combinator.js +105 -0
- package/lib/dom/declaration/constructor.js +140 -0
- package/lib/dom/declaration/metavariable.js +154 -0
- package/lib/dom/declaration/type.js +140 -0
- package/lib/dom/declaration/variable.js +155 -0
- package/lib/{declaration.js → dom/declaration.js} +62 -18
- package/lib/dom/derivation.js +137 -0
- package/lib/dom/equality.js +260 -0
- package/lib/dom/error.js +85 -0
- package/lib/dom/frame.js +372 -0
- package/lib/dom/judgement.js +198 -0
- package/lib/dom/label.js +190 -0
- package/lib/{lemma.js → dom/lemma.js} +19 -9
- package/lib/{metaLemma.js → dom/metaLemma.js} +19 -9
- package/lib/dom/metaType.js +261 -0
- package/lib/dom/metatheorem.js +273 -0
- package/lib/dom/metavariable.js +463 -0
- package/lib/dom/premise.js +221 -0
- package/lib/dom/proof.js +154 -0
- package/lib/dom/proofStep.js +239 -0
- package/lib/dom/reference.js +218 -0
- package/lib/dom/rule.js +311 -0
- package/lib/dom/statement.js +379 -0
- package/lib/dom/subDerivation.js +137 -0
- package/lib/dom/subproof.js +211 -0
- package/lib/dom/supposition.js +221 -0
- package/lib/dom/term.js +354 -0
- package/lib/{theorem.js → dom/theorem.js} +18 -8
- package/lib/dom/topLevelAssertion.js +306 -0
- package/lib/dom/type.js +327 -0
- package/lib/dom/variable.js +328 -0
- package/lib/dom.js +27 -0
- package/lib/equivalences.js +307 -0
- package/lib/index.js +40 -35
- package/lib/mixins/proofStep/unify.js +86 -0
- package/lib/mixins/statement/verify.js +27 -2
- package/lib/mixins/term/verify.js +24 -4
- package/lib/substitution/frame.js +3 -3
- package/lib/substitution/statement.js +17 -16
- package/lib/substitution/term.js +10 -7
- package/lib/substitution.js +4 -31
- package/lib/substitutions.js +24 -56
- package/lib/unifier/equality.js +2 -3
- package/lib/unifier/label.js +3 -3
- package/lib/unifier/metaLevel.js +9 -8
- package/lib/unifier/metavariable.js +3 -3
- package/lib/unifier/statementWithCombinator.js +5 -5
- package/lib/unifier/termWithConstructor.js +3 -3
- package/lib/utilities/json.js +26 -40
- package/lib/utilities/string.js +6 -8
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/substitutions.js +7 -6
- package/lib/utilities/verification.js +22 -14
- package/lib/verifier/combinator.js +4 -4
- package/lib/verifier/constructor.js +3 -3
- package/lib/verifier/topLevel.js +15 -21
- package/package.json +1 -1
- package/src/combinator/bracketed.js +11 -4
- package/src/combinator.js +3 -10
- package/src/constructor/bracketed.js +17 -5
- package/src/constructor.js +3 -9
- package/src/context/file.js +42 -11
- package/src/context/local.js +26 -34
- package/src/context/release.js +1 -1
- package/src/{assertion → dom/assertion}/contained.js +11 -8
- package/src/{assertion → dom/assertion}/defined.js +14 -11
- package/src/{assertion → dom/assertion}/subproof.js +11 -62
- package/src/{assertion → dom/assertion}/type.js +11 -8
- package/src/{axiom.js → dom/axiom.js} +6 -9
- package/src/dom/conclusion.js +95 -0
- package/src/{conjecture.js → dom/conjecture.js} +5 -8
- package/src/dom/consequent.js +95 -0
- package/src/{declaration → dom/declaration}/combinator.js +8 -5
- package/src/{declaration → dom/declaration}/constructor.js +8 -4
- package/src/{declaration → dom/declaration}/metavariable.js +8 -5
- package/src/{declaration → dom/declaration}/type.js +8 -4
- package/src/{declaration → dom/declaration}/variable.js +9 -6
- package/src/{declaration.js → dom/declaration.js} +11 -16
- package/src/{derivation.js → dom/derivation.js} +9 -12
- package/src/{equality.js → dom/equality.js} +11 -14
- package/src/{error.js → dom/error.js} +6 -3
- package/src/{frame.js → dom/frame.js} +14 -23
- package/src/{judgement.js → dom/judgement.js} +8 -11
- package/src/{label.js → dom/label.js} +9 -16
- package/src/{lemma.js → dom/lemma.js} +5 -9
- package/src/{metaLemma.js → dom/metaLemma.js} +6 -9
- package/src/{metaType.js → dom/metaType.js} +7 -10
- package/src/{metatheorem.js → dom/metatheorem.js} +6 -10
- package/src/{metavariable.js → dom/metavariable.js} +79 -77
- package/src/dom/premise.js +173 -0
- package/src/{proof.js → dom/proof.js} +8 -11
- package/src/dom/proofStep.js +173 -0
- package/src/{reference.js → dom/reference.js} +48 -20
- package/src/{rule.js → dom/rule.js} +13 -17
- package/src/{statement.js → dom/statement.js} +142 -71
- package/src/{subDerivation.js → dom/subDerivation.js} +9 -12
- package/src/{subproof.js → dom/subproof.js} +14 -47
- package/src/dom/supposition.js +173 -0
- package/src/{term.js → dom/term.js} +24 -45
- package/src/{theorem.js → dom/theorem.js} +5 -8
- package/src/{topLevelAssertion.js → dom/topLevelAssertion.js} +12 -14
- package/src/{type.js → dom/type.js} +9 -12
- package/src/{variable.js → dom/variable.js} +20 -28
- package/src/dom.js +13 -0
- package/src/equivalences.js +278 -0
- package/src/index.js +39 -34
- package/src/mixins/proofStep/unify.js +115 -0
- package/src/mixins/statement/verify.js +33 -1
- package/src/mixins/term/verify.js +33 -3
- package/src/substitution/frame.js +2 -2
- package/src/substitution/statement.js +20 -18
- package/src/substitution/term.js +12 -5
- package/src/substitution.js +4 -29
- package/src/substitutions.js +35 -73
- package/src/unifier/equality.js +1 -2
- package/src/unifier/label.js +2 -2
- package/src/unifier/metaLevel.js +9 -7
- package/src/unifier/metavariable.js +2 -2
- package/src/unifier/statementWithCombinator.js +4 -4
- package/src/unifier/termWithConstructor.js +2 -2
- package/src/utilities/json.js +23 -42
- package/src/utilities/string.js +8 -6
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/substitutions.js +7 -5
- package/src/utilities/verification.js +29 -13
- package/src/verifier/combinator.js +3 -3
- package/src/verifier/constructor.js +3 -3
- package/src/verifier/topLevel.js +20 -21
- package/lib/assertion/contained.js +0 -232
- package/lib/assertion/defined.js +0 -211
- package/lib/assertion/subproof.js +0 -203
- package/lib/assertion/type.js +0 -185
- package/lib/conclusion.js +0 -130
- package/lib/consequent.js +0 -130
- package/lib/declaration/combinator.js +0 -90
- package/lib/declaration/constructor.js +0 -90
- package/lib/declaration/metavariable.js +0 -104
- package/lib/declaration/type.js +0 -90
- package/lib/declaration/variable.js +0 -105
- package/lib/derivation.js +0 -91
- package/lib/equality.js +0 -209
- package/lib/error.js +0 -70
- package/lib/frame.js +0 -331
- package/lib/judgement.js +0 -147
- package/lib/label.js +0 -141
- package/lib/metaType.js +0 -255
- package/lib/metatheorem.js +0 -263
- package/lib/metavariable.js +0 -399
- package/lib/mixins/statement/qualified/unify.js +0 -69
- package/lib/mixins/statement/unify.js +0 -42
- package/lib/mixins/statement/unifyIndependenntly.js +0 -46
- package/lib/mixins/term/unify.js +0 -40
- package/lib/premise.js +0 -184
- package/lib/proof.js +0 -103
- package/lib/proofStep.js +0 -179
- package/lib/reference.js +0 -145
- package/lib/rule.js +0 -259
- package/lib/shim.js +0 -14
- package/lib/statement/qualified.js +0 -152
- package/lib/statement/unqualified.js +0 -175
- package/lib/statement.js +0 -270
- package/lib/subDerivation.js +0 -91
- package/lib/subproof.js +0 -181
- package/lib/supposition.js +0 -184
- package/lib/term.js +0 -318
- package/lib/topLevelAssertion.js +0 -305
- package/lib/type.js +0 -321
- package/lib/utilities/equivalences.js +0 -178
- package/lib/variable.js +0 -281
- package/src/conclusion.js +0 -96
- package/src/consequent.js +0 -96
- package/src/mixins/statement/qualified/unify.js +0 -103
- package/src/mixins/statement/unify.js +0 -41
- package/src/mixins/statement/unifyIndependenntly.js +0 -58
- package/src/mixins/term/unify.js +0 -36
- package/src/premise.js +0 -183
- package/src/proofStep.js +0 -181
- package/src/shim.js +0 -5
- package/src/statement/qualified.js +0 -133
- package/src/statement/unqualified.js +0 -166
- package/src/supposition.js +0 -183
- package/src/utilities/equivalences.js +0 -183
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
|
|
5
|
+
import { domAssigned } from "../dom";
|
|
6
|
+
import { assignAssignments } from "../utilities/assignments";
|
|
7
|
+
import { subproofAssertionFromStatement } from "../utilities/verification";
|
|
8
|
+
import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
|
|
9
|
+
|
|
10
|
+
export default domAssigned(class Premise {
|
|
11
|
+
constructor(string, statement) {
|
|
12
|
+
this.string = string;
|
|
13
|
+
this.statement = statement;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getString() {
|
|
17
|
+
return this.string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getStatement() {
|
|
21
|
+
return this.statement;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
unifyIndependently(substitutions, generalContext, specificContext) {
|
|
25
|
+
let unifiedIndependently;
|
|
26
|
+
|
|
27
|
+
const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
|
|
28
|
+
|
|
29
|
+
unifiedIndependently = statementResolvedIndependently; ///
|
|
30
|
+
|
|
31
|
+
return unifiedIndependently;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
unifyProofStep(proofStep, substitutions, generalContext, specificContext) {
|
|
35
|
+
let proofStepUnified = false;
|
|
36
|
+
|
|
37
|
+
const subproof = proofStep.getSubproof(),
|
|
38
|
+
statement = proofStep.getStatement();
|
|
39
|
+
|
|
40
|
+
substitutions.snapshot();
|
|
41
|
+
|
|
42
|
+
if (subproof !== null) {
|
|
43
|
+
const subproofUnified = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
44
|
+
|
|
45
|
+
proofStepUnified = subproofUnified; ///
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (statement !== null) {
|
|
49
|
+
const statementUnified = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
50
|
+
|
|
51
|
+
proofStepUnified = statementUnified; ///
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (proofStepUnified) {
|
|
55
|
+
substitutions.resolve(generalContext, specificContext);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const context = specificContext; ///
|
|
59
|
+
|
|
60
|
+
proofStepUnified ?
|
|
61
|
+
substitutions.continue() :
|
|
62
|
+
substitutions.rollback(context);
|
|
63
|
+
|
|
64
|
+
return proofStepUnified;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
68
|
+
let statementUnified;
|
|
69
|
+
|
|
70
|
+
const premise = this, ///
|
|
71
|
+
premiseString = premise.getString(),
|
|
72
|
+
statementString = statement.getString();
|
|
73
|
+
|
|
74
|
+
specificContext.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
75
|
+
|
|
76
|
+
statementUnified = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
77
|
+
|
|
78
|
+
if (statementUnified) {
|
|
79
|
+
specificContext.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return statementUnified;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
86
|
+
let subproofUnified = false;
|
|
87
|
+
|
|
88
|
+
const premise = this, ///
|
|
89
|
+
subproofString = subproof.getString(),
|
|
90
|
+
premiseStatement = premise.getStatement(),
|
|
91
|
+
premiseStatementString = premiseStatement.getString();
|
|
92
|
+
|
|
93
|
+
specificContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
94
|
+
|
|
95
|
+
const context = generalContext,
|
|
96
|
+
subproofAssertion = subproofAssertionFromStatement(this.statement, context);
|
|
97
|
+
|
|
98
|
+
if (subproofAssertion !== null) {
|
|
99
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (subproofUnified) {
|
|
103
|
+
specificContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return subproofUnified;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
verify(context) {
|
|
110
|
+
let verified = false;
|
|
111
|
+
|
|
112
|
+
const premiseString = this.string; ///
|
|
113
|
+
|
|
114
|
+
if (this.statement !== null) {
|
|
115
|
+
context.trace(`Verifying the '${premiseString}' premise...`);
|
|
116
|
+
|
|
117
|
+
const stated = true,
|
|
118
|
+
assignments = [],
|
|
119
|
+
statementVerified = this.statement.verify(assignments, stated, context);
|
|
120
|
+
|
|
121
|
+
if (statementVerified) {
|
|
122
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
123
|
+
|
|
124
|
+
if (assignmentsAssigned) {
|
|
125
|
+
const { ProofStep } = dom,
|
|
126
|
+
proofStep = ProofStep.fromStatement(this.statement, context);
|
|
127
|
+
|
|
128
|
+
context.addProofStep(proofStep);
|
|
129
|
+
|
|
130
|
+
verified = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (verified) {
|
|
135
|
+
context.debug(`...verified the '${premiseString}' premise.`);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
context.debug(`Unable to verify the '${premiseString}' premise because it is nonsense.`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return verified;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
toJSON() {
|
|
145
|
+
const statementJSON = statementToStatementJSON(this.statement),
|
|
146
|
+
statement = statementJSON, ///
|
|
147
|
+
json = {
|
|
148
|
+
statement
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return json;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static name = "Premise";
|
|
155
|
+
|
|
156
|
+
static fromJSON(json, fileContext) {
|
|
157
|
+
const statement = statementFromJSON(json, fileContext),
|
|
158
|
+
string = statement.getString(),
|
|
159
|
+
premise = new Premise(string, statement);
|
|
160
|
+
|
|
161
|
+
return premise;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static fromPremiseNode(premiseNode, fileContext) {
|
|
165
|
+
const { Statement } = dom,
|
|
166
|
+
statement = Statement.fromPremiseNode(premiseNode, fileContext),
|
|
167
|
+
statementString = statement.getString(),
|
|
168
|
+
string = statementString, ///
|
|
169
|
+
premise = new Premise(string, statement);
|
|
170
|
+
|
|
171
|
+
return premise
|
|
172
|
+
}
|
|
173
|
+
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import LocalContext from "
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
import LocalContext from "../context/local";
|
|
5
5
|
|
|
6
|
-
import { nodeQuery } from "
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { domAssigned } from "../dom";
|
|
7
8
|
|
|
8
9
|
const derivationNodeQuery = nodeQuery("/proof/derivation");
|
|
9
10
|
|
|
10
|
-
class Proof {
|
|
11
|
+
export default domAssigned(class Proof {
|
|
11
12
|
constructor(derivation) {
|
|
12
13
|
this.derivation = derivation;
|
|
13
14
|
}
|
|
@@ -52,11 +53,13 @@ class Proof {
|
|
|
52
53
|
return verified;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
static name = "Proof";
|
|
57
|
+
|
|
55
58
|
static fromProofNode(proofNode, fileContext) {
|
|
56
59
|
let proof = null;
|
|
57
60
|
|
|
58
61
|
if (proofNode !== null) {
|
|
59
|
-
const { Derivation } =
|
|
62
|
+
const { Derivation } = dom,
|
|
60
63
|
derivationNode = derivationNodeQuery(proofNode),
|
|
61
64
|
derivation = Derivation.fromDerivationNode(derivationNode, fileContext);
|
|
62
65
|
|
|
@@ -65,10 +68,4 @@ class Proof {
|
|
|
65
68
|
|
|
66
69
|
return proof;
|
|
67
70
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
Object.assign(shim, {
|
|
71
|
-
Proof
|
|
72
71
|
});
|
|
73
|
-
|
|
74
|
-
export default Proof;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
import unifyMixins from "../mixins/proofStep/unify";
|
|
5
|
+
import Substitutions from "../substitutions";
|
|
6
|
+
|
|
7
|
+
import { domAssigned } from "../dom";
|
|
8
|
+
import { assignAssignments } from "../utilities/assignments";
|
|
9
|
+
|
|
10
|
+
export default domAssigned(class ProofStep {
|
|
11
|
+
constructor(string, subproof, statement, reference) {
|
|
12
|
+
this.string = string;
|
|
13
|
+
this.subproof = subproof;
|
|
14
|
+
this.statement = statement;
|
|
15
|
+
this.reference = reference;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getString() {
|
|
19
|
+
return this.string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getSubproof() {
|
|
23
|
+
return this.subproof;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getStatement() {
|
|
27
|
+
return this.statement;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getReference() {
|
|
31
|
+
return this.reference;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
isQualified() {
|
|
35
|
+
const qualified = (this.reference !== null);
|
|
36
|
+
|
|
37
|
+
return qualified;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
unify(substitutions, context) {
|
|
41
|
+
let unified;
|
|
42
|
+
|
|
43
|
+
if (this.subproof !== null) {
|
|
44
|
+
unified = true; ///
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (this.statement !== null) {
|
|
48
|
+
const proofStepString = this.string; ///
|
|
49
|
+
|
|
50
|
+
context.trace(`Unifying the '${proofStepString}' proof step...`);
|
|
51
|
+
|
|
52
|
+
unified = unifyMixins.some((unifyMixin) => {
|
|
53
|
+
const unified = unifyMixin(this.statement, this.reference, substitutions, context);
|
|
54
|
+
|
|
55
|
+
if (unified) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (unified) {
|
|
61
|
+
context.debug(`...unified the '${proofStepString}' proof step.`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return unified;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
unifyStatement(statement, context) {
|
|
69
|
+
let statementUnified;
|
|
70
|
+
|
|
71
|
+
const specificContext = context, ///
|
|
72
|
+
generalContext = context, ///
|
|
73
|
+
substitutions = Substitutions.fromNothing();
|
|
74
|
+
|
|
75
|
+
if (this.subproof !== null) {
|
|
76
|
+
const subproofUnified = statement.unifySubproof(this.subproof, substitutions, generalContext, specificContext);
|
|
77
|
+
|
|
78
|
+
statementUnified = subproofUnified; ///
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (this.statement !== null) {
|
|
82
|
+
statementUnified = statement.unifyStatement(this.statement, substitutions, generalContext, specificContext);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (statementUnified) {
|
|
86
|
+
const equivalences = context.getEquivalences(),
|
|
87
|
+
substitutionsUnified = equivalences.unifySubstitutions(substitutions);
|
|
88
|
+
|
|
89
|
+
statementUnified = substitutionsUnified; ///
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return statementUnified;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
verifyAndUnify(substitutions, context) {
|
|
96
|
+
let verifiedAndUnified = false;
|
|
97
|
+
|
|
98
|
+
const assignments = [],
|
|
99
|
+
verified = this.verify(substitutions, assignments, context);
|
|
100
|
+
|
|
101
|
+
if (verified) {
|
|
102
|
+
const unified = this.unify(substitutions, context);
|
|
103
|
+
|
|
104
|
+
if (unified) {
|
|
105
|
+
const proofStep = this; ///
|
|
106
|
+
|
|
107
|
+
assignAssignments(assignments, context);
|
|
108
|
+
|
|
109
|
+
context.addProofStep(proofStep);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
verifiedAndUnified = unified; ///
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return verifiedAndUnified;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
verify(substitutions, assignments, context) {
|
|
119
|
+
let verified = false;
|
|
120
|
+
|
|
121
|
+
if (false) {
|
|
122
|
+
///
|
|
123
|
+
} else if (this.subproof !== null) {
|
|
124
|
+
const subproofVerified = this.subproof.verify(substitutions, context);
|
|
125
|
+
|
|
126
|
+
verified = subproofVerified; ///
|
|
127
|
+
} else if (this.statement !== null) {
|
|
128
|
+
const qualified = this.isQualified(),
|
|
129
|
+
stated = qualified, ///
|
|
130
|
+
statementVerified = this.statement.verify(assignments, stated, context);
|
|
131
|
+
|
|
132
|
+
if (statementVerified) {
|
|
133
|
+
if (this.reference === null) {
|
|
134
|
+
verified = true;
|
|
135
|
+
} else {
|
|
136
|
+
const referenceVerified = this.reference.verify(context);
|
|
137
|
+
|
|
138
|
+
verified = referenceVerified; ///
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
const proofStepString = this.string;
|
|
143
|
+
|
|
144
|
+
context.debug(`Cannot verify the '${proofStepString}' proof step because it is nonsense.`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return verified;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static name = "ProofStep";
|
|
151
|
+
|
|
152
|
+
static fromStatement(statement, context) {
|
|
153
|
+
const statementString = statement.getString(),
|
|
154
|
+
string = statementString, ///
|
|
155
|
+
subproof = null,
|
|
156
|
+
reference = null,
|
|
157
|
+
proofStep = new ProofStep(string, subproof, statement, reference);
|
|
158
|
+
|
|
159
|
+
return proofStep;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static fromProofStepNode(proofStepNode, fileContext) {
|
|
163
|
+
const { Subproof, Statement, Reference } = dom,
|
|
164
|
+
node = proofStepNode, ///
|
|
165
|
+
string = fileContext.nodeAsString(node),
|
|
166
|
+
subproof = Subproof.fromProofStepNode(proofStepNode, fileContext),
|
|
167
|
+
statement = Statement.fromProofStepNode(proofStepNode, fileContext),
|
|
168
|
+
reference = Reference.fromProofStepNode(proofStepNode, fileContext),
|
|
169
|
+
proofStep = new ProofStep(string, subproof, statement, reference);
|
|
170
|
+
|
|
171
|
+
return proofStep;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import LocalContext from "
|
|
3
|
+
import dom from "../dom";
|
|
4
|
+
import LocalContext from "../context/local";
|
|
5
5
|
|
|
6
|
-
import { nodeQuery } from "
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { domAssigned } from "../dom";
|
|
8
|
+
import { referenceMetaType } from "../dom/metaType";
|
|
9
|
+
import { unifyLabelWithReference } from "../utilities/unification";
|
|
10
|
+
import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const referenceNodeQuery = nodeQuery("/proofStep|lastProofStep/reference");
|
|
12
13
|
|
|
13
|
-
export default class Reference {
|
|
14
|
+
export default domAssigned(class Reference {
|
|
14
15
|
constructor(metavariable) {
|
|
15
16
|
this.metavariable = metavariable;
|
|
16
17
|
}
|
|
@@ -40,7 +41,7 @@ export default class Reference {
|
|
|
40
41
|
unifyLabel(label, substitutions, generalContext, specificContext) {
|
|
41
42
|
let labelUnified;
|
|
42
43
|
|
|
43
|
-
const reference = this,
|
|
44
|
+
const reference = this, ///
|
|
44
45
|
labelString = label.getString(),
|
|
45
46
|
referenceString = reference.getString();
|
|
46
47
|
|
|
@@ -65,10 +66,18 @@ export default class Reference {
|
|
|
65
66
|
context.trace(`Verifying the '${referenceString}' reference...`);
|
|
66
67
|
|
|
67
68
|
if (!verified) {
|
|
68
|
-
const
|
|
69
|
-
metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, context);
|
|
69
|
+
const metavariableVerified = this.verifyMetavariable(context);
|
|
70
70
|
|
|
71
|
-
verified =
|
|
71
|
+
verified = metavariableVerified; ///
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!verified) {
|
|
75
|
+
const reference = this, ///
|
|
76
|
+
rulePresent = context.isRulePresentByReference(reference),
|
|
77
|
+
metaLemmasMetaTheoremsPresent = context.areMetaLemmasMetaTheoremsPresentByReference(reference),
|
|
78
|
+
axiomLemmaTheoremConjecturePresent = context.isAxiomLemmaTheoremConjecturePresentByReference(reference);
|
|
79
|
+
|
|
80
|
+
verified = (rulePresent || metaLemmasMetaTheoremsPresent || axiomLemmaTheoremConjecturePresent);
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
if (verified) {
|
|
@@ -78,6 +87,17 @@ export default class Reference {
|
|
|
78
87
|
return verified;
|
|
79
88
|
}
|
|
80
89
|
|
|
90
|
+
verifyMetavariable(context) {
|
|
91
|
+
let metavariableVerified;
|
|
92
|
+
|
|
93
|
+
const metaType = referenceMetaType, ///
|
|
94
|
+
metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, context);
|
|
95
|
+
|
|
96
|
+
metavariableVerified = metavariableVerifiedGivenMetaType; ///
|
|
97
|
+
|
|
98
|
+
return metavariableVerified;
|
|
99
|
+
}
|
|
100
|
+
|
|
81
101
|
toJSON() {
|
|
82
102
|
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
83
103
|
metavariable = metavariableJSON, ///
|
|
@@ -90,6 +110,8 @@ export default class Reference {
|
|
|
90
110
|
return json;
|
|
91
111
|
}
|
|
92
112
|
|
|
113
|
+
static name = "Reference";
|
|
114
|
+
|
|
93
115
|
static fromJSON(json, fileContext) {
|
|
94
116
|
const metavariable = metavariableFromJSON(json, fileContext),
|
|
95
117
|
reference = new Reference(string, metavariable);
|
|
@@ -97,14 +119,20 @@ export default class Reference {
|
|
|
97
119
|
return reference;
|
|
98
120
|
}
|
|
99
121
|
|
|
100
|
-
static
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
static fromProofStepNode(proofStepNode, fileContext) {
|
|
123
|
+
let reference = null;
|
|
124
|
+
|
|
125
|
+
const referenceNode = referenceNodeQuery(proofStepNode);
|
|
126
|
+
|
|
127
|
+
if (referenceNode !== null) {
|
|
128
|
+
const { Metavariable } = dom,
|
|
129
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
130
|
+
context = localContext, ///
|
|
131
|
+
metavariable = Metavariable.fromReferenceNode(referenceNode, context);
|
|
132
|
+
|
|
133
|
+
reference = new Reference(metavariable);
|
|
134
|
+
}
|
|
107
135
|
|
|
108
136
|
return reference;
|
|
109
137
|
}
|
|
110
|
-
}
|
|
138
|
+
});
|
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import LocalContext from "
|
|
5
|
+
import dom from "../dom";
|
|
6
|
+
import LocalContext from "../context/local";
|
|
7
|
+
import Substitutions from "../substitutions";
|
|
7
8
|
|
|
9
|
+
import { domAssigned } from "../dom";
|
|
8
10
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
9
|
-
import { nodeQuery, nodesQuery } from "
|
|
11
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
10
12
|
import { labelsFromJSON,
|
|
11
13
|
premisesFromJSON,
|
|
12
14
|
conclusionFromJSON,
|
|
13
15
|
labelsToLabelsJSON,
|
|
14
16
|
premisesToPremisesJSON,
|
|
15
|
-
conclusionToConclusionJSON } from "
|
|
17
|
+
conclusionToConclusionJSON } from "../utilities/json";
|
|
16
18
|
|
|
17
|
-
const {
|
|
19
|
+
const { reverse, extract, backwardsEvery } = arrayUtilities;
|
|
18
20
|
|
|
19
21
|
const proofNodeQuery = nodeQuery("/rule/proof"),
|
|
20
22
|
labelNodesQuery = nodesQuery("/rule/label"),
|
|
21
23
|
premiseNodesQuery = nodesQuery("/rule/premise"),
|
|
22
24
|
conclusionNodeQuery = nodeQuery("/rule/conclusion");
|
|
23
25
|
|
|
24
|
-
class Rule {
|
|
26
|
+
export default domAssigned(class Rule {
|
|
25
27
|
constructor(fileContext, string, labels, premises, conclusion, proof) {
|
|
26
28
|
this.fileContext = fileContext;
|
|
27
29
|
this.string = string;
|
|
@@ -76,8 +78,7 @@ class Rule {
|
|
|
76
78
|
generalContext = localContext, ///
|
|
77
79
|
specificContext = context; ///
|
|
78
80
|
|
|
79
|
-
const
|
|
80
|
-
substitutions = Substitutions.fromNothing(),
|
|
81
|
+
const substitutions = Substitutions.fromNothing(),
|
|
81
82
|
statementUnifiedWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, generalContext, specificContext);
|
|
82
83
|
|
|
83
84
|
if (statementUnifiedWithConclusion) {
|
|
@@ -167,8 +168,7 @@ class Rule {
|
|
|
167
168
|
let proofVerified = true; ///
|
|
168
169
|
|
|
169
170
|
if (this.proof !== null) {
|
|
170
|
-
const
|
|
171
|
-
substitutions = Substitutions.fromNothing();
|
|
171
|
+
const substitutions = Substitutions.fromNothing();
|
|
172
172
|
|
|
173
173
|
proofVerified = this.proof.verify(substitutions, this.conclusion, context);
|
|
174
174
|
}
|
|
@@ -220,6 +220,8 @@ class Rule {
|
|
|
220
220
|
return json;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
static name = "Rule";
|
|
224
|
+
|
|
223
225
|
static fromJSON(json, fileContext) {
|
|
224
226
|
let rule;
|
|
225
227
|
|
|
@@ -235,7 +237,7 @@ class Rule {
|
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
static fromRuleNode(ruleNode, fileContext) {
|
|
238
|
-
const { Label, Proof, Premise, Conclusion } =
|
|
240
|
+
const { Label, Proof, Premise, Conclusion } = dom,
|
|
239
241
|
proofNode = proofNodeQuery(ruleNode),
|
|
240
242
|
labelNodes = labelNodesQuery(ruleNode),
|
|
241
243
|
premiseNodes = premiseNodesQuery(ruleNode),
|
|
@@ -257,10 +259,4 @@ class Rule {
|
|
|
257
259
|
|
|
258
260
|
return rule;
|
|
259
261
|
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
Object.assign(shim, {
|
|
263
|
-
Rule
|
|
264
262
|
});
|
|
265
|
-
|
|
266
|
-
export default Rule;
|