occam-verify-cli 1.0.924 → 1.0.932

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 (57) hide show
  1. package/lib/context/bounded.js +19 -18
  2. package/lib/context/file/nominal.js +1 -13
  3. package/lib/context/mnemic.js +1 -5
  4. package/lib/context.js +17 -26
  5. package/lib/element/assertion/contained.js +4 -6
  6. package/lib/element/assertion/defined.js +19 -21
  7. package/lib/element/assertion/type.js +43 -14
  8. package/lib/element/constructor/bracketed.js +3 -2
  9. package/lib/element/constructor.js +5 -3
  10. package/lib/element/declaration/variable.js +2 -1
  11. package/lib/element/hypothesis.js +55 -40
  12. package/lib/element/metavariable.js +13 -7
  13. package/lib/element/proofAssertion/step.js +1 -5
  14. package/lib/element/section.js +21 -27
  15. package/lib/element/statement.js +8 -3
  16. package/lib/element/substitution/statement.js +14 -15
  17. package/lib/element/substitution.js +17 -1
  18. package/lib/element/term.js +22 -13
  19. package/lib/element/topLevelAssertion.js +6 -2
  20. package/lib/element/type.js +4 -4
  21. package/lib/element/variable.js +57 -33
  22. package/lib/utilities/assignment.js +25 -9
  23. package/lib/utilities/element.js +37 -23
  24. package/lib/utilities/equivalences.js +2 -2
  25. package/lib/utilities/string.js +36 -35
  26. package/lib/utilities/substitutions.js +14 -26
  27. package/lib/utilities/unification.js +45 -44
  28. package/lib/utilities/validation.js +5 -3
  29. package/package.json +1 -1
  30. package/src/context/bounded.js +19 -17
  31. package/src/context/file/nominal.js +0 -18
  32. package/src/context/mnemic.js +0 -7
  33. package/src/context.js +24 -43
  34. package/src/element/assertion/contained.js +6 -11
  35. package/src/element/assertion/defined.js +32 -36
  36. package/src/element/assertion/type.js +61 -18
  37. package/src/element/constructor/bracketed.js +4 -1
  38. package/src/element/constructor.js +7 -2
  39. package/src/element/declaration/variable.js +2 -0
  40. package/src/element/hypothesis.js +71 -54
  41. package/src/element/metavariable.js +20 -11
  42. package/src/element/proofAssertion/step.js +0 -6
  43. package/src/element/section.js +24 -31
  44. package/src/element/statement.js +11 -1
  45. package/src/element/substitution/statement.js +23 -21
  46. package/src/element/substitution.js +24 -0
  47. package/src/element/term.js +29 -11
  48. package/src/element/topLevelAssertion.js +8 -2
  49. package/src/element/type.js +4 -4
  50. package/src/element/variable.js +81 -44
  51. package/src/utilities/assignment.js +34 -8
  52. package/src/utilities/element.js +44 -29
  53. package/src/utilities/equivalences.js +1 -1
  54. package/src/utilities/string.js +59 -53
  55. package/src/utilities/substitutions.js +14 -40
  56. package/src/utilities/unification.js +60 -60
  57. package/src/utilities/validation.js +7 -2
@@ -6,12 +6,12 @@ import { baseTypeFromNothing } from "../utilities/type";
6
6
  import { equivalenceStringFromTerms,
7
7
  typeStringFromNominalTypeName,
8
8
  rulsStringFromLabelsPremisesAndConclusion,
9
- sectionStringFromHypothesesTopLevelAssertion,
10
9
  subproofStringFromSuppositionsAndSubDerivation,
10
+ sectionStringFromHypothesesAndTopLevelAssertion,
11
11
  procedureCallStringFromProcedureReferenceAndParameters,
12
- topLevelAssertionStringFromLabelsSuppositionsAndDeduction,
13
12
  topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction,
14
- complexTypeDeclarationStringFromTypeSuperTypesAndProvisional } from "../utilities/string";
13
+ complexTypeDeclarationStringFromTypeSuperTypesAndProvisional,
14
+ topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction } from "../utilities/string";
15
15
 
16
16
  export function typeFromTypeNode(typeNode, context) {
17
17
  let type;
@@ -46,11 +46,12 @@ export function termFromTermNode(termNode, context) {
46
46
  node = termNode, ///
47
47
  string = context.nodeAsString(node),
48
48
  lineIndex = null,
49
- type = typeFromTermNode(termNode, context);
49
+ type = typeFromTermNode(termNode, context),
50
+ provisional = provisionalFromTermNode(termNode, context);
50
51
 
51
52
  context = null;
52
53
 
53
- const term = new Term(context, string, node, lineIndex, type);
54
+ const term = new Term(context, string, node, lineIndex, type, provisional);
54
55
 
55
56
  return term;
56
57
  }
@@ -122,7 +123,7 @@ export function lemmaFromLemmaNode(lemmaNode, context) {
122
123
  suppositions = suppositionsFromTopLevelAssertionNode(topLevelAsssertionNode, context),
123
124
  signature = signatureFromTopLevelAssertionNode(topLevelAsssertionNode, context),
124
125
  hypotheses = hypothesesFromTopLevelAssertionNode(topLevelAsssertionNode, context),
125
- topLevelAsssertionString = topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
126
+ topLevelAsssertionString = topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction),
126
127
  node = lemmaNode, ///
127
128
  string = topLevelAsssertionString, ///
128
129
  lineIndex = null;
@@ -172,7 +173,7 @@ export function axiomFromAxiomNode(axiomNode, context) {
172
173
  suppositions = suppositionsFromTopLevelAssertionNode(topLevelAsssertionNode, context),
173
174
  signature = signatureFromTopLevelAssertionNode(topLevelAsssertionNode, context),
174
175
  hypotheses = hypothesesFromTopLevelAssertionNode(topLevelAsssertionNode, context),
175
- topLevelAsssertionString = topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
176
+ topLevelAsssertionString = topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction),
176
177
  node = axiomNode, ///
177
178
  string = topLevelAsssertionString, ///
178
179
  lineIndex = null;
@@ -185,20 +186,18 @@ export function axiomFromAxiomNode(axiomNode, context) {
185
186
  }
186
187
 
187
188
  export function sectionFromSectionNode(sectionNode, context) {
188
- const hypothesisNodes = sectionNode.getHypothesisNodes(),
189
+ const { Section } = elements,
190
+ hypothesisNodes = sectionNode.getHypothesisNodes(),
189
191
  hypotheses = hypothesesFromHypothesisNodes(hypothesisNodes, context),
190
- axiom = axiomFromSectionNode(sectionNode, context),
191
- lemma = lemmaFromSectionNode(sectionNode, context),
192
- theorem = theoremFromSectionNode(sectionNode, context),
193
- conjecture = conjectureFromSectionNode(sectionNode, context),
194
- sectionString = sectionStringFromHypothesesTopLevelAssertion(hypotheses, axiom, lemma, theorem, conjecture),
192
+ topLevelAssertion = topLevelAssertionFromSectionNode(sectionNode, context),
193
+ sectionString = sectionStringFromHypothesesAndTopLevelAssertion(hypotheses, topLevelAssertion),
195
194
  node = sectionNode, ///
196
195
  string = sectionString, ///
197
196
  lineIndex = null;
198
197
 
199
198
  context = null;
200
199
 
201
- const section = new Section(context, string, node, lineIndex, hypotheses, axiom, lemma, theorem, conjecture);
200
+ const section = new Section(context, string, node, lineIndex, hypotheses, topLevelAssertion);
202
201
 
203
202
  return section;
204
203
  }
@@ -224,7 +223,7 @@ export function theoremFromTheoremNode(theoremNode, context) {
224
223
  suppositions = suppositionsFromTopLevelAssertionNode(topLevelAsssertionNode, context),
225
224
  signature = signatureFromTopLevelAssertionNode(topLevelAsssertionNode, context),
226
225
  hypotheses = hypothesesFromTopLevelAssertionNode(topLevelAsssertionNode, context),
227
- topLevelAsssertionString = topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
226
+ topLevelAsssertionString = topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction),
228
227
  node = theoremNode, ///
229
228
  string = topLevelAsssertionString, ///
230
229
  lineIndex = null;
@@ -261,12 +260,12 @@ export function variableFromVariableNode(variableNode, context) {
261
260
  string = context.nodeAsString(node),
262
261
  lineIndex = null,
263
262
  type = typeFromVariableNode(variableNode, context),
264
- identifier = identifierFromVarialbeNode(variableNode, context),
265
- propertyRelations = propertyRelationsFromVariableNode(variableNode, context);
263
+ identifier = identifierFromVariableNode(variableNode, context),
264
+ provisional = provisionalFromVariableNode(variableNode, context);
266
265
 
267
266
  context = null;
268
267
 
269
- const variable = new Variable(context, string, node, lineIndex, type, identifier, propertyRelations);
268
+ const variable = new Variable(context, string, node, lineIndex, type, identifier, provisional);
270
269
 
271
270
  return variable;
272
271
  }
@@ -400,7 +399,7 @@ export function parameterFromParameterNode(parameterNode, context) {
400
399
  }
401
400
 
402
401
  export function hypothesisFromHypothesisNode(hypotheseNode, context) {
403
- const { Hypothsis } = elements,
402
+ const { Hypothesis } = elements,
404
403
  node = hypotheseNode, ///
405
404
  string = context.nodeAsString(node),
406
405
  lineIndex = null,
@@ -408,7 +407,7 @@ export function hypothesisFromHypothesisNode(hypotheseNode, context) {
408
407
 
409
408
  context = null;
410
409
 
411
- const hypohtesis = new Hypothsis(context, string, node, lineIndex, statement);
410
+ const hypohtesis = new Hypothesis(context, string, node, lineIndex, statement);
412
411
 
413
412
  return hypohtesis;
414
413
  }
@@ -422,7 +421,7 @@ export function conjectureFromConjectureNode(conjectureNode, context) {
422
421
  suppositions = suppositionsFromTopLevelAssertionNode(topLevelAsssertionNode, context),
423
422
  signature = signatureFromTopLevelAssertionNode(topLevelAsssertionNode, context),
424
423
  hypotheses = hypothesesFromTopLevelAssertionNode(topLevelAsssertionNode, context),
425
- topLevelAsssertionString = topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
424
+ topLevelAsssertionString = topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction),
426
425
  node = conjectureNode, ///
427
426
  string = topLevelAsssertionString, ///
428
427
  lineIndex = null;
@@ -1168,6 +1167,12 @@ export function provisionalFromTypeNode(typeNode, context) {
1168
1167
  return provisional;
1169
1168
  }
1170
1169
 
1170
+ export function provisionalFromTermNode(termNode, context) {
1171
+ const provisional = null;
1172
+
1173
+ return provisional;
1174
+ }
1175
+
1171
1176
  export function derivationFromProofNode(proofNode, context) {
1172
1177
  const derivationNode = proofNode.getDerivationNode(),
1173
1178
  derivation = derivationFromDerivationNode(derivationNode, context);
@@ -1322,9 +1327,9 @@ export function typeFromTypeAssertionNode(typeAssertionNode, context) {
1322
1327
  return type;
1323
1328
  }
1324
1329
 
1325
- export function identifierFromVarialbeNode(variableNode, context) {
1330
+ export function identifierFromVariableNode(variableNode, context) {
1326
1331
  const variableIdentifier = variableNode.getVariableIdentifier(),
1327
- identifier = variableIdentifier; ///
1332
+ identifier = variableIdentifier; ///
1328
1333
 
1329
1334
  return identifier;
1330
1335
  }
@@ -1379,6 +1384,12 @@ export function nominalTypeNameFromTypeNode(typeNode, context) {
1379
1384
  return nominalTypeName;
1380
1385
  }
1381
1386
 
1387
+ export function provisionalFromVariableNode(variableNode, context) {
1388
+ const provisional = null;
1389
+
1390
+ return provisional;
1391
+ }
1392
+
1382
1393
  export function assumptionFromJudgementNode(judgementNode, context) {
1383
1394
  const assumptionNode = judgementNode.getAssumptionNode(),
1384
1395
  assumption = assumptionFromAssumptionNode(assumptionNode, context);
@@ -1673,6 +1684,16 @@ export function typeFromVariableDeclarationNode(variableDeclarationNode, context
1673
1684
  return type;
1674
1685
  }
1675
1686
 
1687
+ export function topLevelAssertionFromSectionNode(sectionNode, context) {
1688
+ const axiom = axiomFromSectionNode(sectionNode, context),
1689
+ lemma = lemmaFromSectionNode(sectionNode, context),
1690
+ theorem = theoremFromSectionNode(sectionNode, context),
1691
+ conjecture = conjectureFromSectionNode(sectionNode, context),
1692
+ topLevelAssertion = (axiom || lemma || theorem || conjecture);
1693
+
1694
+ return topLevelAssertion;
1695
+ }
1696
+
1676
1697
  export function procedureCallFromSuppositionNode(suppositionNode, context) {
1677
1698
  let procedureCall = null;
1678
1699
 
@@ -1712,12 +1733,6 @@ export function typeFromBracketedConstructorNode(bracketedCcnstructorNode, conte
1712
1733
  return type;
1713
1734
  }
1714
1735
 
1715
- export function propertyRelationsFromVariableNode(variableNode, context) {
1716
- const propertyRelations = [];
1717
-
1718
- return propertyRelations;
1719
- }
1720
-
1721
1736
  export function definedAssertionFromStatementNode(statementNode, context) {
1722
1737
  let definedAssertion = null;
1723
1738
 
@@ -97,7 +97,7 @@ function mergeEquivalence(equivalencesA, equivalenceB, context) {
97
97
  const equivalenceBDisjointFromEquivalenceA = equivalenceB.isDisjointFrom(equivalenceA);
98
98
 
99
99
  if (equivalenceBDisjointFromEquivalenceA) {
100
- const mergedEquivalence = equivalenceB; ///
100
+ const mergedEquivalence = equivalenceA; ///
101
101
 
102
102
  mergedEquivalences.push(mergedEquivalence);
103
103
  } else {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { baseTypeFromNothing } from "../utilities/type";
4
- import { EMPTY_STRING, PROVISIONALLY } from "../constants";
4
+ import { EMPTY_STRING, PROVISIONAL, PROVISIONALLY } from "../constants";
5
5
 
6
6
  export function termsStringFromTerms(terms) {
7
7
  const termsString = terms.reduce((termsString, term) => {
@@ -98,11 +98,19 @@ export function parametersStringFromParameters(parameters) {
98
98
  }
99
99
 
100
100
  export function provisinalStringFromProvisional(provisional) {
101
- const provisionString = provisional ?
102
- PROVISIONALLY :
101
+ const provisinalString = provisional ?
102
+ `${PROVISIONAL} ` :
103
103
  EMPTY_STRING;
104
104
 
105
- return provisionString;
105
+ return provisinalString;
106
+ }
107
+
108
+ export function provisionallyStringFromProvisional(provisional) {
109
+ const provisinallyString = provisional ?
110
+ ` ${PROVISIONALLY}` :
111
+ EMPTY_STRING;
112
+
113
+ return provisinallyString;
106
114
  }
107
115
 
108
116
  export function suppositionsStringFromSuppositions(suppositions) {
@@ -119,13 +127,6 @@ export function suppositionsStringFromSuppositions(suppositions) {
119
127
  return suppositionsString;
120
128
  }
121
129
 
122
- export function signatureStringFromTerms(terms) {
123
- const termsString = termsStringFromTerms(terms),
124
- signatureString = `[${termsString}]`;
125
-
126
- return signatureString;
127
- }
128
-
129
130
  export function equivalenceStringFromTerms(terms) {
130
131
  const termsString = termsStringFromTerms(terms),
131
132
  equivalenceString = `[${termsString}]`;
@@ -133,6 +134,14 @@ export function equivalenceStringFromTerms(terms) {
133
134
  return equivalenceString;
134
135
  }
135
136
 
137
+ export function signatureStringFromSignature(signature) {
138
+ const signatureString = (signature !== null) ?
139
+ signature.getString() :
140
+ null;
141
+
142
+ return signatureString;
143
+ }
144
+
136
145
  export function typeStringFromNominalTypeName(nominalTypeName) {
137
146
  const typeString = nominalTypeName; ///
138
147
 
@@ -147,34 +156,20 @@ export function termSubstitutionStringFromTermAndVariable(term, variable) {
147
156
  return termSubstitutionString;
148
157
  }
149
158
 
150
- export function assumptionStringFromReferenceAndStatement(reference, statement) {
151
- const referenceString = reference.getString(),
152
- statementString = statement.getString(),
153
- assumptionString = `${referenceString} :: ${statementString}`;
154
-
155
- return assumptionString;
156
- }
157
-
158
159
  export function rulsStringFromLabelsPremisesAndConclusion(labels, premises, conclusion) {
160
+ let ruleString = EMPTY_STRING;
161
+
159
162
  const conclusionString = conclusion.getString(),
160
163
  premisesString = premisesStringFromPremises(premises),
161
- labelsString = labelsStringFromLabels(labels),
162
- ruleString = (premisesString !== null) ?
163
- `${labelsString} :: [${premisesString}]...${conclusionString}` :
164
- `${labelsString} :: ${conclusionString}`;
164
+ labelsString = labelsStringFromLabels(labels);
165
165
 
166
- return ruleString;
167
- }
166
+ ruleString = `${ruleString}${labelsString} :: `;
168
167
 
169
- export function sectionStringFromHypothesesTopLevelAssertion(hypotheses, axiom, lemma, theorem, conjecture) {
170
- const topLevelAssertion = (axiom || lemma || theorem || conjecture),
171
- topLevelAssertionString = topLevelAssertion.getString(),
172
- hypothesesString = hypothesesStringFromHypotheses(hypotheses),
173
- sectionString = (topLevelAssertionString !== null) ?
174
- `[${hypothesesString}]::: ${topLevelAssertionString}` :
175
- `[${hypothesesString}]::: `;
168
+ ruleString = (premisesString !== null) ?
169
+ `${ruleString}[${premisesString}]...${conclusionString}` :
170
+ `${ruleString}${conclusionString}`;
176
171
 
177
- return sectionString;
172
+ return ruleString;
178
173
  }
179
174
 
180
175
  export function subproofStringFromSuppositionsAndSubDerivation(suppositions, subDerivation) {
@@ -194,6 +189,14 @@ export function frameSubstitutionStringFromFrameAndMetavariable(frame, metavaria
194
189
  return string;
195
190
  }
196
191
 
192
+ export function sectionStringFromHypothesesAndTopLevelAssertion(hypotheses, topLevelAssertion) {
193
+ const topLevelAssertionString = topLevelAssertion.getString(),
194
+ hypothesesString = hypothesesStringFromHypotheses(hypotheses),
195
+ sectionString = `[${hypothesesString}]::: ${topLevelAssertionString}`;
196
+
197
+ return sectionString;
198
+ }
199
+
197
200
  export function metaLevelAssumptionStringFromReferenceAndStatement(reference, statement) {
198
201
  const statementString = statement.getString(),
199
202
  referneceString = reference.getString(),
@@ -226,26 +229,6 @@ export function referenceSubstitutionStringFromReferenceAndMetavariable(referenc
226
229
  return referenceSubstitutionString;
227
230
  }
228
231
 
229
- export function topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction) {
230
- let topLevelAssertionString;
231
-
232
- const suppositionsString = suppositionsStringFromSuppositions(suppositions),
233
- deductionString = deduction.getString(),
234
- labelsString = labelsStringFromLabels(labels);
235
-
236
- if (labelsString !== null) {
237
- topLevelAssertionString = (suppositionsString !== null) ?
238
- `${labelsString} :: [${suppositionsString}]...${deductionString}` :
239
- `${labelsString} :: ${deductionString}`;
240
- } else {
241
- topLevelAssertionString = (suppositionsString !== null) ?
242
- `[${suppositionsString}]...${deductionString}` :
243
- deductionString;
244
- }
245
-
246
- return topLevelAssertionString;
247
- }
248
-
249
232
  export function complexTypeDeclarationStringFromTypeSuperTypesAndProvisional(type, superTypes, provisional) {
250
233
  const typeString = type.getString(),
251
234
  superTypesString = superTypesStringFromSuperTypes(superTypes),
@@ -266,6 +249,29 @@ export function topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction(lab
266
249
  return topLevelMetaAssertionString;
267
250
  }
268
251
 
252
+ export function topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction) {
253
+ let topLevelAssertionString = EMPTY_STRING;
254
+
255
+ const deductionString = deduction.getString(),
256
+ labelsString = labelsStringFromLabels(labels),
257
+ signatureString = signatureStringFromSignature(signature),
258
+ suppositionsString = suppositionsStringFromSuppositions(suppositions);
259
+
260
+ topLevelAssertionString = (labelsString !== null) ?
261
+ `${topLevelAssertionString}${labelsString} :: ` :
262
+ `${topLevelAssertionString}`;
263
+
264
+ topLevelAssertionString = (signatureString !== null) ?
265
+ `${topLevelAssertionString} ${signatureString}` :
266
+ `${topLevelAssertionString}`;
267
+
268
+ topLevelAssertionString = (suppositionsString !== null) ?
269
+ `${topLevelAssertionString}[${suppositionsString}]...${deductionString}` :
270
+ `${topLevelAssertionString}${deductionString}`;
271
+
272
+ return topLevelAssertionString;
273
+ }
274
+
269
275
  export function statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution) {
270
276
  const statementString = statement.getString(),
271
277
  metavariableString = metavariable.getString(),
@@ -4,7 +4,7 @@ import { arrayUtilities } from "necessary";
4
4
 
5
5
  const { compress } = arrayUtilities;
6
6
 
7
- export function termFromTermAndSubstitutions(term, generalContext, specificContext) {
7
+ export function termFromTermAndSubstitutions(term, context) {
8
8
  if (term !== null) {
9
9
  const termNode = term.getNode(),
10
10
  termSingular = term.isSingular();
@@ -13,11 +13,10 @@ export function termFromTermAndSubstitutions(term, generalContext, specificConte
13
13
 
14
14
  if (termSingular) {
15
15
  const variableNode = termNode.getVariableNode(),
16
- substitution = specificContext.findSubstitutionByVariableNode(variableNode);
16
+ derivedSubstitution = context.findDerivedSubstitutionByVariableNode(variableNode);
17
17
 
18
- if (substitution !== null) {
19
- const termSubstitution = substitution, ///
20
- replacementTerm = termSubstitution.getReplacementTerm();
18
+ if (derivedSubstitution !== null) {
19
+ const replacementTerm = derivedSubstitution.getReplacementTerm();
21
20
 
22
21
  term = replacementTerm; ///
23
22
  }
@@ -27,7 +26,7 @@ export function termFromTermAndSubstitutions(term, generalContext, specificConte
27
26
  return term;
28
27
  }
29
28
 
30
- export function frameFromFrameAndSubstitutions(frame, generalContext, specificContext) {
29
+ export function frameFromFrameAndSubstitutions(frame, context) {
31
30
  if (frame !== null) {
32
31
  const frameNode = frame.getNode(),
33
32
  frameSingular = frame.isSingular();
@@ -36,11 +35,10 @@ export function frameFromFrameAndSubstitutions(frame, generalContext, specificCo
36
35
 
37
36
  if (frameSingular) {
38
37
  const metavariableNode = frameNode.getMetavariableNode(),
39
- substitution = specificContext.findSubstitutionByMetavariableNode(metavariableNode);
38
+ derivedSubstitution = context.findDerivedSubstitutionByMetavariableNode(metavariableNode);
40
39
 
41
- if (substitution !== null) {
42
- const frameSubstitution = substitution, ///
43
- replacementFrame = frameSubstitution.getReplacementFrame();
40
+ if (derivedSubstitution !== null) {
41
+ const replacementFrame = derivedSubstitution.getReplacementFrame();
44
42
 
45
43
  frame = replacementFrame; ///
46
44
  }
@@ -50,43 +48,19 @@ export function frameFromFrameAndSubstitutions(frame, generalContext, specificCo
50
48
  return frame;
51
49
  }
52
50
 
53
- export function statementFromStatementAndSubstitutions(statement, generalContext, specificContext) {
51
+ export function statementFromStatementAndSubstitutions(statement, context) {
54
52
  if (statement !== null) {
55
53
  const statementNode = statement.getNode(),
56
54
  statementSingular = statement.isSingular();
57
55
 
58
- statement = null;
56
+ statement = null; ///
59
57
 
60
58
  if (statementSingular) {
61
- let substitution = null;
59
+ const metavariableNode = statementNode.getMetavariableNode(),
60
+ derivedSubstitution = context.findDerivedSubstitutionByMetavariableNode(metavariableNode);
62
61
 
63
- const substitutionNode = statementNode.getSubstitutionNode();
64
-
65
- if (substitutionNode !== null) {
66
- let context = generalContext; ///
67
-
68
- generalContext = specificContext; ///
69
-
70
- specificContext = context; ///
71
-
72
- substitution = specificContext.findSubstitutionBySubstitutionNode(substitutionNode);
73
-
74
- context = generalContext; ///
75
-
76
- generalContext = specificContext; ///
77
-
78
- specificContext = context; ///
79
- }
80
-
81
- const metavariableNode = statementNode.getMetavariableNode();
82
-
83
- substitution = (substitution !== null) ?
84
- specificContext.findSubstitutionByMetavariableNodeAndSubstitution(metavariableNode, substitution) :
85
- specificContext.findSubstitutionByMetavariableNode(metavariableNode);
86
-
87
- if (substitution !== null) {
88
- const statementSubstitution = substitution, ///
89
- replacementStatement = statementSubstitution.getReplacementStatement();
62
+ if (derivedSubstitution !== null) {
63
+ const replacementStatement = derivedSubstitution.getReplacementStatement();
90
64
 
91
65
  statement = replacementStatement; ///
92
66
  }
@@ -34,49 +34,6 @@ async function unifyStepWithRule(step, context) {
34
34
  return stepUnifiesWithRule;
35
35
  }
36
36
 
37
- async function unifyStepWithReference(step, context) {
38
- let stepUnifiesWithReference = false;
39
-
40
- const reference = step.getReference();
41
-
42
- if (reference !== null) {
43
- const stepString = step.getString(),
44
- referenceString = reference.getString();
45
-
46
- context.trace(`Unifying the '${stepString}' step with the '${referenceString}' reference...`);
47
-
48
- const topLevelAssertion = context.findTopLevelAssertionByReference(reference);
49
-
50
- if (topLevelAssertion !== null) {
51
- const subproofOrProofAssertions = context.getSubproofOrProofAssertions(),
52
- stepAndSubproofOrProofAssertionsUnify = await topLevelAssertion.unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context);
53
-
54
- if (stepAndSubproofOrProofAssertionsUnify) {
55
- stepUnifiesWithReference = true;
56
- }
57
- } else {
58
- const metaLevel = context.isMetaLevel();
59
-
60
- if (metaLevel) {
61
- descend((context) => {
62
- const { MetaLevelAssumption } = elements,
63
- metaLevelAssumption = MetaLevelAssumption.fromStep(step, context);
64
-
65
- metaLevelAssumption.validate(context);
66
-
67
- stepUnifiesWithReference = true;
68
- }, context);
69
- }
70
- }
71
-
72
- if (stepUnifiesWithReference) {
73
- context.debug(`...unified the '${stepString}' step with the '${referenceString}' reference.`);
74
- }
75
- }
76
-
77
- return stepUnifiesWithReference;
78
- }
79
-
80
37
  async function unifyStepWithTopLevelAssertion(step, context) {
81
38
  let stepUnifiesWithTopLevelAssertion = false;
82
39
 
@@ -86,20 +43,24 @@ async function unifyStepWithTopLevelAssertion(step, context) {
86
43
  const topLevelAssertion = context.findTopLevelAssertionByReference(reference);
87
44
 
88
45
  if (topLevelAssertion !== null) {
89
- const stepString = step.getString(),
90
- topLevelAssertionString = reference.getString();
46
+ const satisfiable = topLevelAssertion.isSatisfiable();
91
47
 
92
- context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion...`);
48
+ if (!satisfiable) {
49
+ const stepString = step.getString(),
50
+ topLevelAssertionString = reference.getString();
93
51
 
94
- const subproofOrProofAssertions = context.getSubproofOrProofAssertions(),
95
- stepAndSubproofOrProofAssertionsUnify = await topLevelAssertion.unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context);
52
+ context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion...`);
96
53
 
97
- if (stepAndSubproofOrProofAssertionsUnify) {
98
- stepUnifiesWithTopLevelAssertion = true;
99
- }
54
+ const subproofOrProofAssertions = context.getSubproofOrProofAssertions(),
55
+ stepAndSubproofOrProofAssertionsUnify = await topLevelAssertion.unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context);
100
56
 
101
- if (stepUnifiesWithTopLevelAssertion) {
102
- context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion.`);
57
+ if (stepAndSubproofOrProofAssertionsUnify) {
58
+ stepUnifiesWithTopLevelAssertion = true;
59
+ }
60
+
61
+ if (stepUnifiesWithTopLevelAssertion) {
62
+ context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion.`);
63
+ }
103
64
  }
104
65
  }
105
66
  }
@@ -263,8 +224,47 @@ async function unifyStepAsUnqualifiedSignatureAssertion(step, context) {
263
224
  return stepUnifiesAsUnqualifiedSignatureAssertion;
264
225
  }
265
226
 
266
- async function unifyStepAsSignatureAssertionWithReference(step, context) {
267
- let stepUnifiesAsSignatureAssertionWithReference = false;
227
+ async function validateStepAsMetaLevelAssumption(step, context) {
228
+ let stepValidatesAsMetaLevelAssumption = false;
229
+
230
+ const metaLevel = context.isMetaLevel();
231
+
232
+ if (metaLevel) {
233
+ const reference = step.getReference();
234
+
235
+ if (reference !== null) {
236
+ const stepString = step.getString(),
237
+ topLevelAssertion = context.findTopLevelAssertionByReference(reference);
238
+
239
+ if (topLevelAssertion === null) {
240
+ context.trace(`Validating the '${stepString}' step as a meta-level assumption...`);
241
+
242
+ descend((context) => {
243
+ let metaLevelAssumption;
244
+
245
+ const { MetaLevelAssumption } = elements;
246
+
247
+ metaLevelAssumption = MetaLevelAssumption.fromStep(step, context);
248
+
249
+ metaLevelAssumption = metaLevelAssumption.validate(context); ///
250
+
251
+ if (metaLevelAssumption !== null) {
252
+ stepValidatesAsMetaLevelAssumption = true;
253
+ }
254
+ }, context);
255
+
256
+ if (stepValidatesAsMetaLevelAssumption) {
257
+ context.debug(`...validated the '${stepString}' step as a meta-level assumption.`);
258
+ }
259
+ }
260
+ }
261
+ }
262
+
263
+ return stepValidatesAsMetaLevelAssumption;
264
+ }
265
+
266
+ async function unifyStepAsSignatureAssertion(step, context) {
267
+ let stepUnifiesAsSignatureAssertion = false;
268
268
 
269
269
  const reference = step.getReference();
270
270
 
@@ -285,17 +285,17 @@ async function unifyStepAsSignatureAssertionWithReference(step, context) {
285
285
  const unifyTopLevelAssertion = await signatureAssertion.unifyTopLevelAssertion(topLevelAssertion, context);
286
286
 
287
287
  if (unifyTopLevelAssertion) {
288
- stepUnifiesAsSignatureAssertionWithReference = true;
288
+ stepUnifiesAsSignatureAssertion = true;
289
289
  }
290
290
 
291
- if (stepUnifiesAsSignatureAssertionWithReference) {
291
+ if (stepUnifiesAsSignatureAssertion) {
292
292
  context.debug(`...unified the '${stepString}' step as a signature assertion with the '${referenceString}' reference.`);
293
293
  }
294
294
  }
295
295
  }
296
296
  }
297
297
 
298
- return stepUnifiesAsSignatureAssertionWithReference;
298
+ return stepUnifiesAsSignatureAssertion;
299
299
  }
300
300
 
301
301
  async function compareStepWithSubproofOrProofAssertions(step, context) {
@@ -325,7 +325,6 @@ async function compareStepWithSubproofOrProofAssertions(step, context) {
325
325
 
326
326
  export const unifySteps = [
327
327
  unifyStepWithRule,
328
- unifyStepWithReference,
329
328
  unifyStepWithTopLevelAssertion,
330
329
  unifyStepWithSignatureAssertion,
331
330
  unifyStepAsUnqualifiedEquality,
@@ -333,6 +332,7 @@ export const unifySteps = [
333
332
  unifyStepAsUnqualifiedTypeAssertion,
334
333
  unifyStepAsUnqualifiedPropertyAssertion,
335
334
  unifyStepAsUnqualifiedSignatureAssertion,
336
- unifyStepAsSignatureAssertionWithReference,
335
+ validateStepAsMetaLevelAssumption,
336
+ unifyStepAsSignatureAssertion,
337
337
  compareStepWithSubproofOrProofAssertions
338
338
  ];
@@ -3,6 +3,7 @@
3
3
  import elements from "../elements";
4
4
 
5
5
  import { choose, descend } from "./context";
6
+ import { provisionallyStringFromProvisional } from "./string";
6
7
  import { bracketedConstructorFromNothing, bracketedCombinatorFromNothing } from "../utilities/instance";
7
8
 
8
9
  function validateTermAsVariable(term, context, validateForwards) {
@@ -23,12 +24,16 @@ function validateTermAsVariable(term, context, validateForwards) {
23
24
 
24
25
  if (variable !== null) {
25
26
  const type = variable.getType(),
26
- typeString = type.getString();
27
+ typeString = type.getString(),
28
+ provisional = variable.isProvisional(),
29
+ provisionallyString = provisionallyStringFromProvisional(provisional);
27
30
 
28
- context.trace(`Setting the '${termString}' term's type to the '${typeString}' type.`);
31
+ context.trace(`Setting the '${termString}' term's type to the '${typeString}' type${provisionallyString}.`);
29
32
 
30
33
  term.setType(type);
31
34
 
35
+ term.setProvisional(provisional);
36
+
32
37
  const validatesForwards = validateForwards(term);
33
38
 
34
39
  if (validatesForwards) {