occam-verify-cli 1.0.444 → 1.0.457
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/constants.js +1 -5
- package/lib/context/file.js +54 -82
- package/lib/context/fragment.js +77 -0
- package/lib/context/release.js +5 -9
- package/lib/context/scoped.js +314 -0
- package/lib/context/transient.js +371 -0
- package/lib/element/assumption.js +71 -84
- package/lib/element/combinator/bracketed.js +1 -10
- package/lib/element/conclusion.js +11 -8
- package/lib/element/constructor/bracketed.js +1 -10
- package/lib/element/declaration/combinator.js +1 -2
- package/lib/element/declaration/metavariable.js +3 -3
- package/lib/element/declaration/variable.js +3 -3
- package/lib/element/deduction.js +18 -13
- package/lib/element/derivation.js +14 -14
- package/lib/element/frame.js +40 -46
- package/lib/element/hypothesis.js +14 -55
- package/lib/element/judgement.js +35 -56
- package/lib/element/metaType.js +5 -4
- package/lib/element/metavariable.js +14 -10
- package/lib/element/proof.js +10 -10
- package/lib/element/proofAssertion/premise.js +308 -0
- package/lib/element/proofAssertion/step.js +305 -0
- package/lib/element/proofAssertion/supposition.js +322 -0
- package/lib/element/proofAssertion.js +199 -0
- package/lib/element/reference.js +28 -25
- package/lib/element/rule.js +29 -29
- package/lib/element/section.js +4 -4
- package/lib/element/statement.js +9 -14
- package/lib/element/subDerivation.js +14 -14
- package/lib/element/subproof.js +14 -14
- package/lib/element/substitution/frame.js +7 -7
- package/lib/element/substitution/statement.js +15 -39
- package/lib/element/substitution.js +5 -5
- package/lib/element/term.js +12 -10
- package/lib/element/topLevelAssertion/axiom.js +329 -0
- package/lib/element/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
- package/lib/element/{lemma.js → topLevelAssertion/lemma.js} +6 -6
- package/lib/element/{theorem.js → topLevelAssertion/theorem.js} +7 -7
- package/lib/element/topLevelAssertion.js +427 -0
- package/lib/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
- package/lib/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
- package/lib/element/topLevelMetaAssertion.js +289 -0
- package/lib/element/type.js +4 -4
- package/lib/element/variable.js +20 -20
- package/lib/metaTypes.js +33 -19
- package/lib/node/proofAssertion/premise.js +116 -0
- package/lib/node/proofAssertion/step.js +152 -0
- package/lib/node/proofAssertion/supposition.js +116 -0
- package/lib/node/{premise.js → proofAssertion.js} +11 -18
- package/lib/node/statement.js +2 -2
- package/lib/node/subDerivation.js +1 -8
- package/lib/node/subproof.js +1 -8
- package/lib/node/substitution/statement.js +2 -2
- package/lib/node/{axiom.js → topLevelAssertion/axiom.js} +7 -7
- package/lib/node/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
- package/lib/node/{lemma.js → topLevelAssertion/lemma.js} +7 -7
- package/lib/node/{theorem.js → topLevelAssertion/theorem.js} +7 -7
- package/lib/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +9 -9
- package/lib/node/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
- package/lib/node/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
- package/lib/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +9 -9
- package/lib/nonTerminalNodeMap.js +13 -13
- package/lib/preamble.js +10 -10
- package/lib/process/instantiate.js +6 -9
- package/lib/process/unify.js +7 -6
- package/lib/types.js +3 -3
- package/lib/utilities/bnf.js +5 -5
- package/lib/utilities/brackets.js +6 -11
- package/lib/utilities/context.js +28 -0
- package/lib/utilities/element.js +101 -99
- package/lib/utilities/fragment.js +23 -0
- package/lib/utilities/instance.js +12 -21
- package/lib/utilities/json.js +3 -2
- package/lib/utilities/string.js +44 -23
- package/lib/utilities/unification.js +36 -36
- package/lib/utilities/validation.js +22 -25
- package/package.json +6 -6
- package/src/constants.js +0 -1
- package/src/context/file.js +51 -58
- package/src/context/fragment.js +38 -0
- package/src/context/release.js +6 -11
- package/src/context/{local.js → scoped.js} +35 -127
- package/src/context/{temporary.js → transient.js} +9 -131
- package/src/element/assumption.js +69 -85
- package/src/element/combinator/bracketed.js +0 -7
- package/src/element/conclusion.js +14 -10
- package/src/element/constructor/bracketed.js +0 -7
- package/src/element/declaration/combinator.js +0 -1
- package/src/element/declaration/metavariable.js +2 -2
- package/src/element/declaration/variable.js +5 -5
- package/src/element/deduction.js +22 -15
- package/src/element/derivation.js +12 -12
- package/src/element/frame.js +36 -48
- package/src/element/hypothesis.js +14 -16
- package/src/element/judgement.js +33 -58
- package/src/element/metaType.js +4 -4
- package/src/element/metavariable.js +17 -10
- package/src/element/proof.js +9 -9
- package/src/element/{premise.js → proofAssertion/premise.js} +107 -75
- package/src/element/{step.js → proofAssertion/step.js} +43 -89
- package/src/element/{supposition.js → proofAssertion/supposition.js} +89 -88
- package/src/element/proofAssertion.js +69 -0
- package/src/element/reference.js +27 -23
- package/src/element/rule.js +25 -25
- package/src/element/section.js +4 -4
- package/src/element/statement.js +8 -15
- package/src/element/subDerivation.js +12 -12
- package/src/element/subproof.js +10 -10
- package/src/element/substitution/frame.js +10 -13
- package/src/element/substitution/statement.js +20 -52
- package/src/element/substitution.js +3 -3
- package/src/element/term.js +10 -9
- package/src/element/{axiom.js → topLevelAssertion/axiom.js} +41 -41
- package/src/element/{conjecture.js → topLevelAssertion/conjecture.js} +4 -4
- package/src/element/{lemma.js → topLevelAssertion/lemma.js} +3 -3
- package/src/element/{theorem.js → topLevelAssertion/theorem.js} +4 -4
- package/src/element/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +30 -49
- package/src/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +4 -4
- package/src/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +4 -4
- package/src/element/{metaLemmaMetatheorem.js → topLevelMetaAssertion.js} +7 -72
- package/src/element/type.js +2 -4
- package/src/element/variable.js +17 -17
- package/src/metaTypes.js +42 -13
- package/src/node/proofAssertion/premise.js +16 -0
- package/src/node/{step.js → proofAssertion/step.js} +4 -18
- package/src/node/proofAssertion/supposition.js +16 -0
- package/src/node/proofAssertion.js +23 -0
- package/src/node/statement.js +1 -1
- package/src/node/subDerivation.js +0 -7
- package/src/node/subproof.js +0 -7
- package/src/node/substitution/statement.js +1 -1
- package/src/node/topLevelAssertion/axiom.js +13 -0
- package/src/node/topLevelAssertion/conjecture.js +13 -0
- package/src/node/topLevelAssertion/lemma.js +13 -0
- package/src/node/topLevelAssertion/theorem.js +13 -0
- package/src/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +1 -1
- package/src/node/topLevelMetaAssertion/metaLemma.js +13 -0
- package/src/node/topLevelMetaAssertion/metatheorem.js +13 -0
- package/src/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +1 -1
- package/src/nonTerminalNodeMap.js +12 -12
- package/src/preamble.js +9 -9
- package/src/process/instantiate.js +31 -32
- package/src/process/unify.js +6 -5
- package/src/types.js +4 -2
- package/src/utilities/bnf.js +3 -2
- package/src/utilities/brackets.js +5 -8
- package/src/utilities/context.js +20 -0
- package/src/utilities/element.js +169 -162
- package/src/utilities/fragment.js +11 -0
- package/src/utilities/instance.js +19 -24
- package/src/utilities/json.js +3 -1
- package/src/utilities/string.js +57 -32
- package/src/utilities/unification.js +39 -39
- package/src/utilities/validation.js +26 -35
- package/lib/context/local.js +0 -605
- package/lib/context/temporary.js +0 -752
- package/lib/element/axiom.js +0 -329
- package/lib/element/axiomLemmaTheoremConjecture.js +0 -434
- package/lib/element/metaLemmaMetatheorem.js +0 -322
- package/lib/element/premise.js +0 -380
- package/lib/element/step.js +0 -390
- package/lib/element/supposition.js +0 -410
- package/lib/node/step.js +0 -166
- package/lib/node/supposition.js +0 -130
- package/src/node/axiom.js +0 -13
- package/src/node/conjecture.js +0 -13
- package/src/node/lemma.js +0 -13
- package/src/node/metaLemma.js +0 -13
- package/src/node/metatheorem.js +0 -13
- package/src/node/premise.js +0 -30
- package/src/node/supposition.js +0 -30
- package/src/node/theorem.js +0 -13
package/src/element/deduction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Element from "../element";
|
|
4
|
-
import
|
|
4
|
+
import TransientContext from "../context/transient";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { termsFromJSON, framesFromJSON, statementFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON } from "../utilities/json";
|
|
@@ -20,9 +20,9 @@ export default define(class Deduction extends Element {
|
|
|
20
20
|
verify(context) {
|
|
21
21
|
let verifies = false;
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const transientContext = TransientContext.fromNothing(context);
|
|
24
24
|
|
|
25
|
-
context =
|
|
25
|
+
context = transientContext; ///
|
|
26
26
|
|
|
27
27
|
const node = this.getNode(),
|
|
28
28
|
deductionString = this.getString(); ///
|
|
@@ -53,14 +53,18 @@ export default define(class Deduction extends Element {
|
|
|
53
53
|
unifyStatement(statement, substitutions, context) {
|
|
54
54
|
let statementUnifies;
|
|
55
55
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
deductionString = deduction.getString();
|
|
56
|
+
const statementString = statement.getString(),
|
|
57
|
+
deductionString = this.getString(); ///
|
|
59
58
|
|
|
60
59
|
context.trace(`Unifying the '${statementString}' statement with the '${deductionString}' deduction...`);
|
|
61
60
|
|
|
62
|
-
const
|
|
63
|
-
|
|
61
|
+
const specificContext = context; ///
|
|
62
|
+
|
|
63
|
+
context = this.getContext();
|
|
64
|
+
|
|
65
|
+
const generalContext = context; ///
|
|
66
|
+
|
|
67
|
+
context = specificContext; ///
|
|
64
68
|
|
|
65
69
|
statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
66
70
|
|
|
@@ -72,22 +76,25 @@ export default define(class Deduction extends Element {
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
unifyDeduction(deduction, substitutions, generalContext, specificContext) {
|
|
75
|
-
let deductionUnifies;
|
|
79
|
+
let deductionUnifies = false;
|
|
76
80
|
|
|
77
81
|
const context = specificContext, ///
|
|
82
|
+
generalDeduction = this, ///
|
|
78
83
|
specificDeduction = deduction, ///
|
|
79
|
-
generalDeductionString =
|
|
84
|
+
generalDeductionString = generalDeduction.getString(),
|
|
80
85
|
specificDeductionString = specificDeduction.getString();
|
|
81
86
|
|
|
82
|
-
context.trace(`Unifying the '${specificDeductionString}' deduction with the '${generalDeductionString}' deduction
|
|
87
|
+
context.trace(`Unifying the '${specificDeductionString}' deduction with the '${generalDeductionString}' deduction...`);
|
|
83
88
|
|
|
84
89
|
const statement = specificDeduction.getStatement(),
|
|
85
90
|
statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
if (statementUnifies) {
|
|
93
|
+
deductionUnifies = true;
|
|
94
|
+
}
|
|
88
95
|
|
|
89
96
|
if (deductionUnifies) {
|
|
90
|
-
context.debug(`...unified the '${specificDeductionString}' deduction with the '${generalDeductionString}' deduction
|
|
97
|
+
context.debug(`...unified the '${specificDeductionString}' deduction with the '${generalDeductionString}' deduction.`);
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
return deductionUnifies;
|
|
@@ -127,9 +134,9 @@ export default define(class Deduction extends Element {
|
|
|
127
134
|
statement = statementFromJSON(json, context),
|
|
128
135
|
node = null,
|
|
129
136
|
string = statement.getString(),
|
|
130
|
-
|
|
137
|
+
transientContext = TransientContext.fromTermsAndFrames(terms, frames, context);
|
|
131
138
|
|
|
132
|
-
context =
|
|
139
|
+
context = transientContext; ///
|
|
133
140
|
|
|
134
141
|
const deduction = new Deduction(context, string, statement);
|
|
135
142
|
|
|
@@ -10,35 +10,35 @@ import { define } from "../elements";
|
|
|
10
10
|
const { last } = arrayUtilities;
|
|
11
11
|
|
|
12
12
|
export default define(class Derivation extends Element {
|
|
13
|
-
constructor(context, string, node,
|
|
13
|
+
constructor(context, string, node, subproofOrProofAssertions) {
|
|
14
14
|
super(context, string, node);
|
|
15
15
|
|
|
16
|
-
this.
|
|
16
|
+
this.subproofOrProofAssertions = subproofOrProofAssertions;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
return this.
|
|
19
|
+
getSubproofOrProofAssertions() {
|
|
20
|
+
return this.subproofOrProofAssertions;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
23
|
+
getLastProofAssertion() {
|
|
24
|
+
const lastSubproofOrProofAssertion = last(this.subproofOrProofAssertions),
|
|
25
|
+
lastProofAssertion = lastSubproofOrProofAssertion; ///
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return lastProofAssertion;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
verify(substitutions, context) {
|
|
31
31
|
let verifies;
|
|
32
32
|
|
|
33
|
-
verifies = this.
|
|
33
|
+
verifies = this.subproofOrProofAssertions.every((subproofOrProofAssertion) => { ///
|
|
34
34
|
const assignments = [],
|
|
35
|
-
|
|
35
|
+
subproofOrProofAssertionVerifies = subproofOrProofAssertion.verify(substitutions, assignments, context);
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (subproofOrProofAssertionVerifies) {
|
|
38
38
|
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
39
39
|
|
|
40
40
|
if (assignmentsAssigned) {
|
|
41
|
-
context.
|
|
41
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
42
42
|
|
|
43
43
|
return true;
|
|
44
44
|
}
|
package/src/element/frame.js
CHANGED
|
@@ -6,7 +6,6 @@ import Element from "../element";
|
|
|
6
6
|
import elements from "../elements";
|
|
7
7
|
|
|
8
8
|
import { define } from "../elements";
|
|
9
|
-
import { S, NOTHING } from "../constants";
|
|
10
9
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
11
10
|
|
|
12
11
|
const { first } = arrayUtilities;
|
|
@@ -115,7 +114,7 @@ export default define(class Frame extends Element {
|
|
|
115
114
|
compareSubstitutions(substitutions, context) {
|
|
116
115
|
let comparesToSubstitutions;
|
|
117
116
|
|
|
118
|
-
const frameString = this.
|
|
117
|
+
const frameString = this.getString(), ///
|
|
119
118
|
substitutionsString = substitutions.asString();
|
|
120
119
|
|
|
121
120
|
context.trace(`Comparing the '${frameString}' frame to the '${substitutionsString}' substitutions...`);
|
|
@@ -135,114 +134,103 @@ export default define(class Frame extends Element {
|
|
|
135
134
|
return comparesToSubstitutions;
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
let
|
|
137
|
+
validate(assignments, stated, context) {
|
|
138
|
+
let validates = false;
|
|
140
139
|
|
|
141
|
-
const frameString = this.
|
|
140
|
+
const frameString = this.getString(); ///
|
|
142
141
|
|
|
143
|
-
context.trace(`
|
|
142
|
+
context.trace(`Validating the '${frameString}' frame...`);
|
|
144
143
|
|
|
145
|
-
const
|
|
144
|
+
const assumptionsValidate = this.validateAssumptions(assignments, stated, context);
|
|
146
145
|
|
|
147
|
-
if (
|
|
148
|
-
let
|
|
149
|
-
|
|
146
|
+
if (assumptionsValidate) {
|
|
147
|
+
let validatesWhenStated = false,
|
|
148
|
+
validatesWhenDerived = false;
|
|
150
149
|
|
|
151
150
|
if (stated) {
|
|
152
|
-
|
|
151
|
+
validatesWhenStated = this.validateWhenStated(assignments, context);
|
|
153
152
|
} else {
|
|
154
|
-
|
|
153
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
155
154
|
}
|
|
156
155
|
|
|
157
|
-
if (
|
|
158
|
-
|
|
156
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
157
|
+
validates = true;
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
if (
|
|
161
|
+
if (validates) {
|
|
163
162
|
const frame = this; ///
|
|
164
163
|
|
|
165
164
|
context.addFrame(frame);
|
|
166
165
|
|
|
167
|
-
context.debug(`...
|
|
166
|
+
context.debug(`...validated the '${frameString}' frame.`);
|
|
168
167
|
}
|
|
169
168
|
|
|
170
|
-
return
|
|
169
|
+
return validates;
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
|
|
174
|
-
let
|
|
172
|
+
validateWhenStated(assignments, context) {
|
|
173
|
+
let validatesWhenStated = false;
|
|
175
174
|
|
|
176
|
-
const frameString = this.
|
|
175
|
+
const frameString = this.getString(); ///
|
|
177
176
|
|
|
178
|
-
context.trace(`
|
|
177
|
+
context.trace(`Validating the '${frameString}' stated frame...`);
|
|
179
178
|
|
|
180
179
|
const singular = this.isSingular();
|
|
181
180
|
|
|
182
181
|
if (!singular) {
|
|
183
182
|
context.trace(`The '${frameString}' stated frame must be singular.`);
|
|
184
183
|
} else {
|
|
185
|
-
|
|
184
|
+
validatesWhenStated = true;
|
|
186
185
|
}
|
|
187
186
|
|
|
188
|
-
if (
|
|
189
|
-
context.debug(`...
|
|
187
|
+
if (validatesWhenStated) {
|
|
188
|
+
context.debug(`...validated the '${frameString}' stated frame.`);
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
return
|
|
191
|
+
return validatesWhenStated;
|
|
193
192
|
}
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
let
|
|
194
|
+
validateWhenDerived(context) {
|
|
195
|
+
let validatesWhenDerived;
|
|
197
196
|
|
|
198
|
-
const frameString = this.
|
|
197
|
+
const frameString = this.getString(); ///
|
|
199
198
|
|
|
200
199
|
context.trace(`Verifying the '${frameString}' derived frame...`);
|
|
201
200
|
|
|
202
|
-
|
|
201
|
+
validatesWhenDerived = true;
|
|
203
202
|
|
|
204
|
-
if (
|
|
203
|
+
if (validatesWhenDerived) {
|
|
205
204
|
context.debug(`...verified the '${frameString}' derived frame.`);
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
return
|
|
207
|
+
return validatesWhenDerived;
|
|
209
208
|
}
|
|
210
209
|
|
|
211
|
-
|
|
212
|
-
let
|
|
210
|
+
validateAssumptions(assignments, stated, context) {
|
|
211
|
+
let assumptionsValidate = true; ///
|
|
213
212
|
|
|
214
213
|
const length = this.getLength();
|
|
215
214
|
|
|
216
215
|
if (length > 0) {
|
|
217
|
-
const sOrNothing = (length > 1) ?
|
|
218
|
-
S :
|
|
219
|
-
NOTHING,
|
|
220
|
-
assumptionsString = assumptionsStringFromAssumptions(this.assumptions);
|
|
221
|
-
|
|
222
|
-
context.trace(`Verifying the '${assumptionsString}' assumption${sOrNothing}...`);
|
|
223
|
-
|
|
224
216
|
stated = true; ///
|
|
225
217
|
|
|
226
218
|
assignments = null; ///
|
|
227
219
|
|
|
228
|
-
|
|
229
|
-
const assumptionVerifies = assumption.
|
|
220
|
+
assumptionsValidate = this.assumptions.every((assumption) => {
|
|
221
|
+
const assumptionVerifies = assumption.validate(assignments, stated, context);
|
|
230
222
|
|
|
231
223
|
return assumptionVerifies;
|
|
232
224
|
});
|
|
233
|
-
|
|
234
|
-
if (assumptionsVerify) {
|
|
235
|
-
context.debug(`...verified the '${assumptionsString}' assumption${sOrNothing}.`);
|
|
236
|
-
}
|
|
237
225
|
}
|
|
238
226
|
|
|
239
|
-
return
|
|
227
|
+
return assumptionsValidate;
|
|
240
228
|
}
|
|
241
229
|
|
|
242
230
|
validateGivenMetaType(metaType, assignments, stated, context) {
|
|
243
231
|
let validatesGivenMetaType = false;
|
|
244
232
|
|
|
245
|
-
const frameString = this.
|
|
233
|
+
const frameString = this.getString(), ///
|
|
246
234
|
metaTypeString = metaType.getString();
|
|
247
235
|
|
|
248
236
|
context.trace(`Validatin the '${frameString}' frame given the '${metaTypeString}' meta-type...`);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Element from "../element";
|
|
4
|
-
import elements from "../elements";
|
|
5
4
|
import assignAssignments from "../process/assign";
|
|
6
5
|
|
|
7
6
|
import { define } from "../elements";
|
|
@@ -36,11 +35,9 @@ export default define(class Hypothesis extends Element {
|
|
|
36
35
|
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
37
36
|
|
|
38
37
|
if (assignmentsAssigned) {
|
|
39
|
-
const
|
|
40
|
-
step = Step.fromStatement(this.statement, context),
|
|
41
|
-
stepOrSubproof = step; ///
|
|
38
|
+
const subproofOrProofAssertion = this; ///
|
|
42
39
|
|
|
43
|
-
context.
|
|
40
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
44
41
|
|
|
45
42
|
verifies = true;
|
|
46
43
|
}
|
|
@@ -56,26 +53,27 @@ export default define(class Hypothesis extends Element {
|
|
|
56
53
|
return verifies;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
let
|
|
56
|
+
compareProofAssertion(proofAssertion, context) {
|
|
57
|
+
let comparesToProofAssertion = false;
|
|
61
58
|
|
|
62
|
-
const
|
|
63
|
-
hypothesisString = this.
|
|
59
|
+
const node = this.getNode(),
|
|
60
|
+
hypothesisString = this.getString(), ///
|
|
61
|
+
proofAssertionString = proofAssertion.getString();
|
|
64
62
|
|
|
65
|
-
context.trace(`Is the '${hypothesisString}' hypothesis equal to the '${
|
|
63
|
+
context.trace(`Is the '${hypothesisString}' hypothesis equal to the '${proofAssertionString}' proof assertion...`, node);
|
|
66
64
|
|
|
67
|
-
const
|
|
68
|
-
statementEqualToStepStatement = this.statement.isEqualTo(
|
|
65
|
+
const proofAssertionStatement = proofAssertion.getStatement(),
|
|
66
|
+
statementEqualToStepStatement = this.statement.isEqualTo(proofAssertionStatement);
|
|
69
67
|
|
|
70
68
|
if (statementEqualToStepStatement) {
|
|
71
|
-
|
|
69
|
+
comparesToProofAssertion = true;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
if (
|
|
75
|
-
context.trace(`...the '${hypothesisString}' hypothesis is equal to the '${
|
|
72
|
+
if (comparesToProofAssertion) {
|
|
73
|
+
context.trace(`...the '${hypothesisString}' hypothesis is equal to the '${proofAssertionString}' proof assertion.`, node);
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
return
|
|
76
|
+
return comparesToProofAssertion;
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
toJSON() {
|
package/src/element/judgement.js
CHANGED
|
@@ -26,110 +26,85 @@ export default define(class Judgement extends Element {
|
|
|
26
26
|
|
|
27
27
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
let
|
|
29
|
+
validate(assignments, stated, context) {
|
|
30
|
+
let validates = false;
|
|
31
31
|
|
|
32
32
|
const judgementString = this.string; ///
|
|
33
33
|
|
|
34
|
-
context.trace(`
|
|
34
|
+
context.trace(`Validating the '${judgementString}' judgement...`);
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const frameValidates = this.frame.validate(assignments, stated, context);
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
38
|
+
if (frameValidates) {
|
|
39
|
+
const assumptionValidates = this.assumption.validate(assignments, stated, context);
|
|
40
40
|
|
|
41
|
-
if (
|
|
42
|
-
let
|
|
43
|
-
|
|
41
|
+
if (assumptionValidates) {
|
|
42
|
+
let validatesWhenStated = false,
|
|
43
|
+
validatesWhenDerived = false;
|
|
44
44
|
|
|
45
45
|
if (stated) {
|
|
46
|
-
|
|
46
|
+
validatesWhenStated = this.validateWhenStated(assignments, context);
|
|
47
47
|
} else {
|
|
48
|
-
|
|
48
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if (
|
|
52
|
-
|
|
51
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
52
|
+
validates = true;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (
|
|
57
|
+
if (validates) {
|
|
58
58
|
if (stated) {
|
|
59
59
|
this.assign(assignments, context);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
if (
|
|
64
|
-
context.debug(`...
|
|
63
|
+
if (validates) {
|
|
64
|
+
context.debug(`...validated the '${judgementString}' judgement.`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
return
|
|
67
|
+
return validates;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
const frameString = this.frame.getString();
|
|
74
|
-
|
|
75
|
-
context.trace(`Verifying the '${frameString}' frame...`);
|
|
76
|
-
|
|
77
|
-
frameVerifies = this.frame.verify(assignments, stated, context);
|
|
78
|
-
|
|
79
|
-
if (frameVerifies) {
|
|
80
|
-
context.debug(`...verified the '${frameString}' frame.`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return frameVerifies;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
verifyDeclaration(assignments, stated, context) {
|
|
87
|
-
let declarationVerifies;
|
|
88
|
-
|
|
89
|
-
declarationVerifies = this.assumption.verify(assignments, stated, context);
|
|
90
|
-
|
|
91
|
-
return declarationVerifies;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
verifyWhenStated(assignments, context) {
|
|
95
|
-
let verifiesWhenStated;
|
|
70
|
+
validateWhenStated(assignments, context) {
|
|
71
|
+
let validatesWhenStated;
|
|
96
72
|
|
|
97
73
|
const judgementString = this.string; ///
|
|
98
74
|
|
|
99
|
-
context.trace(`
|
|
75
|
+
context.trace(`Validating the '${judgementString}' stated judgement...`);
|
|
100
76
|
|
|
101
|
-
|
|
77
|
+
validatesWhenStated = true;
|
|
102
78
|
|
|
103
|
-
if (
|
|
104
|
-
context.debug(`...
|
|
79
|
+
if (validatesWhenStated) {
|
|
80
|
+
context.debug(`...validated the '${judgementString}' stated judgement.`);
|
|
105
81
|
}
|
|
106
82
|
|
|
107
|
-
return
|
|
83
|
+
return validatesWhenStated;
|
|
108
84
|
}
|
|
109
85
|
|
|
110
|
-
|
|
111
|
-
let
|
|
86
|
+
validateWhenDerived(context) {
|
|
87
|
+
let validatesWhenDerived = false;
|
|
112
88
|
|
|
113
89
|
const judgementString = this.string; ///
|
|
114
90
|
|
|
115
|
-
context.trace(`
|
|
91
|
+
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
116
92
|
|
|
117
93
|
const metavariable = this.assumption.getMetavariable(),
|
|
118
94
|
reference = referenceFromMetavariable(metavariable, context),
|
|
119
|
-
|
|
120
|
-
substitutions =
|
|
95
|
+
topLevelMetaAssertion = context.findTopLevelMetaAssertionByReference(reference),
|
|
96
|
+
substitutions = topLevelMetaAssertion.getSubstitutions(),
|
|
121
97
|
frameComparesToSubstitutions = this.frame.compareSubstitutions(substitutions, context);
|
|
122
98
|
|
|
123
99
|
if (frameComparesToSubstitutions) {
|
|
124
|
-
|
|
125
|
-
|
|
100
|
+
validatesWhenDerived = true;
|
|
126
101
|
}
|
|
127
102
|
|
|
128
|
-
if (
|
|
129
|
-
context.debug(`...
|
|
103
|
+
if (validatesWhenDerived) {
|
|
104
|
+
context.debug(`...validated the '${judgementString}' derived judgement.`);
|
|
130
105
|
}
|
|
131
106
|
|
|
132
|
-
return
|
|
107
|
+
return validatesWhenDerived;
|
|
133
108
|
}
|
|
134
109
|
|
|
135
110
|
assign(assignments, context) {
|
package/src/element/metaType.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Element from "../element";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { findMetaTypeFromTypeName } from "../metaTypes";
|
|
6
7
|
|
|
7
8
|
export default define(class MetaType extends Element {
|
|
8
9
|
constructor(context, string, node, name) {
|
|
@@ -41,14 +42,13 @@ export default define(class MetaType extends Element {
|
|
|
41
42
|
static fromJSON(json, context) {
|
|
42
43
|
const { name } = json,
|
|
43
44
|
metaTypeName = name, ///
|
|
44
|
-
metaType =
|
|
45
|
+
metaType = findMetaTypeByMetaTypeName(metaTypeName);
|
|
45
46
|
|
|
46
47
|
return metaType;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
static fromName(name) {
|
|
50
|
-
const
|
|
51
|
-
string = name,
|
|
50
|
+
static fromName(name, context) {
|
|
51
|
+
const string = name,
|
|
52
52
|
node = null,
|
|
53
53
|
metaType = new MetaType(context, string, node, name);
|
|
54
54
|
|
|
@@ -46,7 +46,8 @@ export default define(class Metavariable extends Element {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
compareMetavariableName(metavariableName) {
|
|
49
|
-
const
|
|
49
|
+
const nameMetavariableName = (this.name === metavariableName),
|
|
50
|
+
comparesToMetavariableName = nameMetavariableName; ///
|
|
50
51
|
|
|
51
52
|
return comparesToMetavariableName;
|
|
52
53
|
}
|
|
@@ -54,7 +55,7 @@ export default define(class Metavariable extends Element {
|
|
|
54
55
|
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
55
56
|
|
|
56
57
|
validate(context) {
|
|
57
|
-
let validates;
|
|
58
|
+
let validates = false;
|
|
58
59
|
|
|
59
60
|
const metavariableString = this.getString(); ///
|
|
60
61
|
|
|
@@ -63,7 +64,9 @@ export default define(class Metavariable extends Element {
|
|
|
63
64
|
const metavariable = this, ///
|
|
64
65
|
metavariablePresent = context.isMetavariablePresent(metavariable);
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
if (metavariablePresent) {
|
|
68
|
+
validates = true;
|
|
69
|
+
}
|
|
67
70
|
|
|
68
71
|
if (validates) {
|
|
69
72
|
context.debug(`...va;idated the '${metavariableString}' metavariable.`);
|
|
@@ -75,8 +78,8 @@ export default define(class Metavariable extends Element {
|
|
|
75
78
|
validateGivenMetaType(metaType, context) {
|
|
76
79
|
let validatesGivenMetaType = false;
|
|
77
80
|
|
|
78
|
-
const
|
|
79
|
-
|
|
81
|
+
const metaTypeString = metaType.getString(),
|
|
82
|
+
metavariableString = this.getString(); ///
|
|
80
83
|
|
|
81
84
|
context.trace(`Validating the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
82
85
|
|
|
@@ -87,7 +90,9 @@ export default define(class Metavariable extends Element {
|
|
|
87
90
|
if (metavariable !== null) {
|
|
88
91
|
const metavariableMetaTypeEqualToMetaType = metavariable.isMetaTypeEqualTo(metaType);
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
if (metavariableMetaTypeEqualToMetaType) {
|
|
94
|
+
validatesGivenMetaType = true;
|
|
95
|
+
}
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
if (validatesGivenMetaType) {
|
|
@@ -164,15 +169,17 @@ export default define(class Metavariable extends Element {
|
|
|
164
169
|
if (substitutionPresent) {
|
|
165
170
|
substitution = substitutions.findSubstitutionByMetavariableAndSubstitution(metavariable, substitution); ///
|
|
166
171
|
|
|
167
|
-
const
|
|
172
|
+
const substitutionComparesToStatement = substitution.compareStatement(statement, context);
|
|
168
173
|
|
|
169
|
-
if (
|
|
174
|
+
if (substitutionComparesToStatement) {
|
|
170
175
|
statementUnifies = true;
|
|
171
176
|
}
|
|
172
177
|
} else {
|
|
173
178
|
const { StatementSubstitution } = elements,
|
|
174
179
|
metavariable = this,
|
|
175
|
-
statementSubstitution =
|
|
180
|
+
statementSubstitution = (substitution !== null ) ?
|
|
181
|
+
StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) :
|
|
182
|
+
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context);
|
|
176
183
|
|
|
177
184
|
substitution = statementSubstitution; ///
|
|
178
185
|
|
|
@@ -303,7 +310,7 @@ export default define(class Metavariable extends Element {
|
|
|
303
310
|
|
|
304
311
|
if (generalContextFilePath === specificContextFilePath) {
|
|
305
312
|
const metavariable = this, ///
|
|
306
|
-
metavariableString =
|
|
313
|
+
metavariableString = metavariable.getString(),
|
|
307
314
|
statementMetavariableEqualToMetvariable = statement.isMetavariableEqualToMetavariable(metavariable, context);
|
|
308
315
|
|
|
309
316
|
if (statementMetavariableEqualToMetvariable) {
|
package/src/element/proof.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Element from "../element";
|
|
4
|
-
import
|
|
4
|
+
import ScopedContext from "../context/scoped";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
|
|
@@ -16,12 +16,12 @@ export default define(class Proof extends Element {
|
|
|
16
16
|
return this.derivation;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
getLastProofAssertion() { return this.derivation.getLastProofAssertion(); }
|
|
20
20
|
|
|
21
21
|
getStatement() {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
statement =
|
|
22
|
+
const lastProofAssertion = this.getLastProofAssertion(),
|
|
23
|
+
lastProofAssertionStatement = lastProofAssertion.getStatement(),
|
|
24
|
+
statement = lastProofAssertionStatement; ///
|
|
25
25
|
|
|
26
26
|
return statement;
|
|
27
27
|
}
|
|
@@ -29,16 +29,16 @@ export default define(class Proof extends Element {
|
|
|
29
29
|
verify(substitutions, conclusion, context) {
|
|
30
30
|
let verifies = false;
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const scopedContext = ScopedContext.fromNothing(context); ///
|
|
33
33
|
|
|
34
|
-
context =
|
|
34
|
+
context = scopedContext; ///
|
|
35
35
|
|
|
36
36
|
const derivationVerifies = this.derivation.verify(substitutions, context);
|
|
37
37
|
|
|
38
38
|
if (derivationVerifies) {
|
|
39
|
-
const
|
|
39
|
+
const lastProofAssertion = context.getLastProofAssertion();
|
|
40
40
|
|
|
41
|
-
if (
|
|
41
|
+
if (lastProofAssertion !== null) {
|
|
42
42
|
const statement = this.getStatement(),
|
|
43
43
|
conclusionStatement = conclusion.getStatement(),
|
|
44
44
|
conclusionStatementEqualToStatement = conclusionStatement.isEqualTo(statement);
|