occam-verify-cli 1.0.228 → 1.0.233

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 (111) hide show
  1. package/lib/context/local.js +1 -14
  2. package/lib/dom/assertion/property.js +2 -2
  3. package/lib/dom/axiom.js +25 -17
  4. package/lib/dom/combinator.js +5 -5
  5. package/lib/dom/conclusion.js +5 -5
  6. package/lib/dom/conjecture.js +9 -9
  7. package/lib/dom/constructor.js +5 -5
  8. package/lib/dom/declaration/combinator.js +14 -14
  9. package/lib/dom/declaration/complexType.js +35 -35
  10. package/lib/dom/declaration/constructor.js +19 -19
  11. package/lib/dom/declaration/metavariable.js +22 -22
  12. package/lib/dom/declaration/simpleType.js +23 -23
  13. package/lib/dom/declaration/variable.js +20 -20
  14. package/lib/dom/declaration.js +4 -2
  15. package/lib/dom/deduction.js +5 -5
  16. package/lib/dom/derivation.js +5 -5
  17. package/lib/dom/error.js +9 -9
  18. package/lib/dom/hypothesis.js +260 -0
  19. package/lib/dom/label.js +18 -24
  20. package/lib/dom/lemma.js +7 -7
  21. package/lib/dom/metaLemma.js +9 -9
  22. package/lib/dom/metaType.js +4 -10
  23. package/lib/dom/metatheorem.js +9 -9
  24. package/lib/dom/metavariable.js +7 -8
  25. package/lib/dom/parameter.js +2 -2
  26. package/lib/dom/premise.js +5 -5
  27. package/lib/dom/procedureCall.js +11 -10
  28. package/lib/dom/proof.js +3 -3
  29. package/lib/dom/property.js +9 -9
  30. package/lib/dom/reference.js +23 -22
  31. package/lib/dom/rule.js +68 -37
  32. package/lib/dom/section.js +146 -0
  33. package/lib/dom/signature.js +5 -5
  34. package/lib/dom/statement.js +25 -20
  35. package/lib/dom/step.js +9 -7
  36. package/lib/dom/subDerivation.js +5 -5
  37. package/lib/dom/subproof.js +7 -7
  38. package/lib/dom/substitution/statement.js +3 -3
  39. package/lib/dom/supposition.js +5 -5
  40. package/lib/dom/term.js +5 -6
  41. package/lib/dom/theorem.js +9 -9
  42. package/lib/dom/topLevelAssertion.js +72 -33
  43. package/lib/dom/topLevelMetaAssertion.js +56 -24
  44. package/lib/dom/type.js +21 -21
  45. package/lib/dom/variable.js +9 -15
  46. package/lib/index.js +3 -1
  47. package/lib/node/hypothesis.js +123 -0
  48. package/lib/node/section.js +116 -0
  49. package/lib/nonTerminalNodeMap.js +5 -3
  50. package/lib/ruleNames.js +9 -1
  51. package/lib/utilities/json.js +59 -59
  52. package/lib/utilities/subproof.js +10 -10
  53. package/lib/verifier/combinator.js +9 -10
  54. package/lib/verifier/constructor.js +10 -11
  55. package/lib/verifier/topLevel.js +38 -31
  56. package/package.json +6 -6
  57. package/src/context/local.js +0 -14
  58. package/src/dom/assertion/property.js +1 -1
  59. package/src/dom/axiom.js +33 -30
  60. package/src/dom/combinator.js +4 -4
  61. package/src/dom/conclusion.js +5 -5
  62. package/src/dom/conjecture.js +8 -8
  63. package/src/dom/constructor.js +4 -4
  64. package/src/dom/declaration/combinator.js +14 -14
  65. package/src/dom/declaration/complexType.js +35 -35
  66. package/src/dom/declaration/constructor.js +20 -20
  67. package/src/dom/declaration/metavariable.js +22 -22
  68. package/src/dom/declaration/simpleType.js +22 -22
  69. package/src/dom/declaration/variable.js +21 -21
  70. package/src/dom/declaration.js +5 -3
  71. package/src/dom/deduction.js +5 -5
  72. package/src/dom/derivation.js +5 -5
  73. package/src/dom/error.js +8 -8
  74. package/src/dom/hypothesis.js +230 -0
  75. package/src/dom/label.js +17 -19
  76. package/src/dom/lemma.js +8 -8
  77. package/src/dom/metaLemma.js +8 -8
  78. package/src/dom/metaType.js +2 -6
  79. package/src/dom/metatheorem.js +8 -8
  80. package/src/dom/metavariable.js +9 -12
  81. package/src/dom/parameter.js +1 -1
  82. package/src/dom/premise.js +8 -8
  83. package/src/dom/procedureCall.js +9 -9
  84. package/src/dom/proof.js +2 -2
  85. package/src/dom/property.js +8 -8
  86. package/src/dom/reference.js +23 -27
  87. package/src/dom/rule.js +74 -46
  88. package/src/dom/section.js +70 -0
  89. package/src/dom/signature.js +4 -4
  90. package/src/dom/statement.js +24 -32
  91. package/src/dom/step.js +10 -8
  92. package/src/dom/subDerivation.js +5 -5
  93. package/src/dom/subproof.js +8 -8
  94. package/src/dom/substitution/statement.js +5 -5
  95. package/src/dom/supposition.js +7 -7
  96. package/src/dom/term.js +3 -8
  97. package/src/dom/theorem.js +7 -7
  98. package/src/dom/topLevelAssertion.js +85 -48
  99. package/src/dom/topLevelMetaAssertion.js +61 -33
  100. package/src/dom/type.js +22 -22
  101. package/src/dom/variable.js +8 -11
  102. package/src/index.js +2 -0
  103. package/src/node/hypothesis.js +23 -0
  104. package/src/node/section.js +16 -0
  105. package/src/nonTerminalNodeMap.js +7 -1
  106. package/src/ruleNames.js +2 -0
  107. package/src/utilities/json.js +58 -58
  108. package/src/utilities/subproof.js +10 -10
  109. package/src/verifier/combinator.js +6 -11
  110. package/src/verifier/constructor.js +9 -12
  111. package/src/verifier/topLevel.js +42 -30
package/src/dom/type.js CHANGED
@@ -227,10 +227,10 @@ class Type {
227
227
 
228
228
  static name = "Type";
229
229
 
230
- static fromJSON(json, fileContext) {
230
+ static fromJSON(json, context) {
231
231
  const { name, provisional } = json,
232
- properties = propertiesFromJSON(json, fileContext),
233
- superTypes = superTypesFromJSON(json, fileContext),
232
+ properties = propertiesFromJSON(json, context),
233
+ superTypes = superTypesFromJSON(json, context),
234
234
  typeName = name, ///
235
235
  string = stringFromTypeNameNameAndSuperTypes(typeName, superTypes),
236
236
  type = new Type(string, name, superTypes, properties, provisional);
@@ -238,15 +238,15 @@ class Type {
238
238
  return type;
239
239
  }
240
240
 
241
- static fromTypeNode(typeNode, fileContext) {
242
- const type = typeFromTypeNode(typeNode, fileContext);
241
+ static fromTypeNode(typeNode, context) {
242
+ const type = typeFromTypeNode(typeNode, context);
243
243
 
244
244
  return type;
245
245
  }
246
246
 
247
- static fromTypeAssertionNode(typeAssertionNode, fileContext) {
247
+ static fromTypeAssertionNode(typeAssertionNode, context) {
248
248
  const typeNode = typeAssertionNode.getTypeNode(),
249
- type = typeFromTypeNode(typeNode, fileContext);
249
+ type = typeFromTypeNode(typeNode, context);
250
250
 
251
251
  return type;
252
252
  }
@@ -266,38 +266,38 @@ class Type {
266
266
  return type;
267
267
  }
268
268
 
269
- static fromPropertyDeclarationNode(propertyDeclarationNode, fileContext) {
269
+ static fromPropertyDeclarationNode(propertyDeclarationNode, context) {
270
270
  const typeNode = propertyDeclarationNode.getTypeNode(),
271
- type = typeFromTypeNode(typeNode, fileContext);
271
+ type = typeFromTypeNode(typeNode, context);
272
272
 
273
273
  return type;
274
274
  }
275
275
 
276
- static fromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, fileContext) {
276
+ static fromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
277
277
  const properties = [],
278
278
  provisional = simpleTypeDeclarationNode.isProvisional(),
279
279
  typeName = simpleTypeDeclarationNode.getTypeName(),
280
280
  name = typeName, ///
281
- superTypes = superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, fileContext),
281
+ superTypes = superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context),
282
282
  string = stringFromTypeNameNameAndSuperTypes(typeName, superTypes),
283
283
  type = new Type(string, name, superTypes, properties, provisional);
284
284
 
285
285
  return type;
286
286
  }
287
287
 
288
- static fromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
288
+ static fromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
289
289
  const provisional = complexTypeDeclarationNode.isProvisional(),
290
290
  typeName = complexTypeDeclarationNode.getTypeName(),
291
291
  name = typeName,
292
- superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext),
293
- properties = propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext),
292
+ superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
293
+ properties = propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
294
294
  string = stringFromTypeNameNameAndSuperTypes(typeName, superTypes),
295
295
  type = new Type(string, name, superTypes, properties, provisional);
296
296
 
297
297
  return type;
298
298
  }
299
299
 
300
- static fromConstructorDeclarationNode(constructorDeclarationNode, fileContext) {
300
+ static fromConstructorDeclarationNode(constructorDeclarationNode, context) {
301
301
  let type;
302
302
 
303
303
  const typeNode = constructorDeclarationNode.getTypeNode();
@@ -307,7 +307,7 @@ class Type {
307
307
  } else {
308
308
  const provisional = constructorDeclarationNode.isProvisional();
309
309
 
310
- type = typeFromTypeNode(typeNode, fileContext);
310
+ type = typeFromTypeNode(typeNode, context);
311
311
 
312
312
  type.setProvisional(provisional);
313
313
  }
@@ -318,10 +318,10 @@ class Type {
318
318
 
319
319
  export default domAssigned(Type);
320
320
 
321
- function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, fileContext) {
321
+ function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
322
322
  const superTypeNodes = simpleTypeDeclarationNode.getSuperTypeNodes(),
323
323
  superTypes = superTypeNodes.map((superTypeNode) => {
324
- const superType = Type.fromTypeNode(superTypeNode, fileContext);
324
+ const superType = Type.fromTypeNode(superTypeNode, context);
325
325
 
326
326
  return superType;
327
327
  });
@@ -329,10 +329,10 @@ function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, file
329
329
  return superTypes;
330
330
  }
331
331
 
332
- function superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
332
+ function superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
333
333
  const superTypeNodes = complexTypeDeclarationNode.getSuperTypeNodes(),
334
334
  superTypes = superTypeNodes.map((superTypeNode) => {
335
- const superType = Type.fromTypeNode(superTypeNode, fileContext);
335
+ const superType = Type.fromTypeNode(superTypeNode, context);
336
336
 
337
337
  return superType;
338
338
  });
@@ -340,11 +340,11 @@ function superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fi
340
340
  return superTypes;
341
341
  }
342
342
 
343
- function propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, fileContext) {
343
+ function propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
344
344
  const { Property } = dom,
345
345
  propertyDeclarationNodes = complexTypeDeclarationNode.getPropertyDeclarationNodes(),
346
346
  properties = propertyDeclarationNodes.map((propertyDeclarationNode) => {
347
- const property = Property.fromPropertyDeclarationNode(propertyDeclarationNode, fileContext);
347
+ const property = Property.fromPropertyDeclarationNode(propertyDeclarationNode, context);
348
348
 
349
349
  return property;
350
350
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  import dom from "../dom";
4
- import LocalContext from "../context/local";
5
4
 
6
5
  import { domAssigned } from "../dom";
7
6
  import { EMPTY_STRING } from "../constants";
@@ -88,17 +87,17 @@ export default domAssigned(class Variable {
88
87
  return verifies;
89
88
  }
90
89
 
91
- verifyType(fileContext) {
90
+ verifyType(context) {
92
91
  let typeVerifies = false;
93
92
 
94
93
  const typeString = this.type.getString();
95
94
 
96
- fileContext.trace(`Verifying the '${typeString}' type...`);
95
+ context.trace(`Verifying the '${typeString}' type...`);
97
96
 
98
- const type = fileContext.findTypeByTypeName(typeString);
97
+ const type = context.findTypeByTypeName(typeString);
99
98
 
100
99
  if (type === null) {
101
- fileContext.debug(`The '${typeString}' type is not present.`);
100
+ context.debug(`The '${typeString}' type is not present.`);
102
101
  } else {
103
102
  this.type = type; ///
104
103
 
@@ -106,7 +105,7 @@ export default domAssigned(class Variable {
106
105
  }
107
106
 
108
107
  if (typeVerifies) {
109
- fileContext.debug(`...verified the '${typeString}' type.`);
108
+ context.debug(`...verified the '${typeString}' type.`);
110
109
  }
111
110
 
112
111
  return typeVerifies;
@@ -164,16 +163,14 @@ export default domAssigned(class Variable {
164
163
 
165
164
  static name = "Variable";
166
165
 
167
- static fromJSON(json, fileContext) {
166
+ static fromJSON(json, context) {
168
167
  const { string } = json,
169
- localContext = LocalContext.fromFileContext(fileContext),
170
- context = localContext, ///
171
168
  variableString = string, ///
172
169
  variableNode = variableNodeFromVariableString(variableString, context),
173
170
  variableName = variableNode.getVariableName(),
174
171
  node = variableNode,
175
172
  name = variableName, ///
176
- type = typeFromJSON(json, fileContext),
173
+ type = typeFromJSON(json, context),
177
174
  propertyRelations = [],
178
175
  variable = new Variable(string, node, name, type, propertyRelations);
179
176
 
@@ -213,7 +210,7 @@ export default domAssigned(class Variable {
213
210
  return variable;
214
211
  }
215
212
 
216
- static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
213
+ static fromVariableDeclarationNode(variableDeclarationNode, context) {
217
214
  const { Variable } = dom,
218
215
  provisional = variableDeclarationNode.isProvisional(),
219
216
  typeNode = variableDeclarationNode.getTypeNode(),
package/src/index.js CHANGED
@@ -12,6 +12,7 @@ import Proof from "./dom/proof";
12
12
  import Error from "./dom/error";
13
13
  import Premise from "./dom/premise";
14
14
  import Theorem from "./dom/theorem";
15
+ import Section from "./dom/section";
15
16
  import Equality from "./dom/equality";
16
17
  import MetaType from "./dom/metaType";
17
18
  import Subproof from "./dom/subproof";
@@ -28,6 +29,7 @@ import Conjecture from "./dom/conjecture";
28
29
  import Conclusion from "./dom/conclusion";
29
30
  import Derivation from "./dom/derivation";
30
31
  import Combinator from "./dom/combinator";
32
+ import Hypothesis from "./dom/hypothesis";
31
33
  import Constructor from "./dom/constructor";
32
34
  import Declaration from "./dom/declaration";
33
35
  import Supposition from "./dom/supposition";
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ import NonTerminalNode from "../node/nonTerminal";
4
+
5
+ import { NONSENSE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
6
+
7
+ export default class HypothesisNode extends NonTerminalNode {
8
+ getNonsenseNode() {
9
+ const ruleName = NONSENSE_RULE_NAME,
10
+ nonsenseNode = this.getNodeByRuleName(ruleName);
11
+
12
+ return nonsenseNode;
13
+ }
14
+
15
+ getStatementNode() {
16
+ const ruleName = STATEMENT_RULE_NAME,
17
+ statementNode = this.getNodeByRuleName(ruleName);
18
+
19
+ return statementNode;
20
+ }
21
+
22
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(HypothesisNode, ruleName, childNodes, opacity, precedence); }
23
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ import NonTerminalNode from "../node/nonTerminal";
4
+
5
+ import { HYPOTHESIS_RULE_NAME } from "../ruleNames";
6
+
7
+ export default class SectionNode extends NonTerminalNode {
8
+ getHypothesisNodes() {
9
+ const ruleName = HYPOTHESIS_RULE_NAME,
10
+ hypothesisNodes = this.getNodesByRuleName(ruleName);
11
+
12
+ return hypothesisNodes;
13
+ }
14
+
15
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(SectionNode, ruleName, childNodes, opacity, precedence); }
16
+ }
@@ -12,6 +12,7 @@ import LemmaNode from "./node/lemma";
12
12
  import ProofNode from "./node/proof";
13
13
  import LabelNode from "./node/label";
14
14
  import LabelsNode from "./node/labels";
15
+ import SectionNode from "./node/section";
15
16
  import PremiseNode from "./node/premise";
16
17
  import TheoremNode from "./node/theorem";
17
18
  import NonsenseNode from "./node/nonsense";
@@ -32,6 +33,7 @@ import DerivationNode from "./node/derivation";
32
33
  import CombinatorNode from "./node/combinator";
33
34
  import ConclusionNode from "./node/conclusion";
34
35
  import ConjectureNode from "./node/conjecture";
36
+ import HypothesisNode from "./node/hypothesis";
35
37
  import SuppositionNode from "./node/supposition";
36
38
  import ConstructorNode from "./node/constructor";
37
39
  import DeclarationNode from "./node/declaration";
@@ -41,7 +43,6 @@ import MetavariableNode from "./node/metavariable";
41
43
  import ProcedureCallNode from "./node/procedureCall";
42
44
  import SubDerivationNode from "./node/subDerivation";
43
45
  import TypeAssertionNode from "./node/assertion/type";
44
- import SimpleTypeDeclarationNode from "./node/declaration/simpleType";
45
46
  import PropertyRelationNode from "./node/propertyRelation"
46
47
  import DefinedAssertionNode from "./node/assertion/defined";
47
48
  import TermSubstitutionNode from "./node/substitution/term";
@@ -56,6 +57,7 @@ import PropertyDeclarationNode from "./node/declaration/property";
56
57
  import variableDeclarationNode from "./node/declaration/variable";
57
58
  import StatementSubstitutionNode from "./node/substitution/statement";
58
59
  import ReferenceSubstitutionNode from "./node/substitution/reference";
60
+ import SimpleTypeDeclarationNode from "./node/declaration/simpleType";
59
61
  import combinatorDeclarationNode from "./node/declaration/combinator";
60
62
  import complexTypeDeclarationNode from "./node/declaration/complexType";
61
63
  import constructorDeclarationNode from "./node/declaration/constructor";
@@ -75,6 +77,7 @@ import { RULE_RULE_NAME,
75
77
  LABELS_RULE_NAME,
76
78
  THEOREM_RULE_NAME,
77
79
  PREMISE_RULE_NAME,
80
+ SECTION_RULE_NAME,
78
81
  NONSENSE_RULE_NAME,
79
82
  ARGUMENT_RULE_NAME,
80
83
  SUBPROOF_RULE_NAME,
@@ -93,6 +96,7 @@ import { RULE_RULE_NAME,
93
96
  COMBINATOR_RULE_NAME,
94
97
  CONCLUSION_RULE_NAME,
95
98
  CONJECTURE_RULE_NAME,
99
+ HYPOTHESIS_RULE_NAME,
96
100
  CONSTRUCTOR_RULE_NAME,
97
101
  DECLARATION_RULE_NAME,
98
102
  SUPPOSITION_RULE_NAME,
@@ -137,6 +141,7 @@ const nonTerminalNodeMap = {
137
141
  [LABELS_RULE_NAME]: LabelsNode,
138
142
  [THEOREM_RULE_NAME]: TheoremNode,
139
143
  [PREMISE_RULE_NAME]: PremiseNode,
144
+ [SECTION_RULE_NAME]: SectionNode,
140
145
  [ARGUMENT_RULE_NAME]: ArgumentNode,
141
146
  [PROPERTY_RULE_NAME]: PropertyNode,
142
147
  [SUBPROOF_RULE_NAME]: SubproofNode,
@@ -155,6 +160,7 @@ const nonTerminalNodeMap = {
155
160
  [CONCLUSION_RULE_NAME]: ConclusionNode,
156
161
  [CONJECTURE_RULE_NAME]: ConjectureNode,
157
162
  [DERIVATION_RULE_NAME]: DerivationNode,
163
+ [HYPOTHESIS_RULE_NAME]: HypothesisNode,
158
164
  [SUPPOSITION_RULE_NAME]: SuppositionNode,
159
165
  [CONSTRUCTOR_RULE_NAME]: ConstructorNode,
160
166
  [DECLARATION_RULE_NAME]: DeclarationNode,
package/src/ruleNames.js CHANGED
@@ -14,6 +14,7 @@ export const LABEL_RULE_NAME = "label";
14
14
  export const LABELS_RULE_NAME = "labels";
15
15
  export const THEOREM_RULE_NAME = "theorem";
16
16
  export const PREMISE_RULE_NAME = "premise";
17
+ export const SECTION_RULE_NAME = "section";
17
18
  export const ARGUMENT_RULE_NAME = "argument";
18
19
  export const PROPERTY_RULE_NAME = "property";
19
20
  export const EQUALITY_RULE_NAME = "equality";
@@ -32,6 +33,7 @@ export const COMBINATOR_RULE_NAME = "combinator";
32
33
  export const CONCLUSION_RULE_NAME = "conclusion";
33
34
  export const CONJECTURE_RULE_NAME = "conjecture";
34
35
  export const DERIVATION_RULE_NAME = "derivation";
36
+ export const HYPOTHESIS_RULE_NAME = "hypothesis";
35
37
  export const SUPPOSITION_RULE_NAME = "supposition";
36
38
  export const CONSTRUCTOR_RULE_NAME = "constructor";
37
39
  export const DECLARATION_RULE_NAME = "declaration";