occam-verify-cli 1.0.707 → 1.0.708
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/element/assertion/type.js +5 -5
- package/lib/element/combinator.js +16 -3
- package/lib/element/constructor.js +30 -16
- package/lib/process/instantiate.js +9 -3
- package/lib/process/unify.js +5 -7
- package/lib/utilities/element.js +9 -2
- package/package.json +1 -1
- package/src/element/assertion/type.js +3 -3
- package/src/element/combinator.js +23 -2
- package/src/element/constructor.js +44 -16
- package/src/process/instantiate.js +6 -2
- package/src/process/unify.js +5 -7
- package/src/utilities/element.js +8 -1
package/package.json
CHANGED
|
@@ -4,9 +4,9 @@ import Assertion from "../assertion";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { literally } from "../../utilities/context";
|
|
7
|
-
import {
|
|
7
|
+
import { instantiateTypeAssertion } from "../../process/instantiate";
|
|
8
8
|
import { termFromTypeAssertionNode } from "../../utilities/element";
|
|
9
|
-
import {
|
|
9
|
+
import { typeFromJSON, typeToTypeJSON } from "../../utilities/json";
|
|
10
10
|
import { variableAssignmentFromTypeAssertion } from "../../process/assign";
|
|
11
11
|
|
|
12
12
|
export default define(class TypeAssertion extends Assertion {
|
|
@@ -216,7 +216,7 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
216
216
|
if (this.name === name) {
|
|
217
217
|
literally((context) => {
|
|
218
218
|
const { string } = json,
|
|
219
|
-
typeAssertionNode =
|
|
219
|
+
typeAssertionNode = instantiateTypeAssertion(string, context),
|
|
220
220
|
term = termFromTypeAssertionNode(typeAssertionNode, context),
|
|
221
221
|
type = typeFromJSON(json, context),
|
|
222
222
|
node = typeAssertionNode; ///
|
|
@@ -36,9 +36,9 @@ export default define(class Combinator extends Element {
|
|
|
36
36
|
context.trace(`Verifying the '${combinatorString}' combinator...`);
|
|
37
37
|
|
|
38
38
|
attempt((context) => {
|
|
39
|
-
const
|
|
39
|
+
const statementVerifies = this.verifyStatement(context);
|
|
40
40
|
|
|
41
|
-
if (
|
|
41
|
+
if (statementVerifies) {
|
|
42
42
|
this.setContext(context);
|
|
43
43
|
|
|
44
44
|
verifies = true;
|
|
@@ -52,6 +52,27 @@ export default define(class Combinator extends Element {
|
|
|
52
52
|
return verifies;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
verifyStatement(context) {
|
|
56
|
+
let statementVerifies = false;
|
|
57
|
+
|
|
58
|
+
const statementString = this.statement.getString(),
|
|
59
|
+
combinatorString = this.getString(); ///
|
|
60
|
+
|
|
61
|
+
context.trace(`Verifying the '${combinatorString}' combinator's '${statementString}' statement...`);
|
|
62
|
+
|
|
63
|
+
const statementVerifiesAsCombinator = verifyStatementAsCombinator(this.statement, context);
|
|
64
|
+
|
|
65
|
+
if (statementVerifiesAsCombinator) {
|
|
66
|
+
statementVerifies = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (statementVerifies) {
|
|
70
|
+
context.debug(`...verified the '${combinatorString}' combinator's '${statementString}' statement.`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return statementVerifies;
|
|
74
|
+
}
|
|
75
|
+
|
|
55
76
|
unifyStatement(statement, stated, context) {
|
|
56
77
|
let statementUnifies;
|
|
57
78
|
|
|
@@ -8,19 +8,24 @@ import { instantiateConstructor } from "../process/instantiate";
|
|
|
8
8
|
import { verifyTermAsConstructor } from "../process/verify";
|
|
9
9
|
import { termFromConstructorNode } from "../utilities/element";
|
|
10
10
|
import { unifyTermWithConstructor } from "../process/unify";
|
|
11
|
-
import { termToTermJSON, ephemeralContextFromJSON } from "../utilities/json";
|
|
11
|
+
import { typeFromJSON, termToTermJSON, typeToTypeJSON, ephemeralContextFromJSON } from "../utilities/json";
|
|
12
12
|
|
|
13
13
|
export default define(class Constructor extends Element {
|
|
14
|
-
constructor(context, string, node, term) {
|
|
15
|
-
super(context, string, node);
|
|
14
|
+
constructor(context, string, node, term, type) {
|
|
15
|
+
super(context, string, node, type);
|
|
16
16
|
|
|
17
17
|
this.term = term;
|
|
18
|
+
this.type = type;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
getTerm() {
|
|
21
22
|
return this.term;
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
getType() {
|
|
26
|
+
return this.type;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
getConclusionNode() {
|
|
25
30
|
const node = this.getNode(),
|
|
26
31
|
constructorNode = node; ///
|
|
@@ -28,15 +33,12 @@ export default define(class Constructor extends Element {
|
|
|
28
33
|
return constructorNode;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
getType() { return this.term.getType(); }
|
|
32
|
-
|
|
33
36
|
getString(includeType = true) {
|
|
34
37
|
let string;
|
|
35
38
|
|
|
36
39
|
if (includeType) {
|
|
37
|
-
const
|
|
38
|
-
typeString = type.getString()
|
|
39
|
-
termString = this.term.getString();
|
|
40
|
+
const termString = this.term.getString(),
|
|
41
|
+
typeString = this.type.getString();
|
|
40
42
|
|
|
41
43
|
string = `${termString}.${typeString}`;
|
|
42
44
|
} else {
|
|
@@ -46,7 +48,9 @@ export default define(class Constructor extends Element {
|
|
|
46
48
|
return string;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
setType(type) {
|
|
51
|
+
setType(type) {
|
|
52
|
+
this.type = type;
|
|
53
|
+
}
|
|
50
54
|
|
|
51
55
|
verify(context) {
|
|
52
56
|
let verifies = false;
|
|
@@ -57,9 +61,9 @@ export default define(class Constructor extends Element {
|
|
|
57
61
|
context.trace(`Verifying the '${constructorString}' constructor...`);
|
|
58
62
|
|
|
59
63
|
attempt((context) => {
|
|
60
|
-
const
|
|
64
|
+
const termVerifies = this.verifyTerm(context);
|
|
61
65
|
|
|
62
|
-
if (
|
|
66
|
+
if (termVerifies) {
|
|
63
67
|
this.setContext(context);
|
|
64
68
|
|
|
65
69
|
verifies = true;
|
|
@@ -73,6 +77,28 @@ export default define(class Constructor extends Element {
|
|
|
73
77
|
return verifies;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
verifyTerm(context) {
|
|
81
|
+
let termVerifies = false;
|
|
82
|
+
|
|
83
|
+
const termString = this.term.getString(),
|
|
84
|
+
includeType = false,
|
|
85
|
+
constructorString = this.getString(includeType);
|
|
86
|
+
|
|
87
|
+
context.trace(`Verifying the '${constructorString}' constructor's '${termString}' term...`);
|
|
88
|
+
|
|
89
|
+
const termVerifiesAsConstructor = verifyTermAsConstructor(this.term, context);
|
|
90
|
+
|
|
91
|
+
if (termVerifiesAsConstructor) {
|
|
92
|
+
termVerifies = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (termVerifies) {
|
|
96
|
+
context.debug(`...verified the '${constructorString}' constructor's '${termString}' term.`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return termVerifies;
|
|
100
|
+
}
|
|
101
|
+
|
|
76
102
|
unifyTerm(term, context, validateForwards) {
|
|
77
103
|
let termUnifies = false;
|
|
78
104
|
|
|
@@ -95,9 +121,7 @@ export default define(class Constructor extends Element {
|
|
|
95
121
|
if (termUnifiesWithConstructor) {
|
|
96
122
|
let validatesForwards;
|
|
97
123
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
term.setType(type);
|
|
124
|
+
term.setType(this.type);
|
|
101
125
|
|
|
102
126
|
validatesForwards = validateForwards();
|
|
103
127
|
|
|
@@ -122,12 +146,15 @@ export default define(class Constructor extends Element {
|
|
|
122
146
|
|
|
123
147
|
const includeType = false,
|
|
124
148
|
termJSON = termToTermJSON(this.term),
|
|
149
|
+
typeJSON = typeToTypeJSON(this.type),
|
|
125
150
|
string = this.getString(includeType),
|
|
126
151
|
term = termJSON, ///
|
|
152
|
+
type = typeJSON, ///
|
|
127
153
|
json = {
|
|
128
154
|
context,
|
|
129
155
|
string,
|
|
130
|
-
term
|
|
156
|
+
term,
|
|
157
|
+
type
|
|
131
158
|
};
|
|
132
159
|
|
|
133
160
|
return json;
|
|
@@ -141,11 +168,12 @@ export default define(class Constructor extends Element {
|
|
|
141
168
|
constructorNode = instantiateConstructor(string, context),
|
|
142
169
|
node = constructorNode, ///
|
|
143
170
|
term = termFromConstructorNode(constructorNode, context),
|
|
171
|
+
type = typeFromJSON(json, context),
|
|
144
172
|
ephemeralContext = ephemeralContextFromJSON(json, context);
|
|
145
173
|
|
|
146
174
|
context = ephemeralContext; ///
|
|
147
175
|
|
|
148
|
-
const constructor = new Constructor(context, string, node, term);
|
|
176
|
+
const constructor = new Constructor(context, string, node, term, type);
|
|
149
177
|
|
|
150
178
|
return constructor;
|
|
151
179
|
|
|
@@ -23,6 +23,7 @@ import { TERM_RULE_NAME,
|
|
|
23
23
|
CONSTRUCTOR_RULE_NAME,
|
|
24
24
|
EQUIVALENCE_RULE_NAME,
|
|
25
25
|
METAVARIABLE_RULE_NAME,
|
|
26
|
+
TYPE_ASSERTION_RULE_NAME,
|
|
26
27
|
PROCEDURE_CALL_RULE_NAME,
|
|
27
28
|
PROPERTY_RELATION_RULE_NAME,
|
|
28
29
|
DEFINED_ASSERTION_RULE_NAME,
|
|
@@ -57,7 +58,8 @@ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
|
|
|
57
58
|
constructorPlaceholderRule = ruleFromRuleName(CONSTRUCTOR_RULE_NAME),
|
|
58
59
|
equivalencePlaceholderRule = ruleFromRuleName(EQUIVALENCE_RULE_NAME),
|
|
59
60
|
metavariablePlaceholderRule = ruleFromRuleName(METAVARIABLE_RULE_NAME),
|
|
60
|
-
|
|
61
|
+
typeAssertionPlaceholderRule = ruleFromRuleName(TYPE_ASSERTION_RULE_NAME),
|
|
62
|
+
procedureCallPlaceholderRule = ruleFromRuleName(PROCEDURE_CALL_RULE_NAME),
|
|
61
63
|
propertyRelationlaceholderRule = ruleFromRuleName(PROPERTY_RELATION_RULE_NAME),
|
|
62
64
|
definedAssertionPlaceholderRule = ruleFromRuleName(DEFINED_ASSERTION_RULE_NAME),
|
|
63
65
|
termSubstitutionPlaceholderRule = ruleFromRuleName(TERM_SUBSTITUTION_RULE_NAME),
|
|
@@ -133,7 +135,9 @@ export function instantiateEquivalence(string, context) { return instantiate(equ
|
|
|
133
135
|
|
|
134
136
|
export function instantiateMetavariable(string, context) { return instantiate(metavariablePlaceholderRule, string, context); }
|
|
135
137
|
|
|
136
|
-
export function
|
|
138
|
+
export function instantiateTypeAssertion(string, context) { return instantiate(typeAssertionPlaceholderRule, string, context); }
|
|
139
|
+
|
|
140
|
+
export function instantiateProcedureCall(string, context) { return instantiate(procedureCallPlaceholderRule, string, context); }
|
|
137
141
|
|
|
138
142
|
export function instantiatePropertyRelation(string, context) { return instantiate(propertyRelationlaceholderRule, string, context); }
|
|
139
143
|
|
package/src/process/unify.js
CHANGED
|
@@ -234,15 +234,13 @@ class CombinatorPass extends ZipPass {
|
|
|
234
234
|
|
|
235
235
|
const type = context.findTypeByNominalTypeName(nominalTypeName);
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
context = specificContext; ///
|
|
237
|
+
context = specificContext; ///
|
|
239
238
|
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
const term = termFromTermNode(termNode, context),
|
|
240
|
+
termValidatesGivenType = term.validateGivenType(type, context);
|
|
242
241
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
242
|
+
if (termValidatesGivenType) {
|
|
243
|
+
success = true;
|
|
246
244
|
}
|
|
247
245
|
|
|
248
246
|
return success;
|
package/src/utilities/element.js
CHANGED
|
@@ -482,7 +482,8 @@ export function constructorFromConstructorNode(constructorNode, context) {
|
|
|
482
482
|
node = constructorNode, ///
|
|
483
483
|
string = context.nodeAsString(node),
|
|
484
484
|
term = termFromConstructorNode(constructorNode, context),
|
|
485
|
-
|
|
485
|
+
type = typeFromConstructorNode(constructorNode, context),
|
|
486
|
+
constructor = new Constructor(context, string, node, term, type);
|
|
486
487
|
|
|
487
488
|
return constructor;
|
|
488
489
|
}
|
|
@@ -998,6 +999,12 @@ export function termFromConstructorNode(ocnstructorNode, context) {
|
|
|
998
999
|
return term;
|
|
999
1000
|
}
|
|
1000
1001
|
|
|
1002
|
+
export function typeFromConstructorNode(ocnstructorNode, context) {
|
|
1003
|
+
const type = null;
|
|
1004
|
+
|
|
1005
|
+
return type;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1001
1008
|
export function assumptionsFromFrameNode(frameNode, context) {
|
|
1002
1009
|
const assumptionNodes = frameNode.getAssumptionNodes(),
|
|
1003
1010
|
assumptions = assumptionsFromAssumptionNodes(assumptionNodes, context);
|