occam-verify-cli 1.0.457 → 1.0.472
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 +13 -1
- package/lib/context/ephemeral.js +270 -0
- package/lib/context/file.js +102 -66
- package/lib/context/liminal.js +120 -0
- package/lib/context/literal.js +92 -0
- package/lib/context/nominal.js +15 -1
- package/lib/context/release.js +66 -7
- package/lib/context/scoped.js +48 -40
- package/lib/context/synthetic.js +133 -0
- package/lib/element/assertion/contained.js +66 -66
- package/lib/element/assertion/defined.js +32 -32
- package/lib/element/assertion/property.js +39 -39
- package/lib/element/assertion/satisfies.js +22 -22
- package/lib/element/assumption.js +5 -8
- package/lib/element/conclusion.js +14 -13
- package/lib/element/constructor.js +2 -2
- package/lib/element/deduction.js +14 -13
- package/lib/element/derivation.js +3 -3
- package/lib/element/equality.js +5 -5
- package/lib/element/equivalence.js +112 -107
- package/lib/element/equivalences.js +24 -10
- package/lib/element/error.js +3 -3
- package/lib/element/frame.js +38 -21
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +6 -5
- package/lib/element/metaType.js +1 -2
- package/lib/element/metavariable.js +46 -35
- package/lib/element/parameter.js +13 -5
- package/lib/element/procedureCall.js +16 -16
- package/lib/element/proof.js +14 -13
- package/lib/element/proofAssertion/premise.js +41 -30
- package/lib/element/proofAssertion/step.js +39 -35
- package/lib/element/proofAssertion/supposition.js +43 -32
- package/lib/element/proofAssertion.js +19 -5
- package/lib/element/propertyRelation.js +2 -2
- package/lib/element/reference.js +50 -9
- package/lib/element/rule.js +26 -28
- package/lib/element/section.js +2 -2
- package/lib/element/signature.js +9 -6
- package/lib/element/statement.js +44 -31
- package/lib/element/subproof.js +18 -17
- package/lib/element/substitution/frame.js +83 -46
- package/lib/element/substitution/reference.js +101 -19
- package/lib/element/substitution/statement.js +122 -75
- package/lib/element/substitution/term.js +93 -57
- package/lib/element/substitution.js +20 -69
- package/lib/element/substitutions.js +49 -34
- package/lib/element/term.js +30 -21
- package/lib/element/topLevelAssertion/axiom.js +8 -6
- package/lib/element/topLevelAssertion/conjecture.js +4 -4
- package/lib/element/topLevelAssertion/lemma.js +4 -4
- package/lib/element/topLevelAssertion/theorem.js +2 -2
- package/lib/element/topLevelAssertion.js +30 -23
- package/lib/element/topLevelMetaAssertion/metaLemma.js +2 -2
- package/lib/element/topLevelMetaAssertion/metatheorem.js +2 -2
- package/lib/element/topLevelMetaAssertion.js +16 -12
- package/lib/element/variable.js +30 -22
- package/lib/index.js +3 -3
- package/lib/main.js +3 -3
- package/lib/node/frame.js +2 -2
- package/lib/node/metavariable.js +4 -4
- package/lib/node/parameter.js +28 -7
- package/lib/node/substitution/frame.js +9 -31
- package/lib/node/substitution/reference.js +137 -0
- package/lib/node/substitution/statement.js +9 -31
- package/lib/node/substitution/term.js +9 -23
- package/lib/nonTerminalNodeMap.js +3 -2
- package/lib/process/instantiate.js +2 -14
- package/lib/process/unify.js +5 -5
- package/lib/tokenTypes.js +22 -0
- package/lib/utilities/context.js +54 -19
- package/lib/utilities/element.js +161 -336
- package/lib/utilities/instance.js +4 -4
- package/lib/utilities/string.js +18 -4
- package/lib/utilities/unification.js +24 -18
- package/lib/utilities/validation.js +31 -31
- package/package.json +2 -2
- package/src/constants.js +12 -0
- package/src/context/{transient.js → ephemeral.js} +15 -112
- package/src/context/file.js +66 -67
- package/src/context/liminal.js +67 -0
- package/src/context/{fragment.js → literal.js} +17 -4
- package/src/context/nominal.js +12 -0
- package/src/context/release.js +44 -6
- package/src/context/scoped.js +41 -31
- package/src/context/synthetic.js +60 -0
- package/src/element/assertion/contained.js +49 -47
- package/src/element/assertion/defined.js +29 -27
- package/src/element/assertion/property.js +35 -35
- package/src/element/assertion/satisfies.js +19 -18
- package/src/element/assumption.js +4 -10
- package/src/element/conclusion.js +16 -19
- package/src/element/constructor.js +1 -1
- package/src/element/deduction.js +16 -21
- package/src/element/derivation.js +2 -2
- package/src/element/equality.js +4 -4
- package/src/element/equivalence.js +115 -135
- package/src/element/equivalences.js +9 -7
- package/src/element/error.js +4 -2
- package/src/element/frame.js +50 -23
- package/src/element/hypothesis.js +1 -1
- package/src/element/judgement.js +9 -4
- package/src/element/metaType.js +0 -1
- package/src/element/metavariable.js +54 -53
- package/src/element/parameter.js +10 -5
- package/src/element/procedureCall.js +20 -18
- package/src/element/proof.js +14 -16
- package/src/element/proofAssertion/premise.js +46 -42
- package/src/element/proofAssertion/step.js +45 -40
- package/src/element/proofAssertion/supposition.js +56 -45
- package/src/element/proofAssertion.js +23 -5
- package/src/element/propertyRelation.js +1 -1
- package/src/element/reference.js +64 -16
- package/src/element/rule.js +31 -37
- package/src/element/section.js +1 -1
- package/src/element/signature.js +8 -8
- package/src/element/statement.js +51 -40
- package/src/element/subproof.js +16 -18
- package/src/element/substitution/frame.js +99 -42
- package/src/element/substitution/reference.js +120 -20
- package/src/element/substitution/statement.js +160 -89
- package/src/element/substitution/term.js +104 -63
- package/src/element/substitution.js +16 -58
- package/src/element/substitutions.js +43 -41
- package/src/element/term.js +37 -32
- package/src/element/topLevelAssertion/axiom.js +8 -6
- package/src/element/topLevelAssertion/conjecture.js +1 -2
- package/src/element/topLevelAssertion/lemma.js +2 -3
- package/src/element/topLevelAssertion/theorem.js +1 -1
- package/src/element/topLevelAssertion.js +31 -27
- package/src/element/topLevelMetaAssertion/metaLemma.js +1 -2
- package/src/element/topLevelMetaAssertion/metatheorem.js +1 -2
- package/src/element/topLevelMetaAssertion.js +15 -13
- package/src/element/variable.js +30 -31
- package/src/index.js +2 -1
- package/src/main.js +2 -1
- package/src/node/frame.js +1 -1
- package/src/node/metavariable.js +3 -3
- package/src/node/parameter.js +32 -5
- package/src/node/substitution/frame.js +6 -32
- package/src/node/substitution/reference.js +38 -0
- package/src/node/substitution/statement.js +6 -32
- package/src/node/substitution/term.js +6 -22
- package/src/nonTerminalNodeMap.js +3 -0
- package/src/process/instantiate.js +0 -8
- package/src/process/unify.js +4 -4
- package/src/tokenTypes.js +4 -0
- package/src/utilities/context.js +43 -17
- package/src/utilities/element.js +187 -401
- package/src/utilities/instance.js +3 -3
- package/src/utilities/string.js +21 -5
- package/src/utilities/unification.js +26 -23
- package/src/utilities/validation.js +47 -47
- package/lib/context/fragment.js +0 -77
- package/lib/context/transient.js +0 -371
- package/lib/log.js +0 -150
- package/lib/utilities/fragment.js +0 -23
- package/src/log.js +0 -118
- package/src/utilities/fragment.js +0 -11
package/src/element/variable.js
CHANGED
|
@@ -4,8 +4,8 @@ import Element from "../element";
|
|
|
4
4
|
import elements from "../elements";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { synthetically } from "../utilities/context";
|
|
8
|
+
import { typeToTypeJSON } from "../utilities/json";
|
|
9
9
|
|
|
10
10
|
export default define(class Variable extends Element {
|
|
11
11
|
constructor(context, string, node, type, identifier, propertyRelations) {
|
|
@@ -34,18 +34,26 @@ export default define(class Variable extends Element {
|
|
|
34
34
|
|
|
35
35
|
getTypeString() { return this.type.getString(); }
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
isIdentifierEqualTo(identifier) {
|
|
38
|
+
const identifierEqualTo = (this.identifier === identifier);
|
|
39
|
+
|
|
40
|
+
return identifierEqualTo;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
compareParamter(parameter) {
|
|
44
|
+
const identifier = parameter.getIdentifier(),
|
|
45
|
+
identifierEqualTo = this.isIdentifierEqualTo(identifier),
|
|
46
|
+
comparesToParamter = identifierEqualTo; ///
|
|
41
47
|
|
|
42
48
|
return comparesToParamter;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
compareVariableIdentifier(variableIdentifier) {
|
|
46
|
-
const
|
|
52
|
+
const identifier = variableIdentifier, ///
|
|
53
|
+
identifierEqualTo = this.isIdentifierEqualTo(identifier),
|
|
54
|
+
comparesToVariableIdentifier = identifierEqualTo; ///
|
|
47
55
|
|
|
48
|
-
return
|
|
56
|
+
return comparesToVariableIdentifier;
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
validate(context) {
|
|
@@ -103,27 +111,27 @@ export default define(class Variable extends Element {
|
|
|
103
111
|
unifyTerm(term, substitutions, generalContext, specificContext) {
|
|
104
112
|
let termUnifies = false;
|
|
105
113
|
|
|
106
|
-
const
|
|
114
|
+
const context = specificContext, ///
|
|
115
|
+
termString = term.getString(),
|
|
107
116
|
variableString = this.getString(); ///
|
|
108
117
|
|
|
109
|
-
|
|
118
|
+
context.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
|
|
110
119
|
|
|
111
|
-
let
|
|
112
|
-
variable;
|
|
120
|
+
let variable;
|
|
113
121
|
|
|
114
122
|
variable = this; ///
|
|
115
123
|
|
|
116
124
|
const substitution = substitutions.findSubstitutionByVariable(variable);
|
|
117
125
|
|
|
118
126
|
if (substitution !== null) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const substitutionTermEqualToTerm = substitution.isTermEqualToTerm(term, context);
|
|
127
|
+
const substitutionComparesToTerm = substitution.compareTerm(term, context);
|
|
122
128
|
|
|
123
|
-
if (
|
|
129
|
+
if (substitutionComparesToTerm) {
|
|
124
130
|
termUnifies = true;
|
|
125
131
|
}
|
|
126
132
|
} else {
|
|
133
|
+
let context;
|
|
134
|
+
|
|
127
135
|
context = generalContext; ///
|
|
128
136
|
|
|
129
137
|
const variableIdentifier = variable.getIdentifier();
|
|
@@ -141,18 +149,18 @@ export default define(class Variable extends Element {
|
|
|
141
149
|
termTypeEqualToOrSubTypeOfVariableType = termType.isEqualToOrSubTypeOf(variableType);
|
|
142
150
|
|
|
143
151
|
if (termTypeEqualToOrSubTypeOfVariableType) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
substitution = termSubstitution; ///
|
|
152
|
+
synthetically((context) => {
|
|
153
|
+
const { TermSubstitution } = elements;
|
|
147
154
|
|
|
148
|
-
|
|
155
|
+
TermSubstitution.fromTermAndVariable(term, variable, context);
|
|
156
|
+
}, generalContext, specificContext);
|
|
149
157
|
|
|
150
158
|
termUnifies = true;
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
|
|
154
162
|
if (termUnifies) {
|
|
155
|
-
|
|
163
|
+
context.debug(`...unified the '${termString}' term with the '${variableString}' variable.`);
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
return termUnifies;
|
|
@@ -173,15 +181,6 @@ export default define(class Variable extends Element {
|
|
|
173
181
|
static name = "Variable";
|
|
174
182
|
|
|
175
183
|
static fromJSON(json, context) {
|
|
176
|
-
|
|
177
|
-
variableNode = instantiateVariable(string, context),
|
|
178
|
-
variableIdentifier = variableNode.getVariableIdentifier(),
|
|
179
|
-
node = variableNode,
|
|
180
|
-
identifier = variableIdentifier, ///
|
|
181
|
-
type = typeFromJSON(json, context),
|
|
182
|
-
propertyRelations = [],
|
|
183
|
-
variable = new Variable(context, string, node, type, identifier, propertyRelations);
|
|
184
|
-
|
|
185
|
-
return variable;
|
|
184
|
+
///
|
|
186
185
|
}
|
|
187
186
|
});
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import "./preamble";
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { Log } from "occam-furtle";
|
|
6
|
+
|
|
6
7
|
export { default as FileContext } from "./context/file";
|
|
7
8
|
export { default as ReleaseContext } from "./context/release";
|
|
8
9
|
export { default as releaseUtilities } from "./utilities/release";
|
package/src/main.js
CHANGED
package/src/node/frame.js
CHANGED
|
@@ -22,7 +22,7 @@ export default class FrameNode extends NonTerminalNode {
|
|
|
22
22
|
|
|
23
23
|
const metavariableNode = this.getMetavariableNode();
|
|
24
24
|
|
|
25
|
-
if (
|
|
25
|
+
if (metavariableNode !== null) {
|
|
26
26
|
metavariableName = metavariableNode.getMetavariableName();
|
|
27
27
|
}
|
|
28
28
|
|
package/src/node/metavariable.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TERM_RULE_NAME, TYPE_RULE_NAME } from "../ruleNames";
|
|
|
6
6
|
|
|
7
7
|
export default class MetavariableNode extends NonTerminalNode {
|
|
8
8
|
getMetavariableName() {
|
|
9
|
-
let
|
|
9
|
+
let metavariableName;
|
|
10
10
|
|
|
11
11
|
this.someChildNode((childNode) => {
|
|
12
12
|
const childNodeTerminalNode = childNode.isTerminalNode();
|
|
@@ -15,13 +15,13 @@ export default class MetavariableNode extends NonTerminalNode {
|
|
|
15
15
|
const terminalNode = childNode, ///
|
|
16
16
|
content = terminalNode.getContent();
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
metavariableName = content; ///
|
|
19
19
|
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
return
|
|
24
|
+
return metavariableName;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
getTermNode() {
|
package/src/node/parameter.js
CHANGED
|
@@ -2,22 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
import NonTerminalNode from "../nonTerminalNode";
|
|
4
4
|
|
|
5
|
+
import { NAME_TOKEN_TYPE, IDENTIFIER_TOKEN_TYPE } from "../tokenTypes";
|
|
6
|
+
|
|
5
7
|
export default class ParameterNode extends NonTerminalNode {
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
+
getName() {
|
|
9
|
+
let name = null;
|
|
8
10
|
|
|
9
11
|
this.someChildNode((childNode, index) => {
|
|
10
12
|
const terminalNode = childNode, ///
|
|
11
|
-
|
|
13
|
+
type = terminalNode.getType();
|
|
14
|
+
|
|
15
|
+
if (type === NAME_TOKEN_TYPE) {
|
|
16
|
+
const content = terminalNode.getContent();
|
|
17
|
+
|
|
18
|
+
name = content; ///
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (index === 0) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
return name;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getIdentifier() {
|
|
30
|
+
let identifier = null;
|
|
31
|
+
|
|
32
|
+
this.someChildNode((childNode, index) => {
|
|
33
|
+
const terminalNode = childNode, ///
|
|
34
|
+
type = terminalNode.getType();
|
|
35
|
+
|
|
36
|
+
if (type === IDENTIFIER_TOKEN_TYPE) {
|
|
37
|
+
const content = terminalNode.getContent();
|
|
38
|
+
|
|
39
|
+
identifier = content; ///
|
|
40
|
+
}
|
|
14
41
|
|
|
15
42
|
if (index === 0) {
|
|
16
43
|
return true;
|
|
17
44
|
}
|
|
18
45
|
});
|
|
19
46
|
|
|
20
|
-
return
|
|
47
|
+
return identifier;
|
|
21
48
|
}
|
|
22
49
|
|
|
23
50
|
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(ParameterNode, ruleName, childNodes, opacity, precedence); }
|
|
@@ -5,44 +5,18 @@ import SubstitutionNode from "../../node/substitution";
|
|
|
5
5
|
import { FRAME_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class FrameSubstitutionNode extends SubstitutionNode {
|
|
8
|
-
|
|
9
|
-
const firstFrameNode = this.getFirstFrameNode(),
|
|
10
|
-
frameNode = firstFrameNode; ///
|
|
11
|
-
|
|
12
|
-
return frameNode;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getMetavariableNode() {
|
|
16
|
-
const lastMetavariableNode = this.getLastMetavariableNode(),
|
|
17
|
-
metavariableNode = lastMetavariableNode; ///
|
|
18
|
-
|
|
19
|
-
return metavariableNode;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getLastMetavariableNode() {
|
|
23
|
-
let lastMetavariableNode = null;
|
|
24
|
-
|
|
8
|
+
getTargetFrameNode() {
|
|
25
9
|
const lastFrameNode = this.getLastFrameNode(),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (singularMetavariableNode !== null) {
|
|
29
|
-
lastMetavariableNode = singularMetavariableNode; ///
|
|
30
|
-
}
|
|
10
|
+
targetFrameNode = lastFrameNode; ///
|
|
31
11
|
|
|
32
|
-
return
|
|
12
|
+
return targetFrameNode;
|
|
33
13
|
}
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
let firstMetavariableNode = null;
|
|
37
|
-
|
|
15
|
+
getReplacementFrameNode() {
|
|
38
16
|
const firstFrameNode = this.getFirstFrameNode(),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (singularMetavariableNode !== null) {
|
|
42
|
-
firstMetavariableNode = singularMetavariableNode; ///
|
|
43
|
-
}
|
|
17
|
+
replacementFrameNode = firstFrameNode; ///
|
|
44
18
|
|
|
45
|
-
return
|
|
19
|
+
return replacementFrameNode;
|
|
46
20
|
}
|
|
47
21
|
|
|
48
22
|
getLastFrameNode() {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import SubstitutionNode from "../../node/substitution";
|
|
4
|
+
|
|
5
|
+
import { REFERENCE_RULE_NAME } from "../../ruleNames";
|
|
6
|
+
|
|
7
|
+
export default class ReferenceSubstitutionNode extends SubstitutionNode {
|
|
8
|
+
getTargetReferenceNode() {
|
|
9
|
+
const lastReferenceNode = this.getLastReferenceNode(),
|
|
10
|
+
targetReferenceNode = lastReferenceNode; ///
|
|
11
|
+
|
|
12
|
+
return targetReferenceNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getReplacementReferenceNode() {
|
|
16
|
+
const firstReferenceNode = this.getFirstReferenceNode(),
|
|
17
|
+
replacementReferenceNode = firstReferenceNode; ///
|
|
18
|
+
|
|
19
|
+
return replacementReferenceNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getLastReferenceNode() {
|
|
23
|
+
const ruleName = REFERENCE_RULE_NAME,
|
|
24
|
+
lastReferenceNode = this.getLastNodeByRuleName(ruleName);
|
|
25
|
+
|
|
26
|
+
return lastReferenceNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getFirstReferenceNode() {
|
|
30
|
+
const ruleName = REFERENCE_RULE_NAME,
|
|
31
|
+
firstReferenceNode = this.getFirstNodeByRuleName(ruleName);
|
|
32
|
+
|
|
33
|
+
return firstReferenceNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return SubstitutionNode.fromRuleNameChildNodesOpacityAndPrecedence(ReferenceSubstitutionNode, ruleName, childNodes, opacity, precedence); }
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -5,44 +5,18 @@ import SubstitutionNode from "../../node/substitution";
|
|
|
5
5
|
import { STATEMENT_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class StatementSubstitutionNode extends SubstitutionNode {
|
|
8
|
-
|
|
9
|
-
const firstStatementNode = this.getFirstStatementNode(),
|
|
10
|
-
statementNode = firstStatementNode; ///
|
|
11
|
-
|
|
12
|
-
return statementNode;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getMetavariableNode() {
|
|
16
|
-
const lastMetavariableNode = this.getLastMetavariableNode(),
|
|
17
|
-
metavariableNode = lastMetavariableNode; ///
|
|
18
|
-
|
|
19
|
-
return metavariableNode;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getLastMetavariableNode() {
|
|
23
|
-
let lastMetavariableNode = null;
|
|
24
|
-
|
|
8
|
+
getTargetStatementNode() {
|
|
25
9
|
const lastStatementNode = this.getLastStatementNode(),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (singularMetavariableNode !== null) {
|
|
29
|
-
lastMetavariableNode = singularMetavariableNode; ///
|
|
30
|
-
}
|
|
10
|
+
targetStatementNode = lastStatementNode; ///
|
|
31
11
|
|
|
32
|
-
return
|
|
12
|
+
return targetStatementNode;
|
|
33
13
|
}
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
let firstMetavariableNode = null;
|
|
37
|
-
|
|
15
|
+
getReplacementStatementNode() {
|
|
38
16
|
const firstStatementNode = this.getFirstStatementNode(),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (singularMetavariableNode !== null) {
|
|
42
|
-
firstMetavariableNode = singularMetavariableNode; ///
|
|
43
|
-
}
|
|
17
|
+
replacementStatementNode = firstStatementNode; ///
|
|
44
18
|
|
|
45
|
-
return
|
|
19
|
+
return replacementStatementNode;
|
|
46
20
|
}
|
|
47
21
|
|
|
48
22
|
getLastStatementNode() {
|
|
@@ -5,34 +5,18 @@ import SubstitutionNode from "../../node/substitution";
|
|
|
5
5
|
import { TERM_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class TermSubstitutionNode extends SubstitutionNode {
|
|
8
|
-
|
|
9
|
-
const firstTermNode = this.getFirstTermNode(),
|
|
10
|
-
termNode = firstTermNode; ///
|
|
11
|
-
|
|
12
|
-
return termNode;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getVariableNode() {
|
|
16
|
-
const lastVariableNode = this.getLastVariableNode(),
|
|
17
|
-
variableNode = lastVariableNode; ///
|
|
18
|
-
|
|
19
|
-
return variableNode;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getLastVariableNode() {
|
|
8
|
+
getTargetTermNode() {
|
|
23
9
|
const lastTermNode = this.getLastTermNode(),
|
|
24
|
-
|
|
25
|
-
lastVariableNode = singularVariableNode; ///
|
|
10
|
+
targetTermNode = lastTermNode; ///
|
|
26
11
|
|
|
27
|
-
return
|
|
12
|
+
return targetTermNode;
|
|
28
13
|
}
|
|
29
14
|
|
|
30
|
-
|
|
15
|
+
getReplacementTermNode() {
|
|
31
16
|
const firstTermNode = this.getFirstTermNode(),
|
|
32
|
-
|
|
33
|
-
firstVariableNode = singularVariableNode; ///
|
|
17
|
+
replacementTermNode = firstTermNode; ///
|
|
34
18
|
|
|
35
|
-
return
|
|
19
|
+
return replacementTermNode;
|
|
36
20
|
}
|
|
37
21
|
|
|
38
22
|
getLastTermNode() {
|
|
@@ -75,6 +75,7 @@ import SatisfiesAssertionNode from "./node/assertion/satisfies";
|
|
|
75
75
|
import ParenthesisedLabelsNode from "./node/parenthesisedLabels"
|
|
76
76
|
import PropertyDeclarationNode from "./node/declaration/property";
|
|
77
77
|
import VariableDeclarationNode from "./node/declaration/variable";
|
|
78
|
+
import ReferenceSubstitutionNode from "./node/substitution/reference";
|
|
78
79
|
import StatementSubstitutionNode from "./node/substitution/statement";
|
|
79
80
|
import SimpleTypeDeclarationNode from "./node/declaration/simpleType";
|
|
80
81
|
import CombinatorDeclarationNode from "./node/declaration/combinator";
|
|
@@ -159,6 +160,7 @@ import {
|
|
|
159
160
|
PARENTHESISED_LABELS_RULE_NAME,
|
|
160
161
|
PROPERTY_DECLARATION_RULE_NAME,
|
|
161
162
|
VARIABLE_DECLARATION_RULE_NAME,
|
|
163
|
+
REFERENCE_SUBSTITUTION_RULE_NAME,
|
|
162
164
|
STATEMENT_SUBSTITUTION_RULE_NAME,
|
|
163
165
|
COMBINATOR_DECLARATION_RULE_NAME,
|
|
164
166
|
SIMPLE_TYPE_DECLARATION_RULE_NAME,
|
|
@@ -244,6 +246,7 @@ const NonTerminalNodeMap = {
|
|
|
244
246
|
[VARIABLE_DECLARATION_RULE_NAME]: VariableDeclarationNode,
|
|
245
247
|
[PROPERTY_DECLARATION_RULE_NAME]: PropertyDeclarationNode,
|
|
246
248
|
[STATEMENT_SUBSTITUTION_RULE_NAME]: StatementSubstitutionNode,
|
|
249
|
+
[REFERENCE_SUBSTITUTION_RULE_NAME]: ReferenceSubstitutionNode,
|
|
247
250
|
[COMBINATOR_DECLARATION_RULE_NAME]: CombinatorDeclarationNode,
|
|
248
251
|
[SIMPLE_TYPE_DECLARATION_RULE_NAME]: SimpleTypeDeclarationNode,
|
|
249
252
|
[TYPE_PREFIX_DECLARATION_RULE_NAME]: TypePrefixDeclarationNode,
|
|
@@ -2,26 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
import { ruleFromRuleName } from "../utilities/bnf";
|
|
4
4
|
import { TERM_RULE_NAME,
|
|
5
|
-
VARIABLE_RULE_NAME,
|
|
6
5
|
REFERENCE_RULE_NAME,
|
|
7
6
|
STATEMENT_RULE_NAME,
|
|
8
7
|
COMBINATOR_RULE_NAME,
|
|
9
8
|
CONSTRUCTOR_RULE_NAME,
|
|
10
9
|
EQUIVALENCE_RULE_NAME,
|
|
11
|
-
METAVARIABLE_RULE_NAME,
|
|
12
10
|
TERM_SUBSTITUTION_RULE_NAME,
|
|
13
11
|
FRAME_SUBSTITUTION_RULE_NAME,
|
|
14
12
|
STATEMENT_SUBSTITUTION_RULE_NAME,
|
|
15
13
|
REFERENCE_SUBSTITUTION_RULE_NAME } from "../ruleNames";
|
|
16
14
|
|
|
17
15
|
const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
|
|
18
|
-
variablePlaceholderRule = ruleFromRuleName(VARIABLE_RULE_NAME),
|
|
19
16
|
referencePlaceholderRule = ruleFromRuleName(REFERENCE_RULE_NAME),
|
|
20
17
|
statementPlaceholderRule = ruleFromRuleName(STATEMENT_RULE_NAME),
|
|
21
18
|
combinatorPlaceholderRule = ruleFromRuleName(COMBINATOR_RULE_NAME),
|
|
22
19
|
constructorPlaceholderRule = ruleFromRuleName(CONSTRUCTOR_RULE_NAME),
|
|
23
20
|
equivalencePlaceholderRule = ruleFromRuleName(EQUIVALENCE_RULE_NAME),
|
|
24
|
-
metavariablePlaceholderRule = ruleFromRuleName(METAVARIABLE_RULE_NAME),
|
|
25
21
|
termSubstitutionPlaceholderRule = ruleFromRuleName(TERM_SUBSTITUTION_RULE_NAME),
|
|
26
22
|
frameSubstitutionPlaceholderRule = ruleFromRuleName(FRAME_SUBSTITUTION_RULE_NAME),
|
|
27
23
|
statementSubstitutionPlaceholderRule = ruleFromRuleName(STATEMENT_SUBSTITUTION_RULE_NAME),
|
|
@@ -29,8 +25,6 @@ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
|
|
|
29
25
|
|
|
30
26
|
export function instantiateTerm(string, context) { return instantiate(termPlaceholderRule, string, context); }
|
|
31
27
|
|
|
32
|
-
export function instantiateVariable(string, context) { return instantiate(variablePlaceholderRule, string, context); }
|
|
33
|
-
|
|
34
28
|
export function instantiateReference(string, context) { return instantiate(referencePlaceholderRule, string, context); }
|
|
35
29
|
|
|
36
30
|
export function instantiateStatement(string, context) { return instantiate(statementPlaceholderRule, string, context); }
|
|
@@ -41,8 +35,6 @@ export function instantiateConstructor(string, context) { return instantiate(con
|
|
|
41
35
|
|
|
42
36
|
export function instantiateEquivalence(string, context) { return instantiate(equivalencePlaceholderRule, string, context); }
|
|
43
37
|
|
|
44
|
-
export function instantiateMetavariable(string, context) { return instantiate(metavariablePlaceholderRule, string, context); }
|
|
45
|
-
|
|
46
38
|
export function instantiateTermSubstitution(string, context) { return instantiate(termSubstitutionPlaceholderRule, string, context); }
|
|
47
39
|
|
|
48
40
|
export function instantiateFrameSubstitution(string, context) { return instantiate(frameSubstitutionPlaceholderRule, string, context); }
|
package/src/process/unify.js
CHANGED
|
@@ -486,7 +486,7 @@ class IntrinsicLevelPass extends Pass {
|
|
|
486
486
|
{
|
|
487
487
|
generalNodeQuery: termVariableNodeQuery,
|
|
488
488
|
specificNodeQuery: termNodeQuery,
|
|
489
|
-
run: (generalTermVariableNode, specificTermNode,
|
|
489
|
+
run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
|
|
490
490
|
let success = false;
|
|
491
491
|
|
|
492
492
|
const termNode = specificTermNode, ///
|
|
@@ -502,7 +502,7 @@ class IntrinsicLevelPass extends Pass {
|
|
|
502
502
|
context = specificContext; ///
|
|
503
503
|
|
|
504
504
|
const term = context.findTermByTermNode(termNode),
|
|
505
|
-
termUnifies = variable.unifyTerm(term,
|
|
505
|
+
termUnifies = variable.unifyTerm(term, generalContext, specificContext);
|
|
506
506
|
|
|
507
507
|
if (termUnifies) {
|
|
508
508
|
success = true;
|
|
@@ -612,14 +612,14 @@ export function unifyStatementWithCombinator(statement, combinator, assignments,
|
|
|
612
612
|
return statementUnifiesWithCombinator;
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
export function unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable,
|
|
615
|
+
export function unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext) {
|
|
616
616
|
let metavariableUnifiesIntrinsically = false;
|
|
617
617
|
|
|
618
618
|
const generalMetavariableNode = generalMetavariable.getNode(),
|
|
619
619
|
specificMetavariableNode = specificMetavariable.getNode(),
|
|
620
620
|
generalNode = generalMetavariableNode, ///
|
|
621
621
|
specificNode = specificMetavariableNode, ///
|
|
622
|
-
success = intrinsicLevelPass.run(generalNode, specificNode,
|
|
622
|
+
success = intrinsicLevelPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
623
623
|
|
|
624
624
|
if (success) {
|
|
625
625
|
metavariableUnifiesIntrinsically = true;
|
package/src/utilities/context.js
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
import ScopedContext from "../context/scoped";
|
|
4
|
+
import LiminalContext from "../context/liminal";
|
|
5
|
+
import LiteralContext from "../context/literal";
|
|
6
|
+
import EphemeralContext from "../context/ephemeral";
|
|
7
|
+
import SyntheticContext from "../context/synthetic";
|
|
8
|
+
|
|
9
|
+
export function scope(innerFunction, context) {
|
|
10
|
+
const scopedContext = ScopedContext.fromNothing(context);
|
|
11
|
+
|
|
12
|
+
context = scopedContext; ///
|
|
13
|
+
|
|
14
|
+
return innerFunction(context);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function attempt(innerFunction, context) {
|
|
18
|
+
const ephemeralContext = EphemeralContext.fromNothing(context);
|
|
19
|
+
|
|
20
|
+
context = ephemeralContext; ///
|
|
21
|
+
|
|
22
|
+
return innerFunction(context);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function liminally(innerFunction, context) {
|
|
26
|
+
const liminalContext = LiminalContext.fromNothing(context);
|
|
27
|
+
|
|
28
|
+
context = liminalContext; ///
|
|
29
|
+
|
|
30
|
+
return innerFunction(context);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function literally(innerFunction, context) {
|
|
34
|
+
const literalContext = LiteralContext.fromNothing(context);
|
|
35
|
+
|
|
36
|
+
context = literalContext; ///
|
|
37
|
+
|
|
38
|
+
return innerFunction(context);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function synthetically(innerFunction, generalContext, specificContext) {
|
|
42
|
+
const syntheticContext = SyntheticContext.fromNothing(generalContext, specificContext),
|
|
43
|
+
context = syntheticContext; ///
|
|
44
|
+
|
|
45
|
+
return innerFunction(context);
|
|
20
46
|
}
|