occam-verify-cli 1.0.913 → 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 +37 -31
- package/lib/element/deduction.js +13 -7
- package/lib/element/proofAssertion/step.js +27 -40
- package/lib/element/signature.js +26 -59
- 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/unify.js +21 -5
- package/lib/utilities/context.js +6 -1
- package/lib/utilities/element.js +3 -3
- package/lib/utilities/equivalences.js +1 -13
- package/lib/utilities/unification.js +95 -116
- package/package.json +4 -4
- package/src/context/bounded.js +1 -3
- package/src/element/assertion/signature.js +47 -34
- package/src/element/deduction.js +19 -9
- package/src/element/proofAssertion/step.js +36 -59
- package/src/element/signature.js +37 -91
- 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/unify.js +28 -3
- package/src/utilities/context.js +6 -0
- package/src/utilities/element.js +2 -2
- package/src/utilities/equivalences.js +0 -12
- package/src/utilities/unification.js +117 -145
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
3
|
import elements from "../elements";
|
|
6
4
|
|
|
7
5
|
import { descend } from "./context";
|
|
8
6
|
|
|
9
|
-
const { backwardsSome } = arrayUtilities;
|
|
10
|
-
|
|
11
7
|
async function unifyStepWithRule(step, context) {
|
|
12
8
|
let stepUnifiesWithRule = false;
|
|
13
9
|
|
|
14
|
-
const
|
|
10
|
+
const reference = step.getReference();
|
|
15
11
|
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
rule = context.findRuleByReference(reference);
|
|
12
|
+
if (reference !== null) {
|
|
13
|
+
const rule = context.findRuleByReference(reference);
|
|
19
14
|
|
|
20
15
|
if (rule !== null) {
|
|
21
16
|
const stepString = step.getString(),
|
|
@@ -42,11 +37,10 @@ async function unifyStepWithRule(step, context) {
|
|
|
42
37
|
async function unifyStepWithReference(step, context) {
|
|
43
38
|
let stepUnifiesWithReference = false;
|
|
44
39
|
|
|
45
|
-
const
|
|
40
|
+
const reference = step.getReference();
|
|
46
41
|
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
stepString = step.getString(),
|
|
42
|
+
if (reference !== null) {
|
|
43
|
+
const stepString = step.getString(),
|
|
50
44
|
referenceString = reference.getString();
|
|
51
45
|
|
|
52
46
|
context.trace(`Unifying the '${stepString}' step with the '${referenceString}' reference...`);
|
|
@@ -83,79 +77,13 @@ async function unifyStepWithReference(step, context) {
|
|
|
83
77
|
return stepUnifiesWithReference;
|
|
84
78
|
}
|
|
85
79
|
|
|
86
|
-
async function unifyStepAsSignatureAssertion(step, context) {
|
|
87
|
-
let stepUnifiesAsSignatureAssertion = false;
|
|
88
|
-
|
|
89
|
-
const { SignatureAssertion } = elements;
|
|
90
|
-
|
|
91
|
-
const signatureAssertion = SignatureAssertion.fromStep(step, context);
|
|
92
|
-
|
|
93
|
-
if (signatureAssertion !== null) {
|
|
94
|
-
const stepString = step.getString();
|
|
95
|
-
|
|
96
|
-
context.trace(`Unifying the '${stepString}' step as a signature assertion...`);
|
|
97
|
-
|
|
98
|
-
descend((context) => {
|
|
99
|
-
signatureAssertion.verifySignature(context);
|
|
100
|
-
}, context);
|
|
101
|
-
|
|
102
|
-
const unqualified = step.isUnqualified();
|
|
103
|
-
|
|
104
|
-
if (unqualified) {
|
|
105
|
-
const subproofOrProofAssertions = context.getSubproofOrProofAssertions();
|
|
106
|
-
|
|
107
|
-
stepUnifiesAsSignatureAssertion = backwardsSome(subproofOrProofAssertions, (stepsOrSubproof) => {
|
|
108
|
-
const stepOrSubProofUnifiesWIthSignatureAssertion = stepsOrSubproof.unifyWithSignatureAssertion(signatureAssertion, context);
|
|
109
|
-
|
|
110
|
-
if (stepOrSubProofUnifiesWIthSignatureAssertion) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
const reference = signatureAssertion.getReference(),
|
|
116
|
-
topLevelAssertion = context.findTopLevelAssertionByReference(reference);
|
|
117
|
-
|
|
118
|
-
if (topLevelAssertion !== null) {
|
|
119
|
-
const axiom = context.findAxiomByReference(reference);
|
|
120
|
-
|
|
121
|
-
if (axiom !== null) {
|
|
122
|
-
const satisfiable = axiom.isSatisfiable();
|
|
123
|
-
|
|
124
|
-
if (satisfiable) {
|
|
125
|
-
const topLevelAssertionUnifies = axiom.unifyTopLevelAssertion(topLevelAssertion, context);
|
|
126
|
-
|
|
127
|
-
if (topLevelAssertionUnifies) {
|
|
128
|
-
const substitutionsCorrelates = signatureAssertion.correlateSubstitutions(substitutions, context);
|
|
129
|
-
|
|
130
|
-
if (substitutionsCorrelates) {
|
|
131
|
-
stepUnifiesAsSignatureAssertion = true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
const axiomString = axiom.getString();
|
|
136
|
-
|
|
137
|
-
context.debug(`Unable to unify with the '${axiomString}' because it is not satisfiable.`)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (stepUnifiesAsSignatureAssertion) {
|
|
144
|
-
context.debug(`...unified the '${stepString}' step as a signature assertion.`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return stepUnifiesAsSignatureAssertion;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
80
|
async function unifyStepWithTopLevelAssertion(step, context) {
|
|
152
81
|
let stepUnifiesWithTopLevelAssertion = false;
|
|
153
82
|
|
|
154
|
-
const
|
|
83
|
+
const reference = step.getReference();
|
|
155
84
|
|
|
156
|
-
if (
|
|
157
|
-
const
|
|
158
|
-
topLevelAssertion = context.findTopLevelAssertionByReference(reference);
|
|
85
|
+
if (reference !== null) {
|
|
86
|
+
const topLevelAssertion = context.findTopLevelAssertionByReference(reference);
|
|
159
87
|
|
|
160
88
|
if (topLevelAssertion !== null) {
|
|
161
89
|
const stepString = step.getString(),
|
|
@@ -179,8 +107,34 @@ async function unifyStepWithTopLevelAssertion(step, context) {
|
|
|
179
107
|
return stepUnifiesWithTopLevelAssertion;
|
|
180
108
|
}
|
|
181
109
|
|
|
182
|
-
async function
|
|
183
|
-
let
|
|
110
|
+
async function unifyStepWithSignatureAssertion(step, context) {
|
|
111
|
+
let stepUnifiesWithSignatureAssertion = false;
|
|
112
|
+
|
|
113
|
+
const signatureAssertion = step.getSignatureAssertion();
|
|
114
|
+
|
|
115
|
+
if (signatureAssertion !== null) {
|
|
116
|
+
const stepString = step.getString(),
|
|
117
|
+
signatureAssertionString = signatureAssertion.getString();
|
|
118
|
+
|
|
119
|
+
context.trace(`Unifying the '${stepString}' step with the '${signatureAssertionString}' signature assertion...`);
|
|
120
|
+
|
|
121
|
+
const subproofOrProofAssertions = context.getSubproofOrProofAssertions(),
|
|
122
|
+
stepAndSubproofOrProofAssertionsUnify = await signatureAssertion.unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context);
|
|
123
|
+
|
|
124
|
+
if (stepAndSubproofOrProofAssertionsUnify) {
|
|
125
|
+
stepUnifiesWithSignatureAssertion = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (stepUnifiesWithSignatureAssertion) {
|
|
129
|
+
context.debug(`...unified the '${stepString}' step with the '${signatureAssertionString}' signature assertion.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return stepUnifiesWithSignatureAssertion;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function unifyStepAsUnqualifiedEquality(step, context) {
|
|
137
|
+
let stepUnifiesAUnqualifiedEquality = false;
|
|
184
138
|
|
|
185
139
|
const unqualified = step.isUnqualified();
|
|
186
140
|
|
|
@@ -192,25 +146,21 @@ async function unifyStepAsEquality(step, context) {
|
|
|
192
146
|
if (equality !== null) {
|
|
193
147
|
const stepString = step.getString();
|
|
194
148
|
|
|
195
|
-
context.trace(`Unifying the '${stepString}' step as an equality...`);
|
|
149
|
+
context.trace(`Unifying the '${stepString}' step as an unqualified equality...`);
|
|
196
150
|
|
|
197
|
-
|
|
151
|
+
stepUnifiesAUnqualifiedEquality = true;
|
|
198
152
|
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (stepUnifiesAEquality) {
|
|
204
|
-
context.debug(`...unified the '${stepString}' step as an equality.`);
|
|
153
|
+
if (stepUnifiesAUnqualifiedEquality) {
|
|
154
|
+
context.debug(`...unified the '${stepString}' step as an unqualified equality.`);
|
|
205
155
|
}
|
|
206
156
|
}
|
|
207
157
|
}
|
|
208
158
|
|
|
209
|
-
return
|
|
159
|
+
return stepUnifiesAUnqualifiedEquality;
|
|
210
160
|
}
|
|
211
161
|
|
|
212
|
-
async function
|
|
213
|
-
let
|
|
162
|
+
async function unifyStepAsUNqualifiedJudgement(step, context) {
|
|
163
|
+
let stepUnifiesAsUnqualifiedJudgement = false;
|
|
214
164
|
|
|
215
165
|
const unqualified = step.isUnqualified();
|
|
216
166
|
|
|
@@ -222,21 +172,21 @@ async function unifyStepAsJudgement(step, context) {
|
|
|
222
172
|
if (judgement !== null) {
|
|
223
173
|
const stepString = step.getString();
|
|
224
174
|
|
|
225
|
-
context.trace(`Unifying the '${stepString}' step as
|
|
175
|
+
context.trace(`Unifying the '${stepString}' step as an unqualified judgement...`);
|
|
226
176
|
|
|
227
|
-
|
|
177
|
+
stepUnifiesAsUnqualifiedJudgement = true;
|
|
228
178
|
|
|
229
|
-
if (
|
|
230
|
-
context.debug(`...unified the '${stepString}' step as
|
|
179
|
+
if (stepUnifiesAsUnqualifiedJudgement) {
|
|
180
|
+
context.debug(`...unified the '${stepString}' step as an unqualified judgement.`);
|
|
231
181
|
}
|
|
232
182
|
}
|
|
233
183
|
}
|
|
234
184
|
|
|
235
|
-
return
|
|
185
|
+
return stepUnifiesAsUnqualifiedJudgement;
|
|
236
186
|
}
|
|
237
187
|
|
|
238
|
-
async function
|
|
239
|
-
let
|
|
188
|
+
async function unifyStepAsUnqualifiedTypeAssertion(step, context) {
|
|
189
|
+
let stepUnifiesAsUnqualifiedTypeAssertion = false;
|
|
240
190
|
|
|
241
191
|
const unqualified = step.isUnqualified();
|
|
242
192
|
|
|
@@ -248,19 +198,21 @@ async function unifyStepAsTypeAssertion(step, context) {
|
|
|
248
198
|
if (typeAssertion !== null) {
|
|
249
199
|
const stepString = step.getString();
|
|
250
200
|
|
|
251
|
-
context.trace(`Unifying the '${stepString}' step as
|
|
201
|
+
context.trace(`Unifying the '${stepString}' step as an unqualified type assertion...`);
|
|
252
202
|
|
|
253
|
-
|
|
203
|
+
stepUnifiesAsUnqualifiedTypeAssertion = true;
|
|
254
204
|
|
|
255
|
-
|
|
205
|
+
if (stepUnifiesAsUnqualifiedTypeAssertion) {
|
|
206
|
+
context.debug(`...unified the '${stepString}' step as an unqualified type assertion.`);
|
|
207
|
+
}
|
|
256
208
|
}
|
|
257
209
|
}
|
|
258
210
|
|
|
259
|
-
return
|
|
211
|
+
return stepUnifiesAsUnqualifiedTypeAssertion;
|
|
260
212
|
}
|
|
261
213
|
|
|
262
|
-
async function
|
|
263
|
-
let
|
|
214
|
+
async function unifyStepAsUnqualifiedPropertyAssertion(step, context) {
|
|
215
|
+
let stepUnifiesAsUnqualifiedPropertyAssertion = false;
|
|
264
216
|
|
|
265
217
|
const unqualified = step.isUnqualified();
|
|
266
218
|
|
|
@@ -272,59 +224,78 @@ async function unifyStepAsPropertyAssertion(step, context) {
|
|
|
272
224
|
if (propertyAssertion !== null) {
|
|
273
225
|
const stepString = step.getString();
|
|
274
226
|
|
|
275
|
-
context.trace(`Unifying the '${stepString}' step as
|
|
227
|
+
context.trace(`Unifying the '${stepString}' step as an unqualified property assertion...`);
|
|
276
228
|
|
|
277
|
-
|
|
278
|
-
equivalence = context.findEquivalenceByTerm(term);
|
|
229
|
+
stepUnifiesAsUnqualifiedPropertyAssertion = true;
|
|
279
230
|
|
|
280
|
-
if (
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
231
|
+
if (stepUnifiesAsUnqualifiedPropertyAssertion) {
|
|
232
|
+
context.debug(`...unified the '${stepString}' step as an unqualified property assertion.`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
284
236
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
});
|
|
237
|
+
return stepUnifiesAsUnqualifiedPropertyAssertion;
|
|
238
|
+
}
|
|
289
239
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
}
|
|
240
|
+
async function unifyStepAsUnqualifiedSignatureAssertion(step, context) {
|
|
241
|
+
let stepUnifiesAsUnqualifiedSignatureAssertion = false;
|
|
294
242
|
|
|
295
|
-
|
|
296
|
-
|
|
243
|
+
const unqualified = step.isUnqualified();
|
|
244
|
+
|
|
245
|
+
if (unqualified) {
|
|
246
|
+
const { SignatureAssertion } = elements,
|
|
247
|
+
statement = step.getStatement(),
|
|
248
|
+
signatureAssertion = SignatureAssertion.fromStatement(statement, context);
|
|
249
|
+
|
|
250
|
+
if (signatureAssertion !== null) {
|
|
251
|
+
const stepString = step.getString();
|
|
252
|
+
|
|
253
|
+
context.trace(`Unifying the '${stepString}' step as a signature assertion...`);
|
|
254
|
+
|
|
255
|
+
stepUnifiesAsUnqualifiedSignatureAssertion = true;
|
|
256
|
+
|
|
257
|
+
if (stepUnifiesAsUnqualifiedSignatureAssertion) {
|
|
258
|
+
context.debug(`...unified the '${stepString}' step as a signature assertion.`);
|
|
297
259
|
}
|
|
298
260
|
}
|
|
299
261
|
}
|
|
300
262
|
|
|
301
|
-
return
|
|
263
|
+
return stepUnifiesAsUnqualifiedSignatureAssertion;
|
|
302
264
|
}
|
|
303
265
|
|
|
304
|
-
async function
|
|
305
|
-
let
|
|
266
|
+
async function unifyStepAsSignatureAssertionWithReference(step, context) {
|
|
267
|
+
let stepUnifiesAsSignatureAssertionWithReference = false;
|
|
306
268
|
|
|
307
|
-
const
|
|
269
|
+
const reference = step.getReference();
|
|
308
270
|
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
signatureAssertionString = signatureAssertion.getString();
|
|
271
|
+
if (reference !== null) {
|
|
272
|
+
const topLevelAssertion = context.findTopLevelAssertionByReference(reference);
|
|
312
273
|
|
|
313
|
-
|
|
274
|
+
if (topLevelAssertion !== null) {
|
|
275
|
+
const statementNode = step.getStatementNode(),
|
|
276
|
+
signatureAssertionNode = statementNode.getSignatureAssertionNode();
|
|
314
277
|
|
|
315
|
-
|
|
316
|
-
|
|
278
|
+
if (signatureAssertionNode !== null) {
|
|
279
|
+
const stepString = step.getString(),
|
|
280
|
+
referenceString = reference.getString(),
|
|
281
|
+
signatureAssertion = context.findAssertionByAssertionNode(signatureAssertionNode);
|
|
317
282
|
|
|
318
|
-
|
|
319
|
-
stepUnifiesWithSignatureAssertion = true;
|
|
320
|
-
}
|
|
283
|
+
context.trace(`Unifying the '${stepString}' step as a signature assertion with the '${referenceString}' reference...`);
|
|
321
284
|
|
|
322
|
-
|
|
323
|
-
|
|
285
|
+
const unifyTopLevelAssertion = await signatureAssertion.unifyTopLevelAssertion(topLevelAssertion, context);
|
|
286
|
+
|
|
287
|
+
if (unifyTopLevelAssertion) {
|
|
288
|
+
stepUnifiesAsSignatureAssertionWithReference = true;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (stepUnifiesAsSignatureAssertionWithReference) {
|
|
292
|
+
context.debug(`...unified the '${stepString}' step as a signature assertion with the '${referenceString}' reference.`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
324
295
|
}
|
|
325
296
|
}
|
|
326
297
|
|
|
327
|
-
return
|
|
298
|
+
return stepUnifiesAsSignatureAssertionWithReference;
|
|
328
299
|
}
|
|
329
300
|
|
|
330
301
|
async function compareStepWithSubproofOrProofAssertions(step, context) {
|
|
@@ -355,12 +326,13 @@ async function compareStepWithSubproofOrProofAssertions(step, context) {
|
|
|
355
326
|
export const unifySteps = [
|
|
356
327
|
unifyStepWithRule,
|
|
357
328
|
unifyStepWithReference,
|
|
358
|
-
unifyStepAsSignatureAssertion,
|
|
359
329
|
unifyStepWithTopLevelAssertion,
|
|
360
|
-
unifyStepAsEquality,
|
|
361
|
-
unifyStepAsJudgement,
|
|
362
|
-
unifyStepAsTypeAssertion,
|
|
363
|
-
unifyStepAsPropertyAssertion,
|
|
364
330
|
unifyStepWithSignatureAssertion,
|
|
331
|
+
unifyStepAsUnqualifiedEquality,
|
|
332
|
+
unifyStepAsUNqualifiedJudgement,
|
|
333
|
+
unifyStepAsUnqualifiedTypeAssertion,
|
|
334
|
+
unifyStepAsUnqualifiedPropertyAssertion,
|
|
335
|
+
unifyStepAsUnqualifiedSignatureAssertion,
|
|
336
|
+
unifyStepAsSignatureAssertionWithReference,
|
|
365
337
|
compareStepWithSubproofOrProofAssertions
|
|
366
338
|
];
|