occam-verify-cli 1.0.695 → 1.0.702
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/action/verify.js +3 -2
- package/lib/context/ephemeral.js +14 -5
- package/lib/context.js +9 -1
- package/lib/element/assertion/contained.js +6 -9
- package/lib/element/assertion/defined.js +6 -8
- package/lib/element/assertion/property.js +11 -5
- package/lib/element/assertion/satisfies.js +9 -3
- package/lib/element/assertion/subproof.js +4 -5
- package/lib/element/assertion/type.js +12 -7
- package/lib/element/assumption.js +22 -4
- package/lib/element/combinator.js +6 -6
- package/lib/element/conclusion.js +5 -5
- package/lib/element/constructor.js +9 -4
- package/lib/element/deduction.js +5 -5
- package/lib/element/equality.js +26 -1
- package/lib/element/frame.js +14 -7
- package/lib/element/hypothesis.js +13 -6
- package/lib/element/judgement.js +69 -3
- package/lib/element/label.js +27 -22
- package/lib/element/metaType.js +1 -1
- package/lib/element/metavariable.js +4 -4
- package/lib/element/parameter.js +7 -7
- package/lib/element/procedureCall.js +7 -7
- package/lib/element/procedureReference.js +7 -6
- package/lib/element/proofAssertion/premise.js +6 -7
- package/lib/element/proofAssertion/supposition.js +6 -7
- package/lib/element/property.js +12 -4
- package/lib/element/propertyRelation.js +28 -6
- package/lib/element/reference.js +10 -6
- package/lib/element/rule.js +26 -16
- package/lib/element/signature.js +59 -19
- package/lib/element/statement.js +4 -2
- package/lib/element/substitution/frame.js +16 -7
- package/lib/element/substitution/reference.js +17 -8
- package/lib/element/substitution/statement.js +17 -8
- package/lib/element/substitution/term.js +17 -8
- package/lib/element/term.js +4 -2
- package/lib/element/topLevelAssertion.js +28 -17
- package/lib/element/topLevelMetaAssertion.js +7 -8
- package/lib/element/type.js +16 -9
- package/lib/element/typePrefix.js +13 -6
- package/lib/element/variable.js +8 -11
- package/lib/process/instantiate.js +75 -11
- package/lib/utilities/element.js +101 -7
- package/lib/utilities/json.js +15 -1
- package/package.json +4 -4
- package/src/action/verify.js +3 -1
- package/src/context/ephemeral.js +19 -4
- package/src/context.js +15 -1
- package/src/element/assertion/contained.js +8 -25
- package/src/element/assertion/defined.js +7 -14
- package/src/element/assertion/property.js +16 -5
- package/src/element/assertion/satisfies.js +14 -3
- package/src/element/assertion/subproof.js +3 -5
- package/src/element/assertion/type.js +16 -8
- package/src/element/assumption.js +37 -3
- package/src/element/combinator.js +6 -13
- package/src/element/conclusion.js +5 -7
- package/src/element/constructor.js +13 -6
- package/src/element/deduction.js +7 -9
- package/src/element/equality.js +43 -0
- package/src/element/frame.js +21 -12
- package/src/element/hypothesis.js +19 -7
- package/src/element/judgement.js +45 -0
- package/src/element/label.js +35 -26
- package/src/element/metaType.js +1 -1
- package/src/element/metavariable.js +3 -6
- package/src/element/parameter.js +9 -12
- package/src/element/procedureCall.js +9 -12
- package/src/element/procedureReference.js +8 -8
- package/src/element/proofAssertion/premise.js +8 -14
- package/src/element/proofAssertion/supposition.js +6 -12
- package/src/element/property.js +20 -6
- package/src/element/propertyRelation.js +43 -6
- package/src/element/reference.js +16 -9
- package/src/element/rule.js +41 -24
- package/src/element/signature.js +87 -22
- package/src/element/statement.js +5 -2
- package/src/element/substitution/frame.js +26 -9
- package/src/element/substitution/reference.js +29 -11
- package/src/element/substitution/statement.js +27 -10
- package/src/element/substitution/term.js +27 -10
- package/src/element/term.js +5 -2
- package/src/element/topLevelAssertion.js +44 -25
- package/src/element/topLevelMetaAssertion.js +7 -8
- package/src/element/type.js +30 -19
- package/src/element/typePrefix.js +19 -7
- package/src/element/variable.js +9 -22
- package/src/process/instantiate.js +60 -10
- package/src/utilities/element.js +105 -10
- package/src/utilities/json.js +13 -1
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
import Assertion from "../assertion";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { literally } from "../../utilities/context";
|
|
7
|
+
import { instantiateSatisfiesAssertion } from "../../process/instantiate";
|
|
8
|
+
import { signatureFromJSatisfiesAssertionNode, referenceFromJSatisfiesAssertionNode } from "../../utilities/element";
|
|
6
9
|
|
|
7
10
|
export default define(class SatisfiesAssertion extends Assertion {
|
|
8
11
|
constructor(context, string, node, signature, reference) {
|
|
@@ -155,8 +158,6 @@ export default define(class SatisfiesAssertion extends Assertion {
|
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
toJSON() {
|
|
158
|
-
debugger
|
|
159
|
-
|
|
160
161
|
const { name } = this.constructor,
|
|
161
162
|
string = this.getString(),
|
|
162
163
|
json = {
|
|
@@ -175,7 +176,17 @@ export default define(class SatisfiesAssertion extends Assertion {
|
|
|
175
176
|
const { name } = json;
|
|
176
177
|
|
|
177
178
|
if (this.name === name) {
|
|
178
|
-
|
|
179
|
+
literally((context) => {
|
|
180
|
+
const { string } = json,
|
|
181
|
+
definedAssertionNode = instantiateSatisfiesAssertion(string, context),
|
|
182
|
+
node = definedAssertionNode, ///
|
|
183
|
+
signature = signatureFromJSatisfiesAssertionNode(definedAssertionNode, context),
|
|
184
|
+
reference = referenceFromJSatisfiesAssertionNode(definedAssertionNode, context);
|
|
185
|
+
|
|
186
|
+
context = null;
|
|
187
|
+
|
|
188
|
+
satisfiesAssertion = new SatisfiesAssertion(context, string, node, signature, reference);
|
|
189
|
+
}, context);
|
|
179
190
|
}
|
|
180
191
|
|
|
181
192
|
return satisfiesAssertion;
|
|
@@ -7,7 +7,6 @@ import Assertion from "../assertion";
|
|
|
7
7
|
import { define } from "../../elements";
|
|
8
8
|
import { literally } from "../../utilities/context";
|
|
9
9
|
import { unifyStatement } from "../../process/unify";
|
|
10
|
-
import { statementsToStatementsJSON } from "../../utilities/json";
|
|
11
10
|
import { instantiateSubproofAssertion } from "../../process/instantiate";
|
|
12
11
|
|
|
13
12
|
const { match } = arrayUtilities;
|
|
@@ -116,13 +115,10 @@ export default define(class SubproofAssertion extends Assertion {
|
|
|
116
115
|
|
|
117
116
|
toJSON() {
|
|
118
117
|
const { name } = this.constructor,
|
|
119
|
-
statementJSON = statementsToStatementsJSON(this.statements),
|
|
120
|
-
statements = statementJSON, ///
|
|
121
118
|
string = this.getString(),
|
|
122
119
|
json = {
|
|
123
120
|
name,
|
|
124
|
-
string
|
|
125
|
-
statements
|
|
121
|
+
string
|
|
126
122
|
};
|
|
127
123
|
|
|
128
124
|
return json;
|
|
@@ -142,6 +138,8 @@ export default define(class SubproofAssertion extends Assertion {
|
|
|
142
138
|
statements = statementsFromSubproofAssertionNode(subproofAssertionNode, context),
|
|
143
139
|
node = subproofAssertionNode; ///
|
|
144
140
|
|
|
141
|
+
context = null;
|
|
142
|
+
|
|
145
143
|
subproorAssertion = new SubproofAssertion(context, string, node, statements);
|
|
146
144
|
}, context);
|
|
147
145
|
}
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
import Assertion from "../assertion";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { literally } from "../../utilities/context";
|
|
7
|
+
import { typeFromJSON } from "../../utilities/json";
|
|
8
|
+
import { termFromTypeAssertionNode } from "../../utilities/element";
|
|
9
|
+
import { instantiateSubproofAssertion } from "../../process/instantiate";
|
|
6
10
|
import { variableAssignmentFromTypeAssertion } from "../../process/assign";
|
|
7
|
-
import {termToTermJSON} from "../../utilities/json";
|
|
8
11
|
|
|
9
12
|
export default define(class TypeAssertion extends Assertion {
|
|
10
13
|
constructor(context, string, node, term, type) {
|
|
@@ -190,18 +193,13 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
toJSON() {
|
|
193
|
-
debugger
|
|
194
|
-
|
|
195
196
|
const { name } = this.constructor,
|
|
196
|
-
termJSON = termToTermJSON(this.term),
|
|
197
197
|
typeJSON = typeToTypeJSON(this.type),
|
|
198
|
-
term = termJSON, ///
|
|
199
198
|
type = typeJSON, ///
|
|
200
199
|
string = this.getString(),
|
|
201
200
|
json = {
|
|
202
|
-
string,
|
|
203
201
|
name,
|
|
204
|
-
|
|
202
|
+
string,
|
|
205
203
|
type
|
|
206
204
|
};
|
|
207
205
|
|
|
@@ -216,7 +214,17 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
216
214
|
const { name } = json;
|
|
217
215
|
|
|
218
216
|
if (this.name === name) {
|
|
219
|
-
|
|
217
|
+
literally((context) => {
|
|
218
|
+
const { string } = json,
|
|
219
|
+
typeAssertionNode = instantiateSubproofAssertion(string, context),
|
|
220
|
+
term = termFromTypeAssertionNode(typeAssertionNode, context),
|
|
221
|
+
type = typeFromJSON(json, context),
|
|
222
|
+
node = typeAssertionNode; ///
|
|
223
|
+
|
|
224
|
+
context = null;
|
|
225
|
+
|
|
226
|
+
typeAssertion = new TypeAssertion(context, string, node, term, type);
|
|
227
|
+
}, context);
|
|
220
228
|
}
|
|
221
229
|
|
|
222
230
|
return typeAssertion;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { literally } from "../utilities/context";
|
|
7
|
+
import { instantiateAssumption } from "../process/instantiate";
|
|
6
8
|
import { unifyStatementIntrinsically } from "../process/unify";
|
|
7
|
-
import { referenceFromJSON, referenceToReferenceJSON } from "../utilities/json";
|
|
8
9
|
|
|
9
10
|
export default define(class Assumption extends Element {
|
|
10
11
|
constructor(context, string, node, reference, statement) {
|
|
@@ -319,12 +320,45 @@ export default define(class Assumption extends Element {
|
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
toJSON() {
|
|
322
|
-
|
|
323
|
+
const string = this.getString(),
|
|
324
|
+
json = {
|
|
325
|
+
string
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
return json;
|
|
323
329
|
}
|
|
324
330
|
|
|
325
331
|
static name = "Assumption";
|
|
326
332
|
|
|
327
333
|
static fromJSON(json, context) {
|
|
328
|
-
|
|
334
|
+
const assumption = literally((context) => {
|
|
335
|
+
const { string } = json,
|
|
336
|
+
assumptionNode = instantiateAssumption(string, context),
|
|
337
|
+
node = assumptionNode, ///
|
|
338
|
+
reference = referenceFromAssumptionNode(assumptionNode, context),
|
|
339
|
+
statement = statementFromAssumptionNode(assumptionNode, context);
|
|
340
|
+
|
|
341
|
+
context = null; ///
|
|
342
|
+
|
|
343
|
+
const assumption = new Assumption(context, string, node, reference, statement);
|
|
344
|
+
|
|
345
|
+
return assumption;
|
|
346
|
+
}, context);
|
|
347
|
+
|
|
348
|
+
return assumption;
|
|
329
349
|
}
|
|
330
350
|
});
|
|
351
|
+
|
|
352
|
+
function referenceFromAssumptionNode(assumptionNode, context) {
|
|
353
|
+
const metavariableNode = assumptionNode.getMetavariableNode(context),
|
|
354
|
+
reference = context.findReferenceByMetavariableNode(metavariableNode);
|
|
355
|
+
|
|
356
|
+
return reference;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function statementFromAssumptionNode(assumptionNode, context) {
|
|
360
|
+
const statementNode = assumptionNode.getStatementNode(),
|
|
361
|
+
statement = context.findStatementByStatementNode(statementNode);
|
|
362
|
+
|
|
363
|
+
return statement;
|
|
364
|
+
}
|
|
@@ -5,18 +5,14 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { attempt, literally } from "../utilities/context";
|
|
7
7
|
import { instantiateCombinator } from "../process/instantiate";
|
|
8
|
+
import { ephemeralContextFromJSON } from "../utilities/json";
|
|
8
9
|
import { verifyStatementAsCombinator } from "../process/verify";
|
|
10
|
+
import { statementFromCombinatorNode } from "../utilities/element";
|
|
9
11
|
import { unifyStatementWithCombinator } from "../process/unify";
|
|
10
|
-
import {
|
|
11
|
-
statementFromJSON,
|
|
12
|
-
ephemeralContextFromJSON,
|
|
13
|
-
statementToStatementJSON,
|
|
14
|
-
procedureCallToProcedureCallJSON
|
|
15
|
-
} from "../utilities/json";
|
|
16
12
|
|
|
17
13
|
export default define(class Combinator extends Element {
|
|
18
14
|
constructor(context, string, node, statement) {
|
|
19
|
-
super(context, string, node)
|
|
15
|
+
super(context, string, node);
|
|
20
16
|
|
|
21
17
|
this.statement = statement;
|
|
22
18
|
}
|
|
@@ -93,13 +89,10 @@ export default define(class Combinator extends Element {
|
|
|
93
89
|
|
|
94
90
|
context = contextJSON; ///
|
|
95
91
|
|
|
96
|
-
const
|
|
97
|
-
statement = statementJSON, ///
|
|
98
|
-
string = this.getString(),
|
|
92
|
+
const string = this.getString(),
|
|
99
93
|
json = {
|
|
100
94
|
context,
|
|
101
|
-
string
|
|
102
|
-
statement
|
|
95
|
+
string
|
|
103
96
|
};
|
|
104
97
|
|
|
105
98
|
return json;
|
|
@@ -112,7 +105,7 @@ export default define(class Combinator extends Element {
|
|
|
112
105
|
const { string } = json,
|
|
113
106
|
combinatorNode = instantiateCombinator(string, context),
|
|
114
107
|
node = combinatorNode, ///
|
|
115
|
-
statement =
|
|
108
|
+
statement = statementFromCombinatorNode(combinatorNode, context),
|
|
116
109
|
ephemeralContext = ephemeralContextFromJSON(json, context);
|
|
117
110
|
|
|
118
111
|
context = ephemeralContext; ///
|
|
@@ -5,7 +5,8 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { attempt, literally } from "../utilities/context";
|
|
7
7
|
import { instantiateConclusion } from "../process/instantiate";
|
|
8
|
-
import {
|
|
8
|
+
import { statementFromConclusionNode } from "../utilities/element";
|
|
9
|
+
import { ephemeralContextFromJSON, statementToStatementJSON } from "../utilities/json";
|
|
9
10
|
|
|
10
11
|
export default define(class Conclusion extends Element {
|
|
11
12
|
constructor(context, string, node, statement) {
|
|
@@ -131,13 +132,10 @@ export default define(class Conclusion extends Element {
|
|
|
131
132
|
|
|
132
133
|
context = contextJSON; ///
|
|
133
134
|
|
|
134
|
-
const
|
|
135
|
-
statement = statementJSON, ///
|
|
136
|
-
string = this.getString(),
|
|
135
|
+
const string = this.getString(),
|
|
137
136
|
json = {
|
|
138
137
|
context,
|
|
139
|
-
string
|
|
140
|
-
statement
|
|
138
|
+
string
|
|
141
139
|
};
|
|
142
140
|
|
|
143
141
|
return json;
|
|
@@ -150,7 +148,7 @@ export default define(class Conclusion extends Element {
|
|
|
150
148
|
const { string } = json,
|
|
151
149
|
conclusionNode = instantiateConclusion(string, context),
|
|
152
150
|
node = conclusionNode, ///
|
|
153
|
-
statement =
|
|
151
|
+
statement = statementFromConclusionNode(conclusionNode, context),
|
|
154
152
|
ephemeralContext = ephemeralContextFromJSON(json, context);
|
|
155
153
|
|
|
156
154
|
context = ephemeralContext; ///
|
|
@@ -6,8 +6,9 @@ import { define } from "../elements";
|
|
|
6
6
|
import { attempt, literally } from "../utilities/context";
|
|
7
7
|
import { instantiateConstructor } from "../process/instantiate";
|
|
8
8
|
import { verifyTermAsConstructor } from "../process/verify";
|
|
9
|
+
import { termFromConstructorNode } from "../utilities/element";
|
|
9
10
|
import { unifyTermWithConstructor } from "../process/unify";
|
|
10
|
-
import {
|
|
11
|
+
import { ephemeralContextFromJSON } from "../utilities/json";
|
|
11
12
|
|
|
12
13
|
export default define(class Constructor extends Element {
|
|
13
14
|
constructor(context, string, node, term) {
|
|
@@ -113,11 +114,17 @@ export default define(class Constructor extends Element {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
toJSON() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
let context;
|
|
118
|
+
|
|
119
|
+
context = this.getContext();
|
|
120
|
+
|
|
121
|
+
const contextJSON = context.toJSON();
|
|
122
|
+
|
|
123
|
+
context = contextJSON; ///
|
|
124
|
+
|
|
125
|
+
const string = this.getString(),
|
|
119
126
|
json = {
|
|
120
|
-
|
|
127
|
+
context,
|
|
121
128
|
string
|
|
122
129
|
};
|
|
123
130
|
|
|
@@ -131,7 +138,7 @@ export default define(class Constructor extends Element {
|
|
|
131
138
|
const { string } = json,
|
|
132
139
|
constructorNode = instantiateConstructor(string, context),
|
|
133
140
|
node = constructorNode, ///
|
|
134
|
-
term =
|
|
141
|
+
term = termFromConstructorNode(constructorNode, context),
|
|
135
142
|
ephemeralContext = ephemeralContextFromJSON(json, context);
|
|
136
143
|
|
|
137
144
|
context = ephemeralContext; ///
|
package/src/element/deduction.js
CHANGED
|
@@ -5,7 +5,8 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { attempt, literally } from "../utilities/context";
|
|
7
7
|
import { instantiateDeduction } from "../process/instantiate";
|
|
8
|
-
import {
|
|
8
|
+
import { ephemeralContextFromJSON } from "../utilities/json";
|
|
9
|
+
import { statementFromDeductionNode } from "../utilities/element";
|
|
9
10
|
|
|
10
11
|
export default define(class Deduction extends Element {
|
|
11
12
|
constructor(context, string, node, statement) {
|
|
@@ -156,13 +157,10 @@ export default define(class Deduction extends Element {
|
|
|
156
157
|
|
|
157
158
|
context = contextJSON; ///
|
|
158
159
|
|
|
159
|
-
const
|
|
160
|
-
statement = statementJSON, ///
|
|
161
|
-
string = this.getString(),
|
|
160
|
+
const string = this.getString(),
|
|
162
161
|
json = {
|
|
163
162
|
context,
|
|
164
|
-
string
|
|
165
|
-
statement
|
|
163
|
+
string
|
|
166
164
|
};
|
|
167
165
|
|
|
168
166
|
return json;
|
|
@@ -173,9 +171,9 @@ export default define(class Deduction extends Element {
|
|
|
173
171
|
static fromJSON(json, context) {
|
|
174
172
|
const duduction = literally((context) => {
|
|
175
173
|
const { string } = json,
|
|
176
|
-
|
|
177
|
-
node =
|
|
178
|
-
statement =
|
|
174
|
+
deductionNode = instantiateDeduction(string, context),
|
|
175
|
+
node = deductionNode, ///
|
|
176
|
+
statement = statementFromDeductionNode(deductionNode, context),
|
|
179
177
|
ephemeralContext = ephemeralContextFromJSON(json, context);
|
|
180
178
|
|
|
181
179
|
context = ephemeralContext; ///
|
package/src/element/equality.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { literally } from "../utilities/context";
|
|
6
7
|
import { equateTerms } from "../process/equate";
|
|
8
|
+
import { instantiateEquality } from "../process/instantiate";
|
|
7
9
|
import { equalityAssignmentFromEquality, leftVariableAssignmentFromEquality, rightVariableAssignmentFromEquality } from "../process/assign";
|
|
8
10
|
|
|
9
11
|
export default define(class Equality extends Element {
|
|
@@ -271,4 +273,45 @@ export default define(class Equality extends Element {
|
|
|
271
273
|
}
|
|
272
274
|
|
|
273
275
|
static name = "Equality";
|
|
276
|
+
|
|
277
|
+
toJSON() {
|
|
278
|
+
const string = this.getString(),
|
|
279
|
+
json = {
|
|
280
|
+
string
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
return json;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
static fromJSON(json, context) {
|
|
287
|
+
const equality = literally((context) => {
|
|
288
|
+
const { string } = json,
|
|
289
|
+
equalityNode = instantiateEquality(string, context),
|
|
290
|
+
node = equalityNode, ///
|
|
291
|
+
leftTerm = leftTermFromEqualityNode(equalityNode, context),
|
|
292
|
+
rightTerm = rightTermFromEqualityNode(equalityNode, context);
|
|
293
|
+
|
|
294
|
+
context = null;
|
|
295
|
+
|
|
296
|
+
const equality = new Equality(context, string, node, leftTerm, rightTerm);
|
|
297
|
+
|
|
298
|
+
return equality;
|
|
299
|
+
}, context);
|
|
300
|
+
|
|
301
|
+
return equality;
|
|
302
|
+
}
|
|
274
303
|
});
|
|
304
|
+
|
|
305
|
+
function leftTermFromEqualityNode(equalityNode, context) {
|
|
306
|
+
const leftTermNode = equalityNode.getLeftTermNode(),
|
|
307
|
+
leftTerm = context.findTermByTermNode(leftTermNode);
|
|
308
|
+
|
|
309
|
+
return leftTerm;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function rightTermFromEqualityNode(equalityNode, context) {
|
|
313
|
+
const rightTermNode = equalityNode.getLeftTermNode(),
|
|
314
|
+
rightTerm = context.findTermByTermNode(rightTermNode);
|
|
315
|
+
|
|
316
|
+
return rightTerm;
|
|
317
|
+
}
|
package/src/element/frame.js
CHANGED
|
@@ -6,8 +6,8 @@ import { define } from "../elements";
|
|
|
6
6
|
import { literally } from "../utilities/context";
|
|
7
7
|
import { instantiateFrame } from "../process/instantiate";
|
|
8
8
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
9
|
+
import { metavariableFromFrameNode } from "../utilities/element";
|
|
9
10
|
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
10
|
-
import { assumptionsFromJSON, metavariableFromJSON, assumptionsToAssumptionsJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
11
11
|
|
|
12
12
|
export default define(class Frame extends Element {
|
|
13
13
|
constructor(context, string, node, assumptions, metavariable) {
|
|
@@ -348,15 +348,9 @@ export default define(class Frame extends Element {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
toJSON() {
|
|
351
|
-
const
|
|
352
|
-
assumptionsJSON = assumptionsToAssumptionsJSON(this.assumptions),
|
|
353
|
-
metavariable = metavariableJSON, ///
|
|
354
|
-
assumptions = assumptionsJSON, ///
|
|
355
|
-
string = this.getString(),
|
|
351
|
+
const string = this.getString(),
|
|
356
352
|
json = {
|
|
357
|
-
string
|
|
358
|
-
assumptions,
|
|
359
|
-
metavariable
|
|
353
|
+
string
|
|
360
354
|
};
|
|
361
355
|
|
|
362
356
|
return json;
|
|
@@ -369,9 +363,12 @@ export default define(class Frame extends Element {
|
|
|
369
363
|
const { string } = json,
|
|
370
364
|
frameNode = instantiateFrame(string, context),
|
|
371
365
|
node = frameNode, ///
|
|
372
|
-
assumptions =
|
|
373
|
-
metavariable =
|
|
374
|
-
|
|
366
|
+
assumptions = assumptionsFromFrameNode(frameNode, context),
|
|
367
|
+
metavariable = metavariableFromFrameNode(frameNode, context);
|
|
368
|
+
|
|
369
|
+
context = null;
|
|
370
|
+
|
|
371
|
+
const frame = new Frame(context, string, node, assumptions, metavariable);
|
|
375
372
|
|
|
376
373
|
return frame;
|
|
377
374
|
}, context);
|
|
@@ -379,3 +376,15 @@ export default define(class Frame extends Element {
|
|
|
379
376
|
return frame;
|
|
380
377
|
}
|
|
381
378
|
});
|
|
379
|
+
|
|
380
|
+
function assumptionsFromFrameNode(frameNode, context) {
|
|
381
|
+
const assumptionNodes = frameNode.getAssumptionNodes(),
|
|
382
|
+
assumptions = assumptionNodes.map((assumptionNode) => {
|
|
383
|
+
const assumption = context.findAssumptionByAssumptionNode(assumptionNode);
|
|
384
|
+
|
|
385
|
+
return assumption;
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
return assumptions;
|
|
389
|
+
}
|
|
390
|
+
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {
|
|
6
|
+
import {literally} from "../utilities/context";
|
|
7
|
+
import { instantiateHypothesis } from "../process/instantiate";
|
|
8
|
+
import { statementFromHypothesisNode } from "../utilities/element";
|
|
7
9
|
|
|
8
10
|
export default define(class Hypothesis extends Element {
|
|
9
11
|
constructor(context, string, node, statement) {
|
|
@@ -87,12 +89,9 @@ export default define(class Hypothesis extends Element {
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
toJSON() {
|
|
90
|
-
const
|
|
91
|
-
statement = statementJSON, ///
|
|
92
|
-
string = this.getString(),
|
|
92
|
+
const string = this.getString(),
|
|
93
93
|
json = {
|
|
94
|
-
string
|
|
95
|
-
statement
|
|
94
|
+
string
|
|
96
95
|
};
|
|
97
96
|
|
|
98
97
|
return json;
|
|
@@ -101,6 +100,19 @@ export default define(class Hypothesis extends Element {
|
|
|
101
100
|
static name = "Hypothesis";
|
|
102
101
|
|
|
103
102
|
static fromJSON(json, context) {
|
|
104
|
-
|
|
103
|
+
const hypothesis = literally((context) => {
|
|
104
|
+
const { string } = json,
|
|
105
|
+
hypothesisNode = instantiateHypothesis(string, context),
|
|
106
|
+
node = hypothesisNode, ///
|
|
107
|
+
statement = statementFromHypothesisNode(hypothesisNode, context);
|
|
108
|
+
|
|
109
|
+
context = null;
|
|
110
|
+
|
|
111
|
+
const hypothesis = new Hypothesis(context, string, node, statement);
|
|
112
|
+
|
|
113
|
+
return hypothesis;
|
|
114
|
+
}, context);
|
|
115
|
+
|
|
116
|
+
return hypothesis;
|
|
105
117
|
}
|
|
106
118
|
});
|
package/src/element/judgement.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
|
+
import elements from "../elements";
|
|
6
|
+
|
|
5
7
|
import { define } from "../elements";
|
|
8
|
+
import { literally } from "../utilities/context";
|
|
9
|
+
import { instantiateJudgement } from "../process/instantiate";
|
|
6
10
|
import { judgementAssignmentFromJudgement } from "../process/assign";
|
|
7
11
|
|
|
8
12
|
export default define(class Judgement extends Element {
|
|
@@ -206,9 +210,50 @@ export default define(class Judgement extends Element {
|
|
|
206
210
|
context.addAssignment(assignment);
|
|
207
211
|
}
|
|
208
212
|
|
|
213
|
+
toJSON() {
|
|
214
|
+
const string = this.getString(),
|
|
215
|
+
json = {
|
|
216
|
+
string
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
return json;
|
|
220
|
+
}
|
|
221
|
+
|
|
209
222
|
static name = "Judgement";
|
|
223
|
+
|
|
224
|
+
static fromJSON(json, context) {
|
|
225
|
+
const judgement = literally((context) => {
|
|
226
|
+
const { string } = json,
|
|
227
|
+
judgementNode = instantiateJudgement(string, context),
|
|
228
|
+
node = judgementNode, ///
|
|
229
|
+
frame = frameFromJudgementNode(judgementNode, context),
|
|
230
|
+
assumption = assumptionFromJudgementNode(judgementNode, context);
|
|
231
|
+
|
|
232
|
+
context = null;
|
|
233
|
+
|
|
234
|
+
const judgement = new Judgement(context, string, node, frame, assumption);
|
|
235
|
+
|
|
236
|
+
return judgement;
|
|
237
|
+
}, context);
|
|
238
|
+
|
|
239
|
+
return judgement;
|
|
240
|
+
}
|
|
210
241
|
});
|
|
211
242
|
|
|
243
|
+
function frameFromJudgementNode(judgementNode, context) {
|
|
244
|
+
const frameNode = judgementNode.getFrameNode(),
|
|
245
|
+
frame = context.findFrameByFrameNode(frameNode);
|
|
246
|
+
|
|
247
|
+
return frame;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function assumptionFromJudgementNode(judgementNode, context) {
|
|
251
|
+
const assumptionNode = judgementNode.getAssumptionNode(),
|
|
252
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode);
|
|
253
|
+
|
|
254
|
+
return assumption;
|
|
255
|
+
}
|
|
256
|
+
|
|
212
257
|
function referenceFromMetavariable(metavariable, context) {
|
|
213
258
|
const { Reference } = elements,
|
|
214
259
|
metavariableNode = metavariable.getNode(),
|
package/src/element/label.js
CHANGED
|
@@ -5,8 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { literally } from "../utilities/context";
|
|
7
7
|
import { instantiateLabel } from "../process/instantiate";
|
|
8
|
-
import {
|
|
9
|
-
import { metavariableFromMetavariableNode } from "../utilities/element";
|
|
8
|
+
import { metavariableFromLabelNode } from "../utilities/element";
|
|
10
9
|
|
|
11
10
|
export default define(class Label extends Element {
|
|
12
11
|
constructor(context, string, node, metavariable) {
|
|
@@ -42,7 +41,7 @@ export default define(class Label extends Element {
|
|
|
42
41
|
return comparesToReference;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
verify(
|
|
44
|
+
verify() {
|
|
46
45
|
let verifies = false;
|
|
47
46
|
|
|
48
47
|
const context = this.getContext(),
|
|
@@ -50,38 +49,55 @@ export default define(class Label extends Element {
|
|
|
50
49
|
|
|
51
50
|
context.trace(`Verifying the '${labelString}' label...`);
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
const metavariableVerifies = this.verifyMetavariable();
|
|
54
53
|
|
|
55
|
-
if (
|
|
56
|
-
const metavariableName = this.getMetavariableName()
|
|
54
|
+
if (metavariableVerifies) {
|
|
55
|
+
const metavariableName = this.getMetavariableName(),
|
|
56
|
+
labelPresent = context.isLabelPresentByMetavariableName(metavariableName);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
if (!labelPresent) {
|
|
59
|
+
verifies = true;
|
|
60
|
+
} else {
|
|
61
|
+
context.debug(`The '${labelString}' label is already present.`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
if (verifies) {
|
|
66
|
+
context.debug(`...verified the '${labelString}' label.`);
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
return verifies;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
verifyMetavariable() {
|
|
73
|
+
let verifies = false;
|
|
74
|
+
|
|
75
|
+
const context = this.getContext(),
|
|
76
|
+
labelString = this.getString(), ///
|
|
77
|
+
metavariableString = this.metavariable.getString();
|
|
78
|
+
|
|
79
|
+
context.trace(`Verifying the '${labelString}' label's '${metavariableString}' metavariable...`);
|
|
80
|
+
|
|
81
|
+
const metavariableName = this.getMetavariableName(),
|
|
82
|
+
metavariablePresent = context.isMetavariablePresentByMetavariableName(metavariableName);
|
|
83
|
+
|
|
84
|
+
if (!metavariablePresent) {
|
|
68
85
|
verifies = true;
|
|
86
|
+
} else {
|
|
87
|
+
context.debug(`The '${metavariableString}' metavariable is already present.`);
|
|
69
88
|
}
|
|
70
89
|
|
|
71
90
|
if (verifies) {
|
|
72
|
-
context.debug(`...verified the '${labelString}' label.`);
|
|
91
|
+
context.debug(`...verified the '${labelString}' label's '${metavariableString}' metavariable.`);
|
|
73
92
|
}
|
|
74
93
|
|
|
75
94
|
return verifies;
|
|
76
95
|
}
|
|
77
96
|
|
|
78
97
|
toJSON() {
|
|
79
|
-
const
|
|
80
|
-
metavariable = metavariableJSON, ///
|
|
81
|
-
string = this.getString(),
|
|
98
|
+
const string = this.getString(),
|
|
82
99
|
json = {
|
|
83
|
-
string
|
|
84
|
-
metavariable
|
|
100
|
+
string
|
|
85
101
|
};
|
|
86
102
|
|
|
87
103
|
return json;
|
|
@@ -103,10 +119,3 @@ export default define(class Label extends Element {
|
|
|
103
119
|
return label;
|
|
104
120
|
}
|
|
105
121
|
});
|
|
106
|
-
|
|
107
|
-
function metavariableFromLabelNode(labelNode, context) {
|
|
108
|
-
const metavariableNode = labelNode.getMetavariableNode(),
|
|
109
|
-
metavariable = metavariableFromMetavariableNode(metavariableNode, context);
|
|
110
|
-
|
|
111
|
-
return metavariable;
|
|
112
|
-
}
|
package/src/element/metaType.js
CHANGED