occam-verify-cli 1.0.753 → 1.0.757

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.
Files changed (51) hide show
  1. package/lib/context/file/nominal.js +5 -5
  2. package/lib/context/scoped.js +6 -5
  3. package/lib/context/synthetic.js +5 -1
  4. package/lib/element/assertion/contained.js +1 -1
  5. package/lib/element/assertion/subproof.js +110 -13
  6. package/lib/element/assumption.js +20 -32
  7. package/lib/element/conclusion.js +1 -5
  8. package/lib/element/deduction.js +16 -19
  9. package/lib/element/derivation.js +4 -4
  10. package/lib/element/metavariable.js +7 -1
  11. package/lib/element/proof.js +6 -6
  12. package/lib/element/proofAssertion/premise.js +9 -15
  13. package/lib/element/proofAssertion/supposition.js +10 -16
  14. package/lib/element/reference.js +10 -8
  15. package/lib/element/statement.js +99 -58
  16. package/lib/element/subDerivation.js +4 -4
  17. package/lib/element/subproof.js +6 -6
  18. package/lib/element/substitution/statement.js +63 -46
  19. package/lib/element/topLevelAssertion/axiom.js +15 -13
  20. package/lib/element/topLevelAssertion.js +1 -4
  21. package/lib/element/topLevelMetaAssertion.js +26 -2
  22. package/lib/element/variable.js +3 -1
  23. package/lib/process/unify.js +41 -3
  24. package/lib/utilities/releaseContext.js +3 -3
  25. package/lib/utilities/string.js +2 -2
  26. package/package.json +3 -3
  27. package/src/context/file/nominal.js +4 -4
  28. package/src/context/scoped.js +6 -4
  29. package/src/context/synthetic.js +6 -0
  30. package/src/element/assertion/contained.js +1 -1
  31. package/src/element/assertion/subproof.js +189 -16
  32. package/src/element/assumption.js +20 -51
  33. package/src/element/conclusion.js +0 -7
  34. package/src/element/deduction.js +15 -21
  35. package/src/element/derivation.js +4 -3
  36. package/src/element/metavariable.js +15 -2
  37. package/src/element/proof.js +6 -6
  38. package/src/element/proofAssertion/premise.js +18 -28
  39. package/src/element/proofAssertion/supposition.js +23 -32
  40. package/src/element/reference.js +9 -7
  41. package/src/element/statement.js +153 -87
  42. package/src/element/subDerivation.js +4 -3
  43. package/src/element/subproof.js +4 -4
  44. package/src/element/substitution/statement.js +94 -64
  45. package/src/element/topLevelAssertion/axiom.js +20 -16
  46. package/src/element/topLevelAssertion.js +0 -2
  47. package/src/element/topLevelMetaAssertion.js +40 -1
  48. package/src/element/variable.js +5 -0
  49. package/src/process/unify.js +63 -1
  50. package/src/utilities/releaseContext.js +1 -1
  51. package/src/utilities/string.js +3 -3
@@ -201,30 +201,9 @@ export default define(class StatementSubstitution extends Substitution {
201
201
  return replacementStatementValidates;
202
202
  }
203
203
 
204
- unifyReplacementStatement(replacementStatement, generalContext, specificContext) {
205
- let replacementStatemnentUnifies = false;
206
-
207
- const context = specificContext, ///
208
- substitutionString = this.getString(), ///
209
- replacementStatementString = replacementStatement.getString(),
210
- substitutionReplacementStatementString = this.replacementStatement.getString(); ///
211
-
212
- context.trace(`Unifying the '${replacementStatementString}' replacement statement with the '${substitutionString}' substiution's '${substitutionReplacementStatementString}' replacement statement...`);
213
-
214
- const statementUnifies = this.replacementStatement.unifyStatement(replacementStatement, generalContext, specificContext);
215
-
216
- if (statementUnifies) {
217
- replacementStatemnentUnifies = true;
218
- }
219
-
220
- if (replacementStatemnentUnifies) {
221
- context.debug(`...unified the '${replacementStatementString}' replacement statement with the '${substitutionString}' substiution's '${substitutionReplacementStatementString}' replacement statement.`);
222
- }
223
-
224
- return replacementStatemnentUnifies;
225
- }
226
-
227
204
  unifySubstitution(substitution, generalContext, specificContext) {
205
+ let substitutionUnifies;
206
+
228
207
  const context = specificContext,
229
208
  generalSubstitution = this.substitution, ///
230
209
  specificSubstitution = substitution, ///
@@ -233,7 +212,13 @@ export default define(class StatementSubstitution extends Substitution {
233
212
 
234
213
  context.trace(`Unifying the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution...`);
235
214
 
236
- const substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
215
+ reconcile((specificContext) => {
216
+ substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
217
+
218
+ if (substitutionUnifies) {
219
+ specificContext.commit();
220
+ }
221
+ }, specificContext);
237
222
 
238
223
  if (substitutionUnifies) {
239
224
  context.trace(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
@@ -242,74 +227,119 @@ export default define(class StatementSubstitution extends Substitution {
242
227
  return substitutionUnifies;
243
228
  }
244
229
 
245
- resolve(generalContext, specificContext) {
246
- let context;
230
+ uniffyComplexSubstitution(complexSubstitution, generalContext, specificContext) {
231
+ let substitution = null;
247
232
 
248
- context = this.getContext();
233
+ const context = specificContext, ///
234
+ simpleSubstitutionString = this.getString(), ///
235
+ complexSubstitutionString = complexSubstitution.getString(); ///
249
236
 
250
- const substitutionString = this.getString(); ///
237
+ context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
251
238
 
252
- context.trace(`Resolving the ${substitutionString} substitution...`);
239
+ let simpleSubstitutionUnifies = false;
253
240
 
254
- context = generalContext; ///
241
+ reconcile((specificContext) => {
242
+ const replacementStatement = complexSubstitution.getReplacementStatement(),
243
+ replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
255
244
 
256
- const metavariableName = this.getMetavariableName();
245
+ if (replacementStatementUnifies) {
246
+ const nested = false,
247
+ context = specificContext, ///
248
+ soleNonTrivialSubstitution = context.getSoleNonTrivialSubstitution(nested);
257
249
 
258
- context = specificContext; ///
250
+ substitution = soleNonTrivialSubstitution; ///
251
+ }
252
+ }, specificContext);
259
253
 
260
- const simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
254
+ if (substitution !== null) {
255
+ simpleSubstitutionUnifies = true;
256
+ }
261
257
 
262
- if (simpleSubstitution !== null) {
263
- context = this.getContext();
258
+ if (simpleSubstitutionUnifies) {
259
+ context.debug(`...unified the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution.`);
260
+ }
264
261
 
265
- const substitution = reconcile((context) => {
266
- let substitution = null;
262
+ return substitution;
263
+ }
267
264
 
268
- const specificContext = context; ///
265
+ unifyReplacementStatement(replacementStatement, generalContext, specificContext) {
266
+ let replacementStatemnentUnifies = false;
269
267
 
270
- context = simpleSubstitution.getContext();
268
+ const context = specificContext, ///
269
+ replacementStatementString = replacementStatement.getString(),
270
+ substitutionReplacementStatementString = this.replacementStatement.getString(); ///
271
271
 
272
- const generalContext = context; ///
272
+ context.trace(`Unifying the '${replacementStatementString}' replacement statement with the '${substitutionReplacementStatementString}' replacement statement...`);
273
273
 
274
- context = specificContext; ///
274
+ const statementUnifies = this.replacementStatement.unifyStatement(replacementStatement, generalContext, specificContext);
275
275
 
276
- const replacementStatementUnifies = simpleSubstitution.unifyReplacementStatement(this.replacementStatement, generalContext, specificContext);
276
+ if (statementUnifies) {
277
+ replacementStatemnentUnifies = true;
278
+ }
277
279
 
278
- if (replacementStatementUnifies) {
279
- const nested = false,
280
- soleNonTrivialSubstitution = context.getSoleNonTrivialSubstitution(nested);
280
+ if (replacementStatemnentUnifies) {
281
+ context.debug(`...unified the '${replacementStatementString}' replacement statement with the '${substitutionReplacementStatementString}' replacement statement.`);
282
+ }
281
283
 
282
- substitution = soleNonTrivialSubstitution; ///
283
- }
284
+ return replacementStatemnentUnifies;
285
+ }
284
286
 
285
- return substitution;
286
- }, context);
287
+ unifyWithSipmleSubstitution(simpleSubstitution, generalContext, specificContext) {
288
+ let substitution;
287
289
 
288
- if (substitution !== null) {
289
- reconcile((specificContext) => {
290
- const complexContext = this.getContext(), ///
291
- simpleContext = simpleSubstitution.getContext(); ///
290
+ const complexSubstitution = this; ///
291
+
292
+ let context;
293
+
294
+ context = this.getContext();
292
295
 
293
- context = specificContext; ///
296
+ specificContext = context; ///
294
297
 
295
- join((context) => {
296
- const specificContext = context; ///
298
+ context = simpleSubstitution.getContext();
297
299
 
298
- context = this.substitution.getContext();
300
+ generalContext = context; ///
299
301
 
300
- const generalContext = context; ///
302
+ substitution = simpleSubstitution.uniffyComplexSubstitution(complexSubstitution, generalContext, specificContext);
301
303
 
302
- this.unifySubstitution(substitution, generalContext, specificContext);
303
- }, complexContext, simpleContext, context);
304
+ return substitution;
305
+ }
304
306
 
305
- specificContext.commit();
306
- }, specificContext);
307
+ resolve(generalContext, specificContext) {
308
+ let resolved = false;
309
+
310
+ const context = specificContext, ///
311
+ substitutionString = this.getString(); ///
307
312
 
308
- this.resolved = true;
313
+ context.trace(`Resolving the ${substitutionString} substitution...`);
314
+
315
+ const metavariableName = this.getMetavariableName(),
316
+ simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
317
+
318
+ if (simpleSubstitution !== null) {
319
+ const substitution = this.unifyWithSipmleSubstitution(simpleSubstitution, generalContext, specificContext); ///
320
+
321
+ if (substitution !== null) {
322
+ const complexSubstitution = this, ///
323
+ simpleSubstitutionComplex = simpleSubstitution.getContext(),
324
+ complexSubstitutionContext = complexSubstitution.getContext();
325
+
326
+ join((context) => {
327
+ const specificContext = context; ///
328
+
329
+ context = this.substitution.getContext();
330
+
331
+ const generalContext = context; ///
332
+
333
+ this.unifySubstitution(substitution, generalContext, specificContext);
334
+ }, complexSubstitutionContext, simpleSubstitutionComplex, context);
335
+
336
+ resolved = true;
309
337
  }
310
338
  }
311
339
 
312
- if (this.resolved) {
340
+ if (resolved) {
341
+ this.resolved = true;
342
+
313
343
  context.debug(`...resolved the '${substitutionString}' substitution.`);
314
344
  }
315
345
  }
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ import { arrayUtilities } from "necessary";
4
+
3
5
  import TopLevelAssertion from "../topLevelAssertion";
4
6
 
5
7
  import { define } from "../../elements";
6
8
 
9
+ const { backwardsEvery } = arrayUtilities;
10
+
7
11
  export default define(class Axiom extends TopLevelAssertion {
8
12
  getAxiomNode() {
9
13
  const node = this.getNode(),
@@ -120,7 +124,7 @@ export default define(class Axiom extends TopLevelAssertion {
120
124
  unifySubproof(subproof, context) {
121
125
  let subproofUnifies = false;
122
126
 
123
- const axiomString = this.getString(),
127
+ const axiomString = this.getString(), ///
124
128
  subproofString = subproof.getString();
125
129
 
126
130
  context.trace(`Unifying the '${subproofString}' subproof with the '${axiomString}' axiom...`);
@@ -130,10 +134,10 @@ export default define(class Axiom extends TopLevelAssertion {
130
134
  if (unconditional) {
131
135
  context.trace(`Unable to unify the '${subproofString}' subproof with the '${axiomString}' axiom because the axiom is unconditional.`);
132
136
  } else {
133
- const lastProofAssertion = subproof.getLastProofAssertion(),
134
- lastProofAssertionUnifies = this.unifyLastProofAssertion(lastProofAssertion, context);
137
+ const lastStep = subproof.getLastStep(),
138
+ lastStepUnifies = this.unifyLastStep(lastStep, context);
135
139
 
136
- if (lastProofAssertionUnifies) {
140
+ if (lastStepUnifies) {
137
141
  const suppositions = subproof.getSuppositions(),
138
142
  suppositionsUnify = this.unifySuppositions(suppositions, context);
139
143
 
@@ -196,7 +200,7 @@ export default define(class Axiom extends TopLevelAssertion {
196
200
  if (generalSuppositionsLength === specificSuppositionsLength) {
197
201
  suppositions = specificSuppositions; ///
198
202
 
199
- suppositionsUnify = suppositions.every((supposition, index) => {
203
+ suppositionsUnify = backwardsEvery(suppositions, (supposition, index) => {
200
204
  const suppositionUnifies = this.unifySupposition(supposition, index, generalContext, specificContext);
201
205
 
202
206
  if (suppositionUnifies) {
@@ -208,32 +212,32 @@ export default define(class Axiom extends TopLevelAssertion {
208
212
  return suppositionsUnify;
209
213
  }
210
214
 
211
- unifyLastProofAssertion(lastProofAssertion, context) {
212
- let lastProofAssertionUnifies = false;
215
+ unifyLastStep(lastStep, context) {
216
+ let lastStepUnifies = false;
213
217
 
214
- const axiomString = this.getString(),
215
- lastProofAssertionString = lastProofAssertion.getString();
218
+ const axiomString = this.getString(), ///
219
+ lastStepString = lastStep.getString();
216
220
 
217
- context.trace(`Unifying the '${lastProofAssertionString}' last proof assertion with the '${axiomString}' axiom...`)
221
+ context.trace(`Unifying the '${lastStepString}' last step with the '${axiomString}' axiom...`);
218
222
 
219
- const statement = lastProofAssertion.getStatement(),
223
+ const statement = lastStep.getStatement(),
220
224
  statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
221
225
 
222
226
  if (statementUnifiesWithDeduction) {
223
- lastProofAssertionUnifies = true;
227
+ lastStepUnifies = true;
224
228
  }
225
229
 
226
- if (lastProofAssertionUnifies) {
227
- context.debug(`...unified the '${lastProofAssertionString}' last proof assertion with the '${axiomString}' axiom.`)
230
+ if (lastStepUnifies) {
231
+ context.debug(`...unified the '${lastStepString}' last step with the '${axiomString}' axiom.`);
228
232
  }
229
233
 
230
- return lastProofAssertionUnifies;
234
+ return lastStepUnifies;
231
235
  }
232
236
 
233
237
  unifyTopLevelAssertion(topLevelAssertion, context) {
234
238
  let topLevelAssertionUnifies = false;
235
239
 
236
- const axiomString = this.getString(),
240
+ const axiomString = this.getString(), ///
237
241
  topLevelAssertionString = topLevelAssertion.getString();
238
242
 
239
243
  context.trace(`Unifying the '${topLevelAssertionString}' top level assertion with the '${axiomString}' axiom...`);
@@ -59,8 +59,6 @@ export default class TopLevelAssertion extends Element {
59
59
  this.hypotheses = hypotheses;
60
60
  }
61
61
 
62
- getStatement() { return this.deduction.getStatement(); }
63
-
64
62
  isHypothetical() {
65
63
  const hypothesesLength = this.hypotheses.length,
66
64
  hypothetical = (hypothesesLength > 0);
@@ -46,7 +46,46 @@ export default class TopLevelMetaAssertion extends Element {
46
46
  return this.metaLevelSubstitutions;
47
47
  }
48
48
 
49
- getStatement() { return this.deduction.getStatement(); }
49
+ getStatement() {
50
+ let statement = null;
51
+
52
+ const unconditional = this.isUnconditional();
53
+
54
+ if (unconditional) {
55
+ statement = this.deduction.getStatement();
56
+ }
57
+
58
+ return statement;
59
+ }
60
+
61
+ getStatements() {
62
+ let statements = null;
63
+
64
+ const unconditional = this.isUnconditional();
65
+
66
+ if (!unconditional) {
67
+ const suppositionStatements = this.suppositions.map((supposition) => {
68
+ const suppositionStatement = supposition.getStatement();
69
+
70
+ return suppositionStatement;
71
+ }),
72
+ deductionStatement = this.deduction.getStatement();
73
+
74
+ statements = [
75
+ ...suppositionStatements,
76
+ deductionStatement
77
+ ];
78
+ }
79
+
80
+ return statements;
81
+ }
82
+
83
+ isUnconditional() {
84
+ const suppositionsLength = this.suppositions.length,
85
+ unconditional = (suppositionsLength === 0);
86
+
87
+ return unconditional;
88
+ }
50
89
 
51
90
  compareReference(reference) {
52
91
  const label = this.getLabel(),
@@ -126,6 +126,11 @@ export default define(class Variable extends Element {
126
126
  const substitutionComparesToTerm = substitution.compareTerm(term, context);
127
127
 
128
128
  if (substitutionComparesToTerm) {
129
+ const termSubstitution = substitution, ///
130
+ termSubstitutionString = termSubstitution.getString();
131
+
132
+ context.trace(`The '${termSubstitutionString}' term substitution is already present.`);
133
+
129
134
  termUnifies = true;
130
135
  }
131
136
  } else {
@@ -304,6 +304,67 @@ class MetavariablePass extends ZipPass {
304
304
  ];
305
305
  }
306
306
 
307
+ class SubstitutionPass extends ZipPass {
308
+ static maps = [
309
+ {
310
+ generalNodeQuery: frameAMetavariableNodeQuery,
311
+ specificNodeQuery: frameNodeQuery,
312
+ run: (generalFrameMetavariableNode, specificFrameNode, generalContext, specificContext) => {
313
+ let success = false;
314
+
315
+ const frameNode = specificFrameNode, ///
316
+ metavariableNode = generalFrameMetavariableNode, ///
317
+ metavariableName = metavariableNode.getMetavariableName();
318
+
319
+ let context;
320
+
321
+ context = generalContext; ///
322
+
323
+ const metavariable = context.findMetavariableByMetavariableName(metavariableName);
324
+
325
+ context = specificContext; ///
326
+
327
+ const frame = context.findFrameByFrameNode(frameNode),
328
+ frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
329
+
330
+ if (frameUnifies) {
331
+ success = true;
332
+ }
333
+
334
+ return success;
335
+ }
336
+ },
337
+ {
338
+ generalNodeQuery: termVariableNodeQuery,
339
+ specificNodeQuery: termNodeQuery,
340
+ run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
341
+ let success = false;
342
+
343
+ const termNode = specificTermNode, ///
344
+ variableNode = generalTermVariableNode, ///
345
+ variableIdentifier = variableNode.getVariableIdentifier();
346
+
347
+ let context;
348
+
349
+ context = generalContext; ///
350
+
351
+ const variable = context.findVariableByVariableIdentifier(variableIdentifier);
352
+
353
+ context = specificContext; ///
354
+
355
+ const term = context.findTermByTermNode(termNode),
356
+ termUnifies = variable.unifyTerm(term, generalContext, specificContext);
357
+
358
+ if (termUnifies) {
359
+ success = true;
360
+ }
361
+
362
+ return success;
363
+ }
364
+ }
365
+ ];
366
+ }
367
+
307
368
  class IntrinsicLevelPass extends ZipPass {
308
369
  static maps = [
309
370
  {
@@ -341,6 +402,7 @@ const metaLevelPass = new MetaLevelPass(),
341
402
  combinatorPass = new CombinatorPass(),
342
403
  constructorPass = new ConstructorPass(),
343
404
  metavariablePass = new MetavariablePass(),
405
+ substitutionPass = new SubstitutionPass(),
344
406
  intrinsicLevelPass = new IntrinsicLevelPass();
345
407
 
346
408
  export function unifyStatement(generalStatement, specificStatement, generalContext, specificContext) {
@@ -366,7 +428,7 @@ export function unifySubstitution(generalSubstitution, specificSubstitution, gen
366
428
  specificSubstitutionNode = specificSubstitution.getNode(),
367
429
  generalNode = generalSubstitutionNode, ///
368
430
  specificNode = specificSubstitutionNode, ///
369
- success = metaLevelPass.run(generalNode, specificNode, generalContext, specificContext);
431
+ success = substitutionPass.run(generalNode, specificNode, generalContext, specificContext);
370
432
 
371
433
  if (success) {
372
434
  substitutionUnifies = true;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { releaseContextUtilities } from "occam-languages";
4
- import { fileSystemUtilities as occamFileSystemUtilities } from "occam-file-system";
4
+ import { fileSystemUtilities as occamFileSystemUtilities } from "occam-server";
5
5
  import { pathUtilities, fileSystemUtilities as necessaryFileSystemUtilities } from "necessary";
6
6
 
7
7
  const { loadProject } = occamFileSystemUtilities,
@@ -168,10 +168,10 @@ export function sectionStringFromHypothesesTopLevelAssertion(hypotheses, axiom,
168
168
  }
169
169
 
170
170
  export function subproofStringFromSuppositionsAndSubDerivation(suppositions, subDerivation) {
171
- const lastProofAssertion = subDerivation.getLastProofAssertion(),
171
+ const lastStep = subDerivation.getLastStep(),
172
172
  suppositionsString = suppositionsStringFromSuppositions(suppositions),
173
- lastProofAssertionString = lastProofAssertion.getString(),
174
- subproofString = `[${suppositionsString}]...${lastProofAssertionString}`;
173
+ lastStepString = lastStep.getString(),
174
+ subproofString = `[${suppositionsString}]...${lastStepString}`;
175
175
 
176
176
  return subproofString;
177
177
  }