occam-verify-cli 1.0.206 → 1.0.211
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/dom/assertion/satisfies.js +36 -54
- package/lib/dom/axiom.js +49 -25
- package/lib/dom/metavariable.js +4 -7
- package/lib/dom/signature.js +197 -0
- package/lib/dom/substitution/frame.js +216 -0
- package/lib/dom/substitution/reference.js +203 -0
- package/lib/dom/substitution/statement.js +297 -0
- package/lib/dom/substitution/term.js +237 -0
- package/lib/dom/substitution.js +214 -0
- package/lib/dom/topLevelAssertion.js +21 -10
- package/lib/dom/topLevelMetaAssertion.js +4 -4
- package/lib/dom/variable.js +9 -10
- package/lib/index.js +6 -1
- package/lib/mixins/step/unify.js +3 -4
- package/lib/node/assertion/satisfies.js +5 -5
- package/lib/node/signature.js +116 -0
- package/lib/node/topLevelAssertion.js +8 -18
- package/lib/nonTerminalNodeMap.js +3 -2
- package/lib/ruleNames.js +5 -1
- package/lib/substitutions.js +2 -14
- package/lib/unifier/metaLevel.js +2 -4
- package/lib/utilities/json.js +49 -12
- package/lib/utilities/node.js +36 -1
- package/lib/utilities/substitutions.js +2 -4
- package/package.json +6 -6
- package/src/constants.js +0 -1
- package/src/dom/assertion/satisfies.js +45 -72
- package/src/dom/axiom.js +59 -31
- package/src/dom/metavariable.js +6 -6
- package/src/dom/signature.js +145 -0
- package/src/{substitution → dom/substitution}/frame.js +6 -4
- package/src/{substitution → dom/substitution}/reference.js +6 -4
- package/src/{substitution → dom/substitution}/statement.js +8 -7
- package/src/{substitution → dom/substitution}/term.js +7 -6
- package/src/dom/topLevelAssertion.js +26 -11
- package/src/dom/topLevelMetaAssertion.js +2 -2
- package/src/dom/variable.js +8 -10
- package/src/index.js +5 -0
- package/src/mixins/step/unify.js +4 -3
- package/src/node/assertion/satisfies.js +5 -5
- package/src/node/signature.js +16 -0
- package/src/node/topLevelAssertion.js +8 -21
- package/src/nonTerminalNodeMap.js +4 -1
- package/src/ruleNames.js +1 -0
- package/src/substitutions.js +3 -15
- package/src/unifier/metaLevel.js +2 -3
- package/src/utilities/json.js +60 -13
- package/src/utilities/node.js +45 -0
- package/src/utilities/substitutions.js +2 -3
- package/lib/substitution/frame.js +0 -175
- package/lib/substitution/reference.js +0 -162
- package/lib/substitution/statement.js +0 -296
- package/lib/substitution/term.js +0 -196
- package/lib/substitution.js +0 -214
- /package/src/{substitution.js → dom/substitution.js} +0 -0
|
@@ -4,14 +4,16 @@ import dom from "../../dom";
|
|
|
4
4
|
|
|
5
5
|
import { domAssigned } from "../../dom";
|
|
6
6
|
|
|
7
|
+
import LocalContext from "../../context/local";
|
|
7
8
|
import Substitutions from "../../substitutions";
|
|
9
|
+
import {statementFromJSON} from "../../utilities/json";
|
|
8
10
|
|
|
9
11
|
export default domAssigned(class SatisfiesAssertion {
|
|
10
|
-
constructor(string, node, tokens,
|
|
12
|
+
constructor(string, node, tokens, signature, reference) {
|
|
11
13
|
this.string = string;
|
|
12
14
|
this.node = node;
|
|
13
15
|
this.tokens = tokens;
|
|
14
|
-
this.
|
|
16
|
+
this.signature = signature;
|
|
15
17
|
this.reference = reference;
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -27,8 +29,8 @@ export default domAssigned(class SatisfiesAssertion {
|
|
|
27
29
|
return this.tokens;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
return this.
|
|
32
|
+
getSignature() {
|
|
33
|
+
return this.signature;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
getReference() {
|
|
@@ -36,20 +38,7 @@ export default domAssigned(class SatisfiesAssertion {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
matchSubstitutions(substitutions, context) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const termsString = termsStringFromTerms(this.terms),
|
|
42
|
-
substitutionsString = substitutions.asString();
|
|
43
|
-
|
|
44
|
-
context.trace(`Matching the '${substitutionsString}' substitutions against the ${termsString} terms...`);
|
|
45
|
-
|
|
46
|
-
const termsMatch = substitutions.matchTerms(this.terms);
|
|
47
|
-
|
|
48
|
-
substitutionsMatch = termsMatch; ///
|
|
49
|
-
|
|
50
|
-
if (substitutionsMatch) {
|
|
51
|
-
context.debug(`...matched the '${substitutionsString}' substitutions against the ${termsString} terms.`);
|
|
52
|
-
}
|
|
41
|
+
const substitutionsMatch = this.signature.matchSubstitutions(substitutions, context);
|
|
53
42
|
|
|
54
43
|
return substitutionsMatch;
|
|
55
44
|
}
|
|
@@ -61,9 +50,9 @@ export default domAssigned(class SatisfiesAssertion {
|
|
|
61
50
|
|
|
62
51
|
context.trace(`Verifying the '${satisfiesAssertionString}' satisfies assertion...`);
|
|
63
52
|
|
|
64
|
-
const
|
|
53
|
+
const signatureVerified = this.verifySignature(assignments, stated, context);
|
|
65
54
|
|
|
66
|
-
if (
|
|
55
|
+
if (signatureVerified) {
|
|
67
56
|
const referenceVerified = this.verifyReference(assignments, stated, context);
|
|
68
57
|
|
|
69
58
|
verified = referenceVerified; ///
|
|
@@ -76,28 +65,10 @@ export default domAssigned(class SatisfiesAssertion {
|
|
|
76
65
|
return verified;
|
|
77
66
|
}
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const termsString = termsStringFromTerms(this.terms);
|
|
68
|
+
verifySignature(assignments, stated, context) {
|
|
69
|
+
const signatureVerified = this.signature.verify(context);
|
|
83
70
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
termsVerified = this.terms.every((term) => {
|
|
87
|
-
const termVerified = term.verify(context, () => {
|
|
88
|
-
const verifiedAhead = true;
|
|
89
|
-
|
|
90
|
-
return verifiedAhead;
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return termVerified;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (termsVerified) {
|
|
97
|
-
context.debug(`...verified the ${termsString} terms.`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return termsVerified;
|
|
71
|
+
return signatureVerified;
|
|
101
72
|
}
|
|
102
73
|
|
|
103
74
|
verifyReference(assignments, stated, context) {
|
|
@@ -125,22 +96,42 @@ export default domAssigned(class SatisfiesAssertion {
|
|
|
125
96
|
}
|
|
126
97
|
|
|
127
98
|
unifyStatement(statement, context) {
|
|
128
|
-
let statementUnified;
|
|
99
|
+
let statementUnified = false;
|
|
129
100
|
|
|
130
101
|
const statementString = statement.getString(),
|
|
131
102
|
satisfiesAssertionString = this.string;
|
|
132
103
|
|
|
133
104
|
context.trace(`Unifying the '${statementString}' statement with the '${satisfiesAssertionString}' satisfies assertion...`);
|
|
134
105
|
|
|
106
|
+
this.signature.verify(context);
|
|
107
|
+
|
|
108
|
+
let substitutions;
|
|
109
|
+
|
|
135
110
|
const axiom = context.findAxiomByReference(this.reference),
|
|
136
|
-
|
|
111
|
+
fileContext = axiom.getFileContext(),
|
|
112
|
+
localContext = LocalContext.fromFileContext(fileContext);
|
|
137
113
|
|
|
138
|
-
|
|
114
|
+
substitutions = Substitutions.fromNothing();
|
|
139
115
|
|
|
140
|
-
|
|
141
|
-
|
|
116
|
+
const generalContext = localContext, ///
|
|
117
|
+
specificContext = context, ///
|
|
118
|
+
signatureMatches = axiom.matchSignature(this.signature, substitutions, generalContext, specificContext);
|
|
119
|
+
|
|
120
|
+
if (signatureMatches) {
|
|
121
|
+
const substitutionsB = substitutions; ///
|
|
122
|
+
|
|
123
|
+
substitutions = Substitutions.fromNothing();
|
|
142
124
|
|
|
143
|
-
statementUnified =
|
|
125
|
+
statementUnified = axiom.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
126
|
+
|
|
127
|
+
if (statementUnified) {
|
|
128
|
+
const substitutionsA = substitutions, ///
|
|
129
|
+
substitutionsMatch = substitutionsB.matchSubstitutions(substitutionsA);
|
|
130
|
+
|
|
131
|
+
if (!substitutionsMatch) {
|
|
132
|
+
statementUnified = false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
144
135
|
}
|
|
145
136
|
|
|
146
137
|
if (statementUnified) {
|
|
@@ -162,38 +153,20 @@ export default domAssigned(class SatisfiesAssertion {
|
|
|
162
153
|
node = satisfiesAssertionNode, ///
|
|
163
154
|
string = context.nodeAsString(node),
|
|
164
155
|
tokens = context.nodeAsTokens(node),
|
|
165
|
-
|
|
156
|
+
signature = signatureFromSatisfiesAssertionNode(satisfiesAssertionNode, context),
|
|
166
157
|
reference = Reference.fromSatisfiesAssertionNode(satisfiesAssertionNode, context);
|
|
167
158
|
|
|
168
|
-
satisfiesAssertion = new SatisfiesAssertion(string, node, tokens,
|
|
159
|
+
satisfiesAssertion = new SatisfiesAssertion(string, node, tokens, signature, reference);
|
|
169
160
|
}
|
|
170
161
|
|
|
171
162
|
return satisfiesAssertion;
|
|
172
163
|
}
|
|
173
164
|
});
|
|
174
165
|
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
termsString = (termsString === null) ?
|
|
180
|
-
`'${termString}'` : ///
|
|
181
|
-
`${termsString}, '${termString}'`;
|
|
182
|
-
|
|
183
|
-
return termsString;
|
|
184
|
-
}, null);
|
|
185
|
-
|
|
186
|
-
return termsString;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function termsFromSatisfiesAssertionNode(satisfiesAssertionNode, context) {
|
|
190
|
-
const termNodes = satisfiesAssertionNode.getTermNodes(),
|
|
191
|
-
terms = termNodes.map((termNode) => {
|
|
192
|
-
const { Term } = dom,
|
|
193
|
-
term = Term.fromTermNode(termNode, context);
|
|
194
|
-
|
|
195
|
-
return term;
|
|
196
|
-
});
|
|
166
|
+
function signatureFromSatisfiesAssertionNode(satisfiesAssertionNode, context) {
|
|
167
|
+
const { Signature } = dom,
|
|
168
|
+
signatureNode = satisfiesAssertionNode.getSignatureNode(),
|
|
169
|
+
signature = Signature.fromSignatureNode(signatureNode, context);
|
|
197
170
|
|
|
198
|
-
return
|
|
171
|
+
return signature;
|
|
199
172
|
}
|
package/src/dom/axiom.js
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import LocalContext from "../context/local";
|
|
5
6
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
6
7
|
|
|
7
8
|
import { domAssigned } from "../dom";
|
|
8
|
-
import { satisfiesAssertionFromStatement } from "../utilities/context";
|
|
9
9
|
|
|
10
|
-
const { match
|
|
10
|
+
const { match } = arrayUtilities;
|
|
11
11
|
|
|
12
12
|
export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
13
|
+
isSatisfiable() {
|
|
14
|
+
const signature = this.getSignature(),
|
|
15
|
+
satisfiable = (signature !== null);
|
|
16
|
+
|
|
17
|
+
return satisfiable;
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
verify() {
|
|
14
21
|
let verified;
|
|
15
22
|
|
|
@@ -19,7 +26,11 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
19
26
|
|
|
20
27
|
fileContext.trace(`Verifying the '${axiomString}' axiom...`);
|
|
21
28
|
|
|
22
|
-
|
|
29
|
+
const signatureVerified = this.verifySignature();
|
|
30
|
+
|
|
31
|
+
if (signatureVerified) {
|
|
32
|
+
verified = super.verify();
|
|
33
|
+
}
|
|
23
34
|
|
|
24
35
|
if (verified) {
|
|
25
36
|
const axiom = this; ///
|
|
@@ -32,10 +43,43 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
32
43
|
return verified;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
verifySignature() {
|
|
47
|
+
let signatureVerified = true;
|
|
48
|
+
|
|
49
|
+
const satisfiable = this.isSatisfiable();
|
|
50
|
+
|
|
51
|
+
if (satisfiable) {
|
|
52
|
+
const signature = this.getSignature(),
|
|
53
|
+
fileContext = this.getFileContext(),
|
|
54
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
55
|
+
context = localContext; ///
|
|
56
|
+
|
|
57
|
+
signatureVerified = signature.verify(context);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return signatureVerified;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
matchSignature(signature, substitutions, generalContext, specificContext) {
|
|
64
|
+
let signatureMatches = false;
|
|
65
|
+
|
|
66
|
+
const satisfiable = this.isSatisfiable();
|
|
67
|
+
|
|
68
|
+
if (satisfiable) {
|
|
69
|
+
const signatureA = signature; ///
|
|
70
|
+
|
|
71
|
+
signature = this.getSignature()
|
|
72
|
+
|
|
73
|
+
const signatureB = signature; ///
|
|
74
|
+
|
|
75
|
+
signatureMatches = signatureA.match(signatureB, substitutions, generalContext, specificContext);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return signatureMatches;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
36
82
|
const deduction = this.getDeduction(),
|
|
37
|
-
generalContext = context, ///
|
|
38
|
-
specificContext = context, ///
|
|
39
83
|
statementUnified = deduction.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
40
84
|
|
|
41
85
|
return statementUnified;
|
|
@@ -145,34 +189,18 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
145
189
|
}
|
|
146
190
|
|
|
147
191
|
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context) {
|
|
148
|
-
let statementAndStepsOrSubproofsUnified;
|
|
149
|
-
|
|
150
|
-
statementAndStepsOrSubproofsUnified = super.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context);
|
|
151
|
-
|
|
152
|
-
if (statementAndStepsOrSubproofsUnified) {
|
|
153
|
-
const satisfiable = this.isSatisfiable();
|
|
192
|
+
let statementAndStepsOrSubproofsUnified = false;
|
|
154
193
|
|
|
155
|
-
|
|
156
|
-
const substitutionsMatch = backwardsSome(stepsOrSubproofs, (stepOrSubproof) => {
|
|
157
|
-
const stepSubstep = stepOrSubproof.isStep();
|
|
194
|
+
const satisfiable = this.isSatisfiable();
|
|
158
195
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
196
|
+
if (satisfiable) {
|
|
197
|
+
const string = this.getString(),
|
|
198
|
+
axiomString = string, ///
|
|
199
|
+
statementString = statement.getString();
|
|
163
200
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (substitutionsMatch) {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
statementAndStepsOrSubproofsUnified = substitutionsMatch; ///
|
|
175
|
-
}
|
|
201
|
+
context.debug(`The '${statementString}' statement cannot be unified with the '${axiomString}' axiom because the latter is satisfiable.`);
|
|
202
|
+
} else {
|
|
203
|
+
statementAndStepsOrSubproofsUnified = super.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context);
|
|
176
204
|
}
|
|
177
205
|
|
|
178
206
|
return statementAndStepsOrSubproofsUnified;
|
package/src/dom/metavariable.js
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import dom from "../dom";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
|
-
import FrameSubstitution from "../substitution/frame";
|
|
6
|
-
import ReferenceSubstitution from "../substitution/reference";
|
|
7
|
-
import StatementSubstitution from "../substitution/statement";
|
|
8
5
|
import MetavariablePartialContext from "../context/partial/metavariable";
|
|
9
6
|
|
|
10
7
|
import { domAssigned } from "../dom";
|
|
@@ -189,7 +186,8 @@ export default domAssigned(class Metavariable {
|
|
|
189
186
|
frameUnified = true;
|
|
190
187
|
}
|
|
191
188
|
} else {
|
|
192
|
-
const
|
|
189
|
+
const { FrameSubstitution } = dom,
|
|
190
|
+
context = specificContext, ///
|
|
193
191
|
metavariable = this, ///
|
|
194
192
|
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
|
|
195
193
|
substitution = frameSubstitution; ///
|
|
@@ -232,7 +230,8 @@ export default domAssigned(class Metavariable {
|
|
|
232
230
|
referenceUnified = true;
|
|
233
231
|
}
|
|
234
232
|
} else {
|
|
235
|
-
const
|
|
233
|
+
const { ReferenceSubstitution } = dom,
|
|
234
|
+
context = specificContext, ///
|
|
236
235
|
metavariable = this, ///
|
|
237
236
|
referenceSubstitution = ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, context),
|
|
238
237
|
substitution = referenceSubstitution; ///
|
|
@@ -279,7 +278,8 @@ export default domAssigned(class Metavariable {
|
|
|
279
278
|
statementUnified = true;
|
|
280
279
|
}
|
|
281
280
|
} else {
|
|
282
|
-
const
|
|
281
|
+
const { StatementSubstitution } = dom,
|
|
282
|
+
metavariable = this,
|
|
283
283
|
statementSubstitution = StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context);
|
|
284
284
|
|
|
285
285
|
substitution = statementSubstitution; ///
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import dom from "../dom";
|
|
6
|
+
|
|
7
|
+
import { domAssigned } from "../dom";
|
|
8
|
+
import { termsFromJSON, termsToTermsJSON } from "../utilities/json";
|
|
9
|
+
import { stringFromTerms, variableFromTerm, termsFromTermNodes } from "../utilities/node";
|
|
10
|
+
|
|
11
|
+
const { match, correlate } = arrayUtilities;
|
|
12
|
+
|
|
13
|
+
export default domAssigned(class Signature {
|
|
14
|
+
constructor(string, terms) {
|
|
15
|
+
this.string = string;
|
|
16
|
+
this.terms = terms;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getTerms() {
|
|
24
|
+
return this.terms;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
verify(context) {
|
|
28
|
+
let verified;
|
|
29
|
+
|
|
30
|
+
const signatureString = this.string;
|
|
31
|
+
|
|
32
|
+
context.trace(`Verifying the ${signatureString} signature...`);
|
|
33
|
+
|
|
34
|
+
verified = this.terms.every((term) => {
|
|
35
|
+
const termVerified = term.verify(context, () => {
|
|
36
|
+
const verifiedAhead = true;
|
|
37
|
+
|
|
38
|
+
return verifiedAhead;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (termVerified) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (verified) {
|
|
47
|
+
context.debug(`...verified the ${signatureString} signature.`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return verified;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
match(signature, substitutions, generalContext, specificContext) {
|
|
54
|
+
const terms = signature.getTerms(),
|
|
55
|
+
termsA = this.terms, ///
|
|
56
|
+
termsB = terms, ///
|
|
57
|
+
matches = match(termsA, termsB, (termA, termB) => {
|
|
58
|
+
const termAType = termA.getType(),
|
|
59
|
+
termBType = termB.getType(),
|
|
60
|
+
termATypeEqualToOrSubTypeOfTermB = termAType.isEqualToOrSubTypeOf(termBType);
|
|
61
|
+
|
|
62
|
+
if (termATypeEqualToOrSubTypeOfTermB) {
|
|
63
|
+
let context,
|
|
64
|
+
term;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
context = generalContext; ///
|
|
68
|
+
|
|
69
|
+
term = termB; ///
|
|
70
|
+
|
|
71
|
+
const variable = variableFromTerm(term, context);
|
|
72
|
+
|
|
73
|
+
context = specificContext; ///
|
|
74
|
+
|
|
75
|
+
term = termA; ///
|
|
76
|
+
|
|
77
|
+
const { TermSubstitution } = dom,
|
|
78
|
+
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
79
|
+
substitution = termSubstitution; ///
|
|
80
|
+
|
|
81
|
+
substitutions.addSubstitution(substitution, specificContext);
|
|
82
|
+
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return matches;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
matchSubstitutions(substitutions, context) {
|
|
91
|
+
let substitutionsMatch;
|
|
92
|
+
|
|
93
|
+
const signatureString = this.string,
|
|
94
|
+
substitutionsString = substitutions.asString();
|
|
95
|
+
|
|
96
|
+
context.trace(`Matching the '${substitutionsString}' substitutions against the ${signatureString} signature...`);
|
|
97
|
+
|
|
98
|
+
const array = substitutions.getArray(),
|
|
99
|
+
correlates = correlate(this.terms, array, (term, substitution) => {
|
|
100
|
+
const substitutionTerm = substitution.getTerm(),
|
|
101
|
+
substitutionTermEqualToTerm = substitutionTerm.isEqualTo(term);
|
|
102
|
+
|
|
103
|
+
if (substitutionTermEqualToTerm) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
substitutionsMatch = correlates; ///
|
|
109
|
+
|
|
110
|
+
if (substitutionsMatch) {
|
|
111
|
+
context.debug(`...matched the '${substitutionsString}' substitutions against the ${signatureString} signature.`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return substitutionsMatch;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
toJSON() {
|
|
118
|
+
const termsJSON = termsToTermsJSON(this.terms),
|
|
119
|
+
terms = termsJSON, ///
|
|
120
|
+
json = {
|
|
121
|
+
terms
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return json;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static name = "Signature";
|
|
128
|
+
|
|
129
|
+
static fromJSON(json, fileContext) {
|
|
130
|
+
const terms = termsFromJSON(json, fileContext),
|
|
131
|
+
string = stringFromTerms(terms),
|
|
132
|
+
signature = new Signature(string, terms);
|
|
133
|
+
|
|
134
|
+
return signature;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static fromSignatureNode(signatureNode, fileContext) {
|
|
138
|
+
const termNodes = signatureNode.getTermNodes(),
|
|
139
|
+
terms = termsFromTermNodes(termNodes, fileContext),
|
|
140
|
+
string = stringFromTerms(terms),
|
|
141
|
+
signature = new Signature(string, terms);
|
|
142
|
+
|
|
143
|
+
return signature;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import dom from "
|
|
3
|
+
import dom from "../../dom";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import FrameSubstitutionPartialContext from "
|
|
5
|
+
import FrameSubstitutionPartialContext from "../../context/partial/substitution/frame";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
|
|
9
|
+
export default domAssigned(class FrameSubstitution extends Substitution {
|
|
8
10
|
constructor(string, node, tokens, frame, metavariable) {
|
|
9
11
|
super(string, node, tokens);
|
|
10
12
|
|
|
@@ -71,7 +73,7 @@ export default class FrameSubstitution extends Substitution {
|
|
|
71
73
|
|
|
72
74
|
return frameSubstitution;
|
|
73
75
|
}
|
|
74
|
-
}
|
|
76
|
+
});
|
|
75
77
|
|
|
76
78
|
function stringFromFrameAndMetavariable(frame, metavariable) {
|
|
77
79
|
const frameString = frame.getString(),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import dom from "
|
|
3
|
+
import dom from "../../dom";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import ReferenceSubstitutionPartialContext from "
|
|
5
|
+
import ReferenceSubstitutionPartialContext from "../../context/partial/substitution/reference";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
|
|
9
|
+
export default domAssigned(class ReferenceSubstitution extends Substitution {
|
|
8
10
|
constructor(string, node, tokens, reference, metavariable) {
|
|
9
11
|
super(string, node, tokens);
|
|
10
12
|
|
|
@@ -62,7 +64,7 @@ export default class ReferenceSubstitution extends Substitution {
|
|
|
62
64
|
|
|
63
65
|
return referenceSubstitution;
|
|
64
66
|
}
|
|
65
|
-
}
|
|
67
|
+
});
|
|
66
68
|
|
|
67
69
|
function stringFromReferenceAndMetavariable(reference, metavariable) {
|
|
68
70
|
const referenceString = reference.getString(),
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
|
-
import Substitutions from "
|
|
5
|
-
import StatementSubstitutionPartialContext from "
|
|
4
|
+
import Substitutions from "../../substitutions";
|
|
5
|
+
import StatementSubstitutionPartialContext from "../../context/partial/substitution/statement";
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
import { unifySubstitution } from "../../utilities/unification";
|
|
9
|
+
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
10
|
+
import { statementFromJSON, statementToStatementJSON, metavariableFromJSON, metavariableToMetavariableJSON } from "../../utilities/json";
|
|
10
11
|
|
|
11
|
-
export default class StatementSubstitution extends Substitution {
|
|
12
|
+
export default domAssigned(class StatementSubstitution extends Substitution {
|
|
12
13
|
constructor(string, node, tokens, resolved, statement, metavariable, substitution) {
|
|
13
14
|
super(string, node, tokens);
|
|
14
15
|
|
|
@@ -216,7 +217,7 @@ export default class StatementSubstitution extends Substitution {
|
|
|
216
217
|
|
|
217
218
|
return statementSubstitution;
|
|
218
219
|
}
|
|
219
|
-
}
|
|
220
|
+
});
|
|
220
221
|
|
|
221
222
|
function stringFromStatementAndMetavariable(statement, metavariable) {
|
|
222
223
|
const statementString = statement.getString(),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import dom from "
|
|
3
|
+
import dom from "../../dom";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import TermSubstitutionPartialContext from "
|
|
5
|
+
import TermSubstitutionPartialContext from "../../context/partial/substitution/term";
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
9
|
+
import { stripBracketsFromTermNode } from "../../utilities/brackets";
|
|
9
10
|
|
|
10
|
-
export default class TermSubstitution extends Substitution {
|
|
11
|
+
export default domAssigned(class TermSubstitution extends Substitution {
|
|
11
12
|
constructor(string, node, tokens, term, variable) {
|
|
12
13
|
super(string, node, tokens);
|
|
13
14
|
|
|
@@ -106,7 +107,7 @@ export default class TermSubstitution extends Substitution {
|
|
|
106
107
|
|
|
107
108
|
return termSubstitution;
|
|
108
109
|
}
|
|
109
|
-
}
|
|
110
|
+
});
|
|
110
111
|
|
|
111
112
|
function stringFromTermAndVariable(term, variable) {
|
|
112
113
|
const termString = term.getString(),
|