occam-verify-cli 1.0.911 → 1.0.919
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/context/bounded.js +1 -4
- package/lib/element/assertion/signature.js +38 -32
- package/lib/element/deduction.js +13 -7
- package/lib/element/proofAssertion/step.js +27 -40
- package/lib/element/signature.js +52 -60
- package/lib/element/subproof.js +1 -23
- package/lib/element/topLevelAssertion/axiom.js +21 -108
- package/lib/element/topLevelAssertion.js +13 -36
- package/lib/node/proofAssertion/step.js +5 -5
- package/lib/node/qualification.js +4 -4
- package/lib/node/statement.js +4 -4
- package/lib/process/instantiate.js +8 -2
- package/lib/process/unify.js +21 -5
- package/lib/utilities/context.js +6 -1
- package/lib/utilities/element.js +6 -19
- package/lib/utilities/equivalences.js +1 -13
- package/lib/utilities/unification.js +95 -116
- package/package.json +7 -7
- package/src/context/bounded.js +1 -3
- package/src/element/assertion/signature.js +50 -37
- package/src/element/deduction.js +19 -9
- package/src/element/proofAssertion/step.js +36 -59
- package/src/element/signature.js +80 -92
- package/src/element/subproof.js +0 -35
- package/src/element/topLevelAssertion/axiom.js +26 -170
- package/src/element/topLevelAssertion.js +11 -45
- package/src/node/proofAssertion/step.js +4 -4
- package/src/node/qualification.js +3 -3
- package/src/node/statement.js +3 -3
- package/src/process/instantiate.js +4 -0
- package/src/process/unify.js +28 -3
- package/src/utilities/context.js +6 -0
- package/src/utilities/element.js +10 -21
- package/src/utilities/equivalences.js +0 -12
- package/src/utilities/unification.js +117 -145
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import Assertion from "../assertion";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { instantiate } from "../../utilities/context";
|
|
6
|
+
import { join, reconcile, instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiateSignatureAssertion } from "../../process/instantiate";
|
|
8
|
-
import {
|
|
8
|
+
import { signatureFromSignatureAssertionNode, referenceFromSignatureAssertionNode, signatureAssertionFromStatementNode } from "../../utilities/element";
|
|
9
9
|
|
|
10
10
|
export default define(class SignatureAssertion extends Assertion {
|
|
11
11
|
constructor(context, string, node, lineIndex, signature, reference) {
|
|
@@ -30,10 +30,6 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
30
30
|
return signatureAssertionNode;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
compareSubstitutions(substitutions, context) { return this.signature.compareSubstitutions(substitutions, context); }
|
|
34
|
-
|
|
35
|
-
correlateSubstitutions(substitutions, context) { return this.signature.correlateSubstitutions(substitutions, context); }
|
|
36
|
-
|
|
37
33
|
validate(context) {
|
|
38
34
|
let signatureAssertion = null;
|
|
39
35
|
|
|
@@ -118,7 +114,7 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
118
114
|
const satisfiable = axiom.isSatisfiable();
|
|
119
115
|
|
|
120
116
|
if (satisfiable) {
|
|
121
|
-
const signatureUnifies =
|
|
117
|
+
const signatureUnifies = this.unifySignature(context);
|
|
122
118
|
|
|
123
119
|
if (signatureUnifies) {
|
|
124
120
|
this.reference = reference;
|
|
@@ -130,7 +126,6 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
130
126
|
|
|
131
127
|
context.debug(`The '${axiomString}' axiom is not satisfiable.`);
|
|
132
128
|
}
|
|
133
|
-
|
|
134
129
|
} else {
|
|
135
130
|
const referencdString = reference.getString();
|
|
136
131
|
|
|
@@ -145,46 +140,64 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
145
140
|
return referenceVerifies;
|
|
146
141
|
}
|
|
147
142
|
|
|
148
|
-
|
|
149
|
-
let
|
|
143
|
+
unifySignature(context) {
|
|
144
|
+
let signatureUnifies;
|
|
145
|
+
|
|
146
|
+
const signatureAssertionString = this.getString(); ///
|
|
147
|
+
|
|
148
|
+
context.trace(`Unifying the '${signatureAssertionString}' signature assertion's signature...`);
|
|
150
149
|
|
|
151
|
-
const
|
|
152
|
-
signatureAssertionString = this.getString(); ///
|
|
150
|
+
const axiom = context.findAxiomByReference(this.reference);
|
|
153
151
|
|
|
154
|
-
context
|
|
152
|
+
context = this.signature.getContext();
|
|
153
|
+
|
|
154
|
+
reconcile((context) => {
|
|
155
|
+
signatureUnifies = axiom.unifySignature(this.signature, context);
|
|
156
|
+
}, context);
|
|
157
|
+
|
|
158
|
+
if (signatureUnifies) {
|
|
159
|
+
context.debug(`...unified the '${signatureAssertionString}' signature assertion's signature.`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return signatureUnifies;
|
|
163
|
+
}
|
|
155
164
|
|
|
156
|
-
|
|
165
|
+
async unifyTopLevelAssertion(topLevelAssertion, context) {
|
|
166
|
+
let topLevelAssertionUnifies;
|
|
157
167
|
|
|
158
168
|
const axiom = context.findAxiomByReference(this.reference),
|
|
159
|
-
|
|
169
|
+
signatureContext = this.signature.getContext(),
|
|
170
|
+
specificContext = signatureContext; ///
|
|
160
171
|
|
|
161
|
-
|
|
162
|
-
const
|
|
172
|
+
await join(async (specificContext) => {
|
|
173
|
+
const context = specificContext; ///
|
|
163
174
|
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
await reconcile(async (context) => {
|
|
176
|
+
axiom.unifySignature(this.signature, context);
|
|
166
177
|
|
|
167
|
-
|
|
178
|
+
topLevelAssertionUnifies = await axiom.unifyTopLevelAssertion(topLevelAssertion, context);
|
|
179
|
+
}, context);
|
|
180
|
+
}, specificContext, context);
|
|
168
181
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
substitutionsCorrelate = substitutionsA.correlateSubstitutions(substitutionsB);
|
|
182
|
+
return topLevelAssertionUnifies;
|
|
183
|
+
}
|
|
172
184
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
substitutionsBString = substitutionsB.asString();
|
|
185
|
+
async unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context) {
|
|
186
|
+
let stepAndSubproofOrProofAssertionsUnify;
|
|
176
187
|
|
|
177
|
-
|
|
188
|
+
const axiom = context.findAxiomByReference(this.reference),
|
|
189
|
+
signatureContext = this.signature.getContext(),
|
|
190
|
+
specificContext = signatureContext; ///
|
|
178
191
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
192
|
+
await join(async (specificContext) => {
|
|
193
|
+
const context = specificContext; ///
|
|
184
194
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
await reconcile(async (context) => {
|
|
196
|
+
axiom.unifySignature(this.signature, context);
|
|
197
|
+
|
|
198
|
+
stepAndSubproofOrProofAssertionsUnify = await axiom.unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context);
|
|
199
|
+
}, context);
|
|
200
|
+
}, specificContext, context);
|
|
188
201
|
|
|
189
202
|
return stepAndSubproofOrProofAssertionsUnify;
|
|
190
203
|
}
|
|
@@ -201,8 +214,8 @@ export default define(class SignatureAssertion extends Assertion {
|
|
|
201
214
|
const { string, lineIndex } = json,
|
|
202
215
|
definedAssertionNode = instantiateSignatureAssertion(string, context),
|
|
203
216
|
node = definedAssertionNode, ///
|
|
204
|
-
signature =
|
|
205
|
-
reference =
|
|
217
|
+
signature = signatureFromSignatureAssertionNode(definedAssertionNode, context),
|
|
218
|
+
reference = referenceFromSignatureAssertionNode(definedAssertionNode, context);
|
|
206
219
|
|
|
207
220
|
context = null;
|
|
208
221
|
|
package/src/element/deduction.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { instantiateDeduction } from "../process/instantiate";
|
|
7
|
-
import { declare, attempt, descend, serialise, unserialise, instantiate } from "../utilities/context";
|
|
7
|
+
import { join, declare, attempt, descend, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
8
8
|
|
|
9
9
|
export default define(class Deduction extends Element {
|
|
10
10
|
constructor(context, string, node, lineIndex, statement) {
|
|
@@ -130,23 +130,33 @@ export default define(class Deduction extends Element {
|
|
|
130
130
|
return stepUnifies;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
unifyDeduction(deduction,
|
|
133
|
+
unifyDeduction(deduction, context) {
|
|
134
134
|
let deductionUnifies = false;
|
|
135
135
|
|
|
136
|
-
const
|
|
137
|
-
generalDeduction = this, ///
|
|
136
|
+
const generalDeduction = this, ///
|
|
138
137
|
specificDeduction = deduction, ///
|
|
139
138
|
generalDeductionString = generalDeduction.getString(),
|
|
140
139
|
specificDeductionString = specificDeduction.getString();
|
|
141
140
|
|
|
142
141
|
context.trace(`Unifying the '${specificDeductionString}' deduction with the '${generalDeductionString}' deduction...`);
|
|
143
142
|
|
|
144
|
-
const
|
|
145
|
-
|
|
143
|
+
const specificDeductionContext = specificDeduction.getContext(),
|
|
144
|
+
generalDeductionContext = generalDeduction.getContext(),
|
|
145
|
+
specificContext = specificDeductionContext, ///
|
|
146
|
+
generalContext = generalDeductionContext; ///
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
join((specificContext) => {
|
|
149
|
+
reconcile((specificContext) => {
|
|
150
|
+
const statement = specificDeduction.getStatement(),
|
|
151
|
+
statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
|
|
152
|
+
|
|
153
|
+
if (statementUnifies) {
|
|
154
|
+
specificContext.commit();
|
|
155
|
+
|
|
156
|
+
deductionUnifies = true;
|
|
157
|
+
}
|
|
158
|
+
}, specificContext);
|
|
159
|
+
}, specificContext, context);
|
|
150
160
|
|
|
151
161
|
if (deductionUnifies) {
|
|
152
162
|
context.debug(`...unified the '${specificDeductionString}' deduction with the '${generalDeductionString}' deduction.`);
|
|
@@ -50,7 +50,7 @@ export default define(class Step extends ProofAssertion {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
isQualified() {
|
|
53
|
-
const qualified = (this.reference !== null);
|
|
53
|
+
const qualified = ((this.reference !== null) || (this.signatureAssertion !== null));
|
|
54
54
|
|
|
55
55
|
return qualified;
|
|
56
56
|
}
|
|
@@ -164,29 +164,6 @@ export default define(class Step extends ProofAssertion {
|
|
|
164
164
|
return validates;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
validateReference(context) {
|
|
168
|
-
let referenceValidates = true; ///
|
|
169
|
-
|
|
170
|
-
if (this.reference !== null) {
|
|
171
|
-
const stepString = this.getString(), ///
|
|
172
|
-
referenceString = this.reference.getString();
|
|
173
|
-
|
|
174
|
-
context.trace(`Validating the '${stepString}' step's '${referenceString}' reference... `);
|
|
175
|
-
|
|
176
|
-
const reference = this.reference.validate(context);
|
|
177
|
-
|
|
178
|
-
if (reference === null) {
|
|
179
|
-
referenceValidates = false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (referenceValidates) {
|
|
183
|
-
context.debug(`...validated the '${stepString}' step's '${referenceString}' reference. `);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return referenceValidates;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
167
|
validateStatement(context) {
|
|
191
168
|
let statementValidates = false;
|
|
192
169
|
|
|
@@ -211,8 +188,35 @@ export default define(class Step extends ProofAssertion {
|
|
|
211
188
|
return statementValidates;
|
|
212
189
|
}
|
|
213
190
|
|
|
191
|
+
validateReference(context) {
|
|
192
|
+
let referenceValidates = false;
|
|
193
|
+
|
|
194
|
+
if (this.reference !== null) {
|
|
195
|
+
const stepString = this.getString(), ///
|
|
196
|
+
referenceString = this.reference.getString();
|
|
197
|
+
|
|
198
|
+
context.trace(`Validating the '${stepString}' step's '${referenceString}' reference... `);
|
|
199
|
+
|
|
200
|
+
const reference = this.reference.validate(context);
|
|
201
|
+
|
|
202
|
+
if (reference !== null) {
|
|
203
|
+
this.reference = reference;
|
|
204
|
+
|
|
205
|
+
referenceValidates = true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (referenceValidates) {
|
|
209
|
+
context.debug(`...validated the '${stepString}' step's '${referenceString}' reference. `);
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
referenceValidates = true;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return referenceValidates;
|
|
216
|
+
}
|
|
217
|
+
|
|
214
218
|
validateSignatureAssertion(context) {
|
|
215
|
-
let signatureAssertionValidates =
|
|
219
|
+
let signatureAssertionValidates = false;
|
|
216
220
|
|
|
217
221
|
if (this.signatureAssertion !== null) {
|
|
218
222
|
const stepString = this.getString(), ///
|
|
@@ -222,13 +226,17 @@ export default define(class Step extends ProofAssertion {
|
|
|
222
226
|
|
|
223
227
|
const signatureAssertion = this.signatureAssertion.validate(context);
|
|
224
228
|
|
|
225
|
-
if (signatureAssertion
|
|
226
|
-
|
|
229
|
+
if (signatureAssertion !== null) {
|
|
230
|
+
this.signatureAssertion = signatureAssertion;
|
|
231
|
+
|
|
232
|
+
signatureAssertionValidates = true;
|
|
227
233
|
}
|
|
228
234
|
|
|
229
235
|
if (signatureAssertionValidates) {
|
|
230
|
-
context.debug(`...
|
|
236
|
+
context.debug(`...validated the '${stepString}' step's '${signatureAssertionString}' signature assertion. `);
|
|
231
237
|
}
|
|
238
|
+
} else {
|
|
239
|
+
signatureAssertionValidates = true;
|
|
232
240
|
}
|
|
233
241
|
|
|
234
242
|
return signatureAssertionValidates;
|
|
@@ -264,36 +272,5 @@ export default define(class Step extends ProofAssertion {
|
|
|
264
272
|
return unifies;
|
|
265
273
|
}
|
|
266
274
|
|
|
267
|
-
unifyWithSignatureAssertion(signatureAssertion, context) {
|
|
268
|
-
let unifiesWithSignatureAssertion = false;
|
|
269
|
-
|
|
270
|
-
const stepString = this.getString(), ///
|
|
271
|
-
signatureAssertionString = signatureAssertion.getString();
|
|
272
|
-
|
|
273
|
-
context.trace(`Unifying the '${stepString}' step with the '${signatureAssertionString}' signature assertion...`);
|
|
274
|
-
|
|
275
|
-
const reference = signatureAssertion.getReference(),
|
|
276
|
-
axiom = context.findAxiomByReference(reference);
|
|
277
|
-
|
|
278
|
-
if (axiom !== null) {
|
|
279
|
-
const step = this, ///
|
|
280
|
-
stepUnifies = axiom.unifyStep(step, context);
|
|
281
|
-
|
|
282
|
-
if (stepUnifies) {
|
|
283
|
-
const substitutionsCompare = signatureAssertion.compareSubstitutions(context);
|
|
284
|
-
|
|
285
|
-
if (substitutionsCompare) {
|
|
286
|
-
unifiesWithSignatureAssertion = true;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (unifiesWithSignatureAssertion) {
|
|
292
|
-
context.debug(`...unified the '${stepString}' step with the '${signatureAssertionString}' signature assertion.`);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return unifiesWithSignatureAssertion;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
275
|
static name = "Step";
|
|
299
276
|
});
|
package/src/element/signature.js
CHANGED
|
@@ -5,10 +5,10 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { instantiateSignature } from "../process/instantiate";
|
|
8
|
-
import {
|
|
9
|
-
import { attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
8
|
+
import { signatureFromSignatureNode } from "../utilities/element";
|
|
9
|
+
import { join, ablate, attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
10
10
|
|
|
11
|
-
const { match
|
|
11
|
+
const { match } = arrayUtilities;
|
|
12
12
|
|
|
13
13
|
export default define(class Signature extends Element {
|
|
14
14
|
constructor(context, string, node, lineIndex, terms) {
|
|
@@ -41,6 +41,22 @@ export default define(class Signature extends Element {
|
|
|
41
41
|
return term;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
isEqualTo(signature) {
|
|
45
|
+
const signatureNode = signature.getNode(),
|
|
46
|
+
signatureNodeMatches = this.matchSignatureNode(signatureNode),
|
|
47
|
+
equalTo = signatureNodeMatches; ///
|
|
48
|
+
|
|
49
|
+
return equalTo;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
matchSignatureNode(signatureNode) {
|
|
53
|
+
const node = signatureNode, ///
|
|
54
|
+
nodeMatches = this.matchNode(node),
|
|
55
|
+
signatureNodeMatches = nodeMatches; ///
|
|
56
|
+
|
|
57
|
+
return signatureNodeMatches;
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
findValidSignature(context) {
|
|
45
61
|
const signatureNode = this.getSignatureNode(),
|
|
46
62
|
signature = context.findSignatureBySignatureNode(signatureNode),
|
|
@@ -157,48 +173,52 @@ export default define(class Signature extends Element {
|
|
|
157
173
|
return termsValidate
|
|
158
174
|
}
|
|
159
175
|
|
|
160
|
-
unifySignature(signature,
|
|
161
|
-
let signatureUnifies
|
|
176
|
+
unifySignature(signature, generalContext, specificContext) {
|
|
177
|
+
let signatureUnifies;
|
|
162
178
|
|
|
163
|
-
const
|
|
179
|
+
const context = specificContext, ///
|
|
180
|
+
generalSignature = this,
|
|
164
181
|
specificSignature = signature, ///
|
|
165
182
|
generalSignatureString = generalSignature.getString(),
|
|
166
183
|
specificSignatureString = specificSignature.getString();
|
|
167
184
|
|
|
168
185
|
context.trace(`Unifying the '${specificSignatureString}' signature with the '${generalSignatureString}' signature...`);
|
|
169
186
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
const generalSignatureTerms = generalSignature.getTerms(),
|
|
188
|
+
specificSignatureTerms = specificSignature.getTerms(),
|
|
189
|
+
generalSignatureContext = generalSignature.getContext(),
|
|
190
|
+
specificSignatureContext = specificSignature.getContext(),
|
|
191
|
+
generalTerms = generalSignatureTerms, ///
|
|
192
|
+
specificTerms = specificSignatureTerms, ///
|
|
193
|
+
generalContexts = [
|
|
194
|
+
generalSignatureContext,
|
|
195
|
+
generalContext
|
|
196
|
+
],
|
|
197
|
+
specificContexts = [
|
|
198
|
+
specificSignatureContext,
|
|
199
|
+
specificContext
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
join((generalContext) => {
|
|
203
|
+
join((specificContext) => {
|
|
204
|
+
signatureUnifies = match(generalTerms, specificTerms, (generalTerm, specificTerm) => {
|
|
205
|
+
let termUnifies;
|
|
206
|
+
|
|
207
|
+
reconcile((specificContext) => {
|
|
208
|
+
termUnifies = generalTerm.unifyTerm(specificTerm, generalContext, specificContext);
|
|
209
|
+
|
|
210
|
+
if (termUnifies) {
|
|
211
|
+
specificContext.commit();
|
|
212
|
+
}
|
|
213
|
+
}, specificContext);
|
|
191
214
|
|
|
192
215
|
if (termUnifies) {
|
|
193
|
-
|
|
216
|
+
return true;
|
|
194
217
|
}
|
|
195
|
-
}
|
|
218
|
+
});
|
|
219
|
+
}, ...specificContexts);
|
|
220
|
+
}, ...generalContexts);
|
|
196
221
|
|
|
197
|
-
if (termUnifies) {
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}, specificContext);
|
|
202
222
|
|
|
203
223
|
if (signatureUnifies) {
|
|
204
224
|
context.debug(`...unified the '${specificSignatureString}' signature with the '${generalSignatureString}' signature.`);
|
|
@@ -207,64 +227,6 @@ export default define(class Signature extends Element {
|
|
|
207
227
|
return signatureUnifies;
|
|
208
228
|
}
|
|
209
229
|
|
|
210
|
-
compareSubstitutions(substitutions, context) {
|
|
211
|
-
let substitutionsCompares = false;
|
|
212
|
-
|
|
213
|
-
const signatureString = this.getString(), ///
|
|
214
|
-
substitutionsString = substitutions.asString();
|
|
215
|
-
|
|
216
|
-
context.trace(`Comparing the '${substitutionsString}' substitutions against the '${signatureString}' signature...`);
|
|
217
|
-
|
|
218
|
-
const array = substitutions.getArray(),
|
|
219
|
-
compares = compare(this.terms, array, (term, substitution) => {
|
|
220
|
-
const substitutionTerm = substitution.getTerm(),
|
|
221
|
-
substitutionTermEqualToTerm = substitutionTerm.isEqualTo(term);
|
|
222
|
-
|
|
223
|
-
if (substitutionTermEqualToTerm) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
if (compares) {
|
|
229
|
-
substitutionsCompares = true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (substitutionsCompares) {
|
|
233
|
-
context.debug(`...compared the '${substitutionsString}' substitutions against the '${signatureString}' signature.`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return substitutionsCompares;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
correlateSubstitutions(substitutions, context) {
|
|
240
|
-
let substitutionsCorrelates = false;
|
|
241
|
-
|
|
242
|
-
const signatureString = this.getString(), ///
|
|
243
|
-
substitutionsString = substitutions.asString();
|
|
244
|
-
|
|
245
|
-
context.trace(`Correlating the '${substitutionsString}' substitutions against the '${signatureString}' signature...`);
|
|
246
|
-
|
|
247
|
-
const array = substitutions.getArray(),
|
|
248
|
-
correlates = correlate(this.terms, array, (term, substitution) => {
|
|
249
|
-
const substitutionTerm = substitution.getTerm(),
|
|
250
|
-
substitutionTermEqualToTerm = substitutionTerm.isEqualTo(term);
|
|
251
|
-
|
|
252
|
-
if (substitutionTermEqualToTerm) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
if (correlates) {
|
|
258
|
-
substitutionsCorrelates = true;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (substitutionsCorrelates) {
|
|
262
|
-
context.debug(`...correlated the '${substitutionsString}' substitutions against the '${signatureString}' signature.`);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return substitutionsCorrelates;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
230
|
static name = "Signature";
|
|
269
231
|
|
|
270
232
|
toJSON() {
|
|
@@ -299,4 +261,30 @@ export default define(class Signature extends Element {
|
|
|
299
261
|
|
|
300
262
|
return signature;
|
|
301
263
|
}
|
|
264
|
+
|
|
265
|
+
static fromSignatureString(signatureString, context) {
|
|
266
|
+
let signature;
|
|
267
|
+
|
|
268
|
+
ablate((context) => {
|
|
269
|
+
instantiate((context) => {
|
|
270
|
+
const string = signatureString, ///
|
|
271
|
+
signatureNode = instantiateSignature(string, context);
|
|
272
|
+
|
|
273
|
+
signature = signatureFromSignatureNode(signatureNode, context);
|
|
274
|
+
}, context);
|
|
275
|
+
}, context);
|
|
276
|
+
|
|
277
|
+
return signature;
|
|
278
|
+
}
|
|
302
279
|
});
|
|
280
|
+
|
|
281
|
+
function termsFromSignatureNode(signatureNode, context) {
|
|
282
|
+
const termNodes = signatureNode.getTermNodes(),
|
|
283
|
+
terms = termNodes.map((termNode) => {
|
|
284
|
+
const term = context.findTermByTermNode(termNode);
|
|
285
|
+
|
|
286
|
+
return term;
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
return terms;
|
|
290
|
+
}
|
package/src/element/subproof.js
CHANGED
|
@@ -112,40 +112,5 @@ export default define(class Subproof extends Element {
|
|
|
112
112
|
return subDerivationVerifies;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
unifyWithSignatureAssertion(signatureAssertion, context) {
|
|
116
|
-
let unifiesWithSignatureAssertion = false;
|
|
117
|
-
|
|
118
|
-
const subproofString = this.getString(), ///
|
|
119
|
-
signatureAssertionString = signatureAssertion.getString();
|
|
120
|
-
|
|
121
|
-
context.trace(`Unifying the '${subproofString}' subproof with the '${signatureAssertionString}' signature assertion...`)
|
|
122
|
-
|
|
123
|
-
const reference = signatureAssertion.getReference(),
|
|
124
|
-
axiom = context.findAxiomByReference(reference);
|
|
125
|
-
|
|
126
|
-
if (axiom !== null) {
|
|
127
|
-
const axiomSatisfiable = axiom.isSatisfiable();
|
|
128
|
-
|
|
129
|
-
if (axiomSatisfiable) {
|
|
130
|
-
const subproof = this, ///
|
|
131
|
-
statementUnifies = axiom.unifySubproof(subproof, context);
|
|
132
|
-
|
|
133
|
-
if (statementUnifies) {
|
|
134
|
-
const substitutionsCompare = signatureAssertion.compareSubstitutions(substitutions, context);
|
|
135
|
-
|
|
136
|
-
if (substitutionsCompare) {
|
|
137
|
-
unifiesWithSignatureAssertion = true;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (unifiesWithSignatureAssertion) {
|
|
144
|
-
context.debug(`...unified the '${subproofString}' subproof with the '${signatureAssertionString}' signature assertion.`)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return unifiesWithSignatureAssertion;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
115
|
static name = "Subproof";
|
|
151
116
|
});
|