occam-verify-cli 0.0.1073 → 0.0.1075

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 (141) hide show
  1. package/lib/assertion/type.js +47 -54
  2. package/lib/assignment/equality.js +8 -2
  3. package/lib/assignment/variable.js +2 -2
  4. package/lib/axiom.js +9 -12
  5. package/lib/combinator/bracketed.js +3 -2
  6. package/lib/combinator.js +6 -6
  7. package/lib/conclusion.js +2 -3
  8. package/lib/conjecture.js +10 -15
  9. package/lib/consequent.js +2 -3
  10. package/lib/constructor/bracketed.js +3 -2
  11. package/lib/constructor.js +6 -6
  12. package/lib/context/file.js +48 -107
  13. package/lib/context/local.js +52 -73
  14. package/lib/declaration/combinator.js +5 -5
  15. package/lib/declaration/constructor.js +5 -5
  16. package/lib/declaration/metavariable.js +4 -5
  17. package/lib/declaration/type.js +3 -3
  18. package/lib/declaration/variable.js +5 -5
  19. package/lib/declaration.js +6 -2
  20. package/lib/derivation.js +6 -2
  21. package/lib/equality.js +53 -22
  22. package/lib/equivalence.js +22 -24
  23. package/lib/frame.js +11 -13
  24. package/lib/index.js +13 -1
  25. package/lib/judgement.js +11 -8
  26. package/lib/label.js +6 -7
  27. package/lib/lemma.js +10 -15
  28. package/lib/metaLemma.js +15 -15
  29. package/lib/metatheorem.js +9 -14
  30. package/lib/metavariable.js +17 -23
  31. package/lib/mixins/statement/qualified/unify.js +2 -2
  32. package/lib/mixins/statement/verify.js +8 -12
  33. package/lib/mixins/term/verify.js +4 -4
  34. package/lib/premise.js +2 -3
  35. package/lib/proof.js +8 -4
  36. package/lib/proofStep.js +10 -8
  37. package/lib/reference.js +3 -3
  38. package/lib/rule.js +11 -16
  39. package/lib/statement/qualified.js +6 -2
  40. package/lib/statement/unqualified.js +1 -1
  41. package/lib/statement.js +5 -5
  42. package/lib/subDerivation.js +6 -2
  43. package/lib/subproof.js +10 -7
  44. package/lib/substitution/statementForMetavariable.js +14 -15
  45. package/lib/substitution.js +13 -13
  46. package/lib/substitutions.js +51 -47
  47. package/lib/supposition.js +2 -3
  48. package/lib/term.js +5 -5
  49. package/lib/theorem.js +10 -15
  50. package/lib/topLevelAssertion.js +3 -3
  51. package/lib/type.js +15 -22
  52. package/lib/unifier/equality.js +2 -2
  53. package/lib/unifier/metaLevel.js +6 -6
  54. package/lib/unifier/metavariable.js +5 -5
  55. package/lib/unifier/statementWithCombinator.js +2 -2
  56. package/lib/utilities/brackets.js +2 -2
  57. package/lib/utilities/equivalences.js +8 -8
  58. package/lib/utilities/node.js +2 -7
  59. package/lib/utilities/nominal.js +26 -0
  60. package/lib/utilities/subproof.js +2 -2
  61. package/lib/utilities/tokens.js +3 -7
  62. package/lib/variable.js +13 -9
  63. package/lib/verifier/metaLevel.js +2 -2
  64. package/lib/verifier/statementAsCombinator.js +2 -2
  65. package/lib/verifier/termAsConstructor.js +2 -2
  66. package/lib/verifier/topLevel.js +9 -15
  67. package/package.json +1 -1
  68. package/src/assertion/type.js +52 -57
  69. package/src/assignment/equality.js +3 -1
  70. package/src/assignment/variable.js +2 -1
  71. package/src/axiom.js +6 -8
  72. package/src/combinator/bracketed.js +6 -3
  73. package/src/combinator.js +4 -4
  74. package/src/conclusion.js +2 -2
  75. package/src/conjecture.js +8 -11
  76. package/src/consequent.js +2 -2
  77. package/src/constructor/bracketed.js +6 -3
  78. package/src/constructor.js +4 -4
  79. package/src/context/file.js +46 -90
  80. package/src/context/local.js +51 -90
  81. package/src/declaration/combinator.js +5 -4
  82. package/src/declaration/constructor.js +5 -4
  83. package/src/declaration/metavariable.js +3 -4
  84. package/src/declaration/type.js +2 -2
  85. package/src/declaration/variable.js +5 -4
  86. package/src/declaration.js +7 -1
  87. package/src/derivation.js +7 -1
  88. package/src/equality.js +80 -27
  89. package/src/equivalence.js +30 -28
  90. package/src/frame.js +10 -9
  91. package/src/index.js +12 -0
  92. package/src/judgement.js +11 -5
  93. package/src/label.js +5 -5
  94. package/src/lemma.js +8 -11
  95. package/src/metaLemma.js +13 -11
  96. package/src/metatheorem.js +6 -10
  97. package/src/metavariable.js +18 -34
  98. package/src/mixins/statement/qualified/unify.js +1 -2
  99. package/src/mixins/statement/verify.js +19 -18
  100. package/src/mixins/term/verify.js +4 -3
  101. package/src/premise.js +2 -2
  102. package/src/proof.js +10 -3
  103. package/src/proofStep.js +12 -7
  104. package/src/reference.js +3 -2
  105. package/src/rule.js +10 -12
  106. package/src/statement/qualified.js +7 -1
  107. package/src/statement/unqualified.js +0 -1
  108. package/src/statement.js +3 -3
  109. package/src/subDerivation.js +8 -2
  110. package/src/subproof.js +12 -5
  111. package/src/substitution/statementForMetavariable.js +12 -12
  112. package/src/substitution.js +9 -9
  113. package/src/substitutions.js +42 -34
  114. package/src/supposition.js +2 -2
  115. package/src/term.js +3 -3
  116. package/src/theorem.js +8 -11
  117. package/src/topLevelAssertion.js +3 -2
  118. package/src/type.js +15 -28
  119. package/src/unifier/equality.js +1 -1
  120. package/src/unifier/metaLevel.js +8 -10
  121. package/src/unifier/metavariable.js +5 -5
  122. package/src/unifier/statementWithCombinator.js +5 -5
  123. package/src/utilities/brackets.js +2 -2
  124. package/src/utilities/equivalences.js +9 -9
  125. package/src/utilities/node.js +1 -10
  126. package/src/utilities/nominal.js +14 -0
  127. package/src/utilities/subproof.js +2 -2
  128. package/src/utilities/tokens.js +2 -9
  129. package/src/variable.js +16 -11
  130. package/src/verifier/metaLevel.js +2 -2
  131. package/src/verifier/statementAsCombinator.js +3 -3
  132. package/src/verifier/termAsConstructor.js +2 -2
  133. package/src/verifier/topLevel.js +15 -14
  134. package/lib/assignment/metavariable.js +0 -62
  135. package/lib/unifier/intrinsicLevel.js +0 -144
  136. package/lib/utilities/unify.js +0 -24
  137. package/lib/verifier/intrinsicLevel.js +0 -140
  138. package/src/assignment/metavariable.js +0 -30
  139. package/src/unifier/intrinsicLevel.js +0 -54
  140. package/src/utilities/unify.js +0 -23
  141. package/src/verifier/intrinsicLevel.js +0 -42
package/src/theorem.js CHANGED
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import shim from "./shim";
4
- import Label from "./label";
5
- import Proof from "./proof";
6
- import Consequent from "./consequent";
7
- import Supposition from "./supposition";
8
4
  import LocalContext from "./context/local";
9
- import Substitutions from "./substitutions";
10
5
  import TopLevelAssertion from "./topLevelAssertion";
11
6
 
12
7
  import { stringFromLabels } from "./topLevelAssertion";
@@ -25,15 +20,15 @@ class Theorem extends TopLevelAssertion {
25
20
 
26
21
  this.fileContext.trace(`Verifying the '${theoremString}' theorem...`);
27
22
 
28
- const labelsVerifiedAtTopLevel = this.labels.every((label) => {
29
- const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
23
+ const labelsVerifiedWhenDeclared = this.labels.every((label) => {
24
+ const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
30
25
 
31
- if (labelVVerifiedAtTopLevel) {
26
+ if (labelVVerifiedWhenDeclared) {
32
27
  return true;
33
28
  }
34
29
  });
35
30
 
36
- if (labelsVerifiedAtTopLevel) {
31
+ if (labelsVerifiedWhenDeclared) {
37
32
  const localContext = LocalContext.fromFileContext(this.fileContext),
38
33
  suppositionsVerified = this.suppositions.every((supposition) => {
39
34
  const suppositionVerified = supposition.verify(localContext);
@@ -47,7 +42,8 @@ class Theorem extends TopLevelAssertion {
47
42
  const consequentVerified = this.consequent.verify(localContext);
48
43
 
49
44
  if (consequentVerified) {
50
- const substitutions = Substitutions.fromNothing(),
45
+ const { Substitutions } = shim,
46
+ substitutions = Substitutions.fromNothing(),
51
47
  proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
52
48
 
53
49
  if (proofVerified) {
@@ -71,7 +67,8 @@ class Theorem extends TopLevelAssertion {
71
67
  static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
72
68
 
73
69
  static fromTheoremNode(theoremNode, fileContext) {
74
- const proofNode = proofNodeQuery(theoremNode),
70
+ const { Label, Proof, Consequent, Supposition } = shim,
71
+ proofNode = proofNodeQuery(theoremNode),
75
72
  labelNodes = labelNodesQuery(theoremNode),
76
73
  consequentNode = consequentNodeQuery(theoremNode),
77
74
  suppositionNodes = suppositionNodesQuery(theoremNode),
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import Substitutions from "./substitutions";
5
+ import shim from "./shim";
6
6
 
7
7
  import { EMPTY_STRING } from "./constants";
8
8
  import { labelsFromJSON,
@@ -63,7 +63,8 @@ export default class TopLevelAssertion {
63
63
  unifyStatement(statement, localContext) {
64
64
  let statementUnified = false;
65
65
 
66
- const proofSteps = localContext.getProofSteps(),
66
+ const { Substitutions } = shim,
67
+ proofSteps = localContext.getProofSteps(),
67
68
  substitutions = Substitutions.fromNothing(),
68
69
  proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
69
70
 
package/src/type.js CHANGED
@@ -36,37 +36,24 @@ class Type {
36
36
  }
37
37
 
38
38
  isSubTypeOf(type) {
39
- let subTypeOf = false;
40
-
41
- let superType = this.superType;
42
-
43
- while (superType !== null) {
44
- if (superType === type) {
45
- subTypeOf = true;
46
-
47
- break;
48
- }
49
-
50
- superType = superType.getSuperType();
39
+ let subTypeOf;
40
+
41
+ if (false) {
42
+ ///
43
+ } else if (this === objectType) {
44
+ subTypeOf = false;
45
+ } else if (this.superType === type) {
46
+ subTypeOf = true;
47
+ } else {
48
+ subTypeOf = this.superType.isSubTypeOf(type);
51
49
  }
52
50
 
53
51
  return subTypeOf;
54
52
  }
55
53
 
56
54
  isSuperTypeOf(type) {
57
- let superTypeOf = false;
58
-
59
- let superType = type.getSuperType();
60
-
61
- while (superType !== null) {
62
- if (superType === this) {
63
- superTypeOf = true;
64
-
65
- break;
66
- }
67
-
68
- superType = superType.getSuperType();
69
- }
55
+ const subTypeOf = type.isSubTypeOf(this),
56
+ superTypeOf = subTypeOf; ///
70
57
 
71
58
  return superTypeOf;
72
59
  }
@@ -122,12 +109,12 @@ class Type {
122
109
  return typeNodeMatches;
123
110
  }
124
111
 
125
- verifyAtTopLevel(fileContext) {
112
+ verifyWhenDeclared(fileContext) {
126
113
  let verifiedAtTopLevel = false;
127
114
 
128
115
  const typeString = this.string; ///
129
116
 
130
- fileContext.trace(`Verifying the '${typeString}' type at top level...`);
117
+ fileContext.trace(`Verifying the '${typeString}' type when declared...`);
131
118
 
132
119
  const typePresent = fileContext.isTypePresentByTypeName(this.name);
133
120
 
@@ -149,7 +136,7 @@ class Type {
149
136
  }
150
137
 
151
138
  if (verifiedAtTopLevel) {
152
- fileContext.debug(`...verified the '${typeString}' type at top level.`);
139
+ fileContext.debug(`...verified the '${typeString}' type when declared.`);
153
140
  }
154
141
 
155
142
  return verifiedAtTopLevel;
@@ -5,7 +5,7 @@ import Unifier from "../unifier";
5
5
  import { nodeQuery } from "../utilities/query";
6
6
  import { findEquivalenceByTermNodes } from "../utilities/equivalences";
7
7
 
8
- const termNodeQuery = nodeQuery("/term!");
8
+ const termNodeQuery = nodeQuery("/term");
9
9
 
10
10
  class EqualityUnifier extends Unifier {
11
11
  unify(leftTermNode, rightTermNode, localContext) {
@@ -6,11 +6,11 @@ import TermForVariableSubstitution from "../substitution/termForVariable";
6
6
  import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
7
7
 
8
8
  import { nodeQuery } from "../utilities/query";
9
- import { variableNameFromVariableNode, metavariableNameFromMetavariableNode } from "../utilities/name";
9
+ import { variableNameFromVariableNode } from "../utilities/name";
10
10
 
11
- const termNodeQuery = nodeQuery("/term!"),
12
- frameNodeQuery = nodeQuery("/frame!"),
13
- statementNodeQuery = nodeQuery("/statement!"),
11
+ const termNodeQuery = nodeQuery("/term"),
12
+ frameNodeQuery = nodeQuery("/frame"),
13
+ statementNodeQuery = nodeQuery("/statement"),
14
14
  termVariableNodeQuery = nodeQuery("/term/variable!"),
15
15
  frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
16
16
  statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
@@ -56,8 +56,7 @@ class MetaLevelUnifier extends Unifier {
56
56
 
57
57
  const { Statement } = shim,
58
58
  metavariableNode = statementMetavariableNode, ///
59
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
60
- metavariable = localContextA.findMetavariableByMetavariableName(metavariableName);
59
+ metavariable = localContextA.findMetavariableByMetavariableNode(metavariableNode, localContextB);
61
60
 
62
61
  localContext = localContextB; ///
63
62
 
@@ -67,7 +66,7 @@ class MetaLevelUnifier extends Unifier {
67
66
 
68
67
  statementUnified = metavariable.unifyStatement(statement, substitution, substitutions, localContext);
69
68
  } else {
70
- statementUnified = unifyStatementWithStatement(statementNodeA, statementNodeB, substitutions, localContextA, localContextB);
69
+ statementUnified = unifyChildNodes(statementNodeA, statementNodeB, substitutions, localContextA, localContextB);
71
70
  }
72
71
  }
73
72
 
@@ -81,8 +80,7 @@ class MetaLevelUnifier extends Unifier {
81
80
  let frameUnified = false;
82
81
 
83
82
  const metavariableNode = frameMetavariableNodeA, ///
84
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
85
- metavariablePresent = localContextA.isMetavariablePresentByMetavariableName(metavariableName);
83
+ metavariablePresent = localContextA.isMetavariablePresentByMetavariableNode(metavariableNode, localContextB);
86
84
 
87
85
  if (metavariablePresent) {
88
86
  const { Frame, Metavariable } = shim,
@@ -127,7 +125,7 @@ const metaLevelUnifier = new MetaLevelUnifier();
127
125
 
128
126
  export default metaLevelUnifier;
129
127
 
130
- function unifyStatementWithStatement(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
128
+ function unifyChildNodes(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
131
129
  const nonTerminalNodeA = statementNodeA, ///
132
130
  nonTerminalNodeB = statementNodeB, ///
133
131
  nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
@@ -6,8 +6,8 @@ import Unifier from "../unifier";
6
6
  import { nodeQuery } from "../utilities/query";
7
7
  import { typeNameFromTypeNode } from "../utilities/name";
8
8
 
9
- const typeNodeQuery = nodeQuery("/type!"),
10
- termNodeQuery = nodeQuery("/term!");
9
+ const typeNodeQuery = nodeQuery("/type"),
10
+ termNodeQuery = nodeQuery("/term");
11
11
 
12
12
  class MetavariableUnifier extends Unifier {
13
13
  unify(metavariableNodeA, metavariableNodeB, localContext) {
@@ -27,7 +27,7 @@ class MetavariableUnifier extends Unifier {
27
27
  nodeQueryA: typeNodeQuery,
28
28
  nodeQueryB: termNodeQuery,
29
29
  unify: (typeNodeA, termNodeB, localContext) => {
30
- let unified = false;
30
+ let termUnified = false;
31
31
 
32
32
  const { Term } = shim,
33
33
  typeNode = typeNodeA, ///
@@ -40,11 +40,11 @@ class MetavariableUnifier extends Unifier {
40
40
  termVerifiedGivenType = term.verifyGivenType(type, localContext);
41
41
 
42
42
  if (termVerifiedGivenType) {
43
- unified = true;
43
+ termUnified = true;
44
44
  }
45
45
  }
46
46
 
47
- return unified;
47
+ return termUnified;
48
48
  }
49
49
  }
50
50
  ];
@@ -6,11 +6,11 @@ import Unifier from "../unifier";
6
6
  import { nodeQuery } from "../utilities/query";
7
7
  import { typeNameFromTypeNode } from "../utilities/name";
8
8
 
9
- const termNodeQuery = nodeQuery("/term!"),
10
- typeNodeQuery = nodeQuery("/type!"),
11
- frameNodeQuery = nodeQuery("/frame!"),
12
- metaTypeNodeQuery = nodeQuery("/metaType!"),
13
- statementNodeQuery = nodeQuery("/statement!");
9
+ const termNodeQuery = nodeQuery("/term"),
10
+ typeNodeQuery = nodeQuery("/type"),
11
+ frameNodeQuery = nodeQuery("/frame"),
12
+ metaTypeNodeQuery = nodeQuery("/metaType"),
13
+ statementNodeQuery = nodeQuery("/statement");
14
14
 
15
15
  class StatementWithCombinatorUnifier extends Unifier {
16
16
  unify(combinatorStatementNode, statementNode, assignments, stated, localContext) {
@@ -5,8 +5,8 @@ import { bracketedTermNode } from "../constructor/bracketed";
5
5
  import { bracketedStatementNode } from "../combinator/bracketed";
6
6
  import { BRACKETED_TERM_DEPTH, BRACKETED_STATEMENT_DEPTH } from "../constants";
7
7
 
8
- const bracketedTermChildNodeQuery = nodeQuery("/term/argument/term!"),
9
- bracketedStatementChildNodeQuery = nodeQuery("/statement/metaArgument/statement!");
8
+ const bracketedTermChildNodeQuery = nodeQuery("/term/argument/term"),
9
+ bracketedStatementChildNodeQuery = nodeQuery("/statement/metaArgument/statement");
10
10
 
11
11
  export function stripBracketsFromTermNode(termNode) {
12
12
  const bracketedTermChildNode = bracketedTermChildNodeFromTermNode(termNode);
@@ -6,9 +6,9 @@ import Equivalence from "../equivalence";
6
6
 
7
7
  const { push, compress, separate } = arrayUtilities;
8
8
 
9
- export function mergeEquivalences(equivalencesA, equivalencesB, localContext) {
10
- const typesA = typesFromEquivalences(equivalencesA, localContext),
11
- typesB = typesFromEquivalences(equivalencesB, localContext),
9
+ export function mergeEquivalences(equivalencesA, equivalencesB) {
10
+ const typesA = typesFromEquivalences(equivalencesA),
11
+ typesB = typesFromEquivalences(equivalencesB),
12
12
  types = [
13
13
  ...typesA,
14
14
  ...typesB
@@ -23,8 +23,8 @@ export function mergeEquivalences(equivalencesA, equivalencesB, localContext) {
23
23
  const equivalences = types.map((type) => {
24
24
  let equivalence;
25
25
 
26
- const equivalenceA = findEquivalenceByType(equivalencesA, type, localContext),
27
- equivalenceB = findEquivalenceByType(equivalencesB, type, localContext);
26
+ const equivalenceA = findEquivalenceByType(equivalencesA, type),
27
+ equivalenceB = findEquivalenceByType(equivalencesB, type);
28
28
 
29
29
  if ((equivalenceA !== null) && (equivalenceB !== null)) {
30
30
  const leftEquivalence = equivalenceA, ///
@@ -43,9 +43,9 @@ export function mergeEquivalences(equivalencesA, equivalencesB, localContext) {
43
43
  return equivalences;
44
44
  }
45
45
 
46
- export function findEquivalenceByType(equivalences, type, localContext) {
46
+ export function findEquivalenceByType(equivalences, type) {
47
47
  const equivalence = equivalences.find((equivalence) => {
48
- const equivalenceMatchesType = equivalence.matchType(type, localContext);
48
+ const equivalenceMatchesType = equivalence.matchType(type);
49
49
 
50
50
  if (equivalenceMatchesType) {
51
51
  return true;
@@ -127,9 +127,9 @@ export function groundedTermsAndDefinedVariablesFromFromEquivalences(equivalence
127
127
  }
128
128
  }
129
129
 
130
- function typesFromEquivalences(equivalences, localContext) {
130
+ function typesFromEquivalences(equivalences) {
131
131
  const types = equivalences.map((equivalence) => {
132
- const type = equivalence.getType(localContext);
132
+ const type = equivalence.getType();
133
133
 
134
134
  return type;
135
135
  });
@@ -1,23 +1,14 @@
1
1
  "use strict";
2
2
 
3
- import { parsersUtilities } from "occam-custom-grammars";
4
-
5
3
  import { nodeQuery } from "../utilities/query";
6
- import { combinedCustomGrammarFromNothing } from "./customGrammar";
7
4
  import { VARIABLE_RULE_NAME,
8
5
  METAVARIABLE_RULE_NAME,
9
6
  UNQUALIFIED_STATEMENT_RULE_NAME,
10
7
  CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
11
8
  import { variableTokensFromVariableString,
12
9
  metavariableTokensFromMetavariableString,
13
- unqualifiedStatementTokensFromUnqualifiedStatementString,
14
10
  constructorDeclarationTokensFromConstructorDeclarationString } from "../utilities/tokens";
15
11
 
16
- const { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
17
-
18
- const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
19
- nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
20
-
21
12
  const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
22
13
  statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
23
14
  substitutionNodeQuery = nodeQuery("/unqualifiedStatement/statement/substitution");
@@ -114,7 +105,7 @@ export function constructorDeclarationNodeFromConstructorDeclarationTokens(const
114
105
  return constructorDeclarationNode;
115
106
  }
116
107
 
117
- function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser = nominalParser) {
108
+ function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser) {
118
109
  const ruleMap = parser.getRuleMap(),
119
110
  rule = ruleMap[ruleName],
120
111
  node = parser.parse(tokens, rule);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
4
+
5
+ import { combinedCustomGrammarFromNothing } from "./customGrammar";
6
+
7
+ const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
8
+ { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
9
+
10
+ const combinedCustomGrammar = combinedCustomGrammarFromNothing();
11
+
12
+ export const nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
13
+
14
+ export const nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
@@ -3,8 +3,8 @@
3
3
  import { nodeQuery, nodesQuery } from "./query";
4
4
  import { nodeAsString, nodesAsString } from "./string";
5
5
 
6
- const subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
7
- subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
6
+ const subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement"),
7
+ subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement");
8
8
 
9
9
  export function subproofStringFromSubproofNode(subproofNode, fileContext) {
10
10
  const tokens = fileContext.getTokens(),
@@ -1,15 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
- import { lexersUtilities } from "occam-custom-grammars";
5
4
 
6
- import { combinedCustomGrammarFromNothing } from "./customGrammar";
7
-
8
- const { front } = arrayUtilities,
9
- { nominalLexerFromCombinedCustomGrammar } = lexersUtilities;
10
-
11
- const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
12
- nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
5
+ const { front } = arrayUtilities;
13
6
 
14
7
  export function variableTokensFromVariableString(variableString, lexer) {
15
8
  const variableContent = `${variableString}`,
@@ -63,7 +56,7 @@ export function substitutionTokensFromUnqualifiedStatementTokensAndSubstitutionN
63
56
  return substitutionTokens;
64
57
  }
65
58
 
66
- function tokensFromContentAndLexer(content, lexer = nominalLexer) {
59
+ function tokensFromContentAndLexer(content, lexer) {
67
60
  const tokens = lexer.tokenise(content);
68
61
 
69
62
  return tokens;
package/src/variable.js CHANGED
@@ -70,14 +70,14 @@ class Variable {
70
70
  variableName = variableNameFromVariableNode(variableNode),
71
71
  variable = localContext.findVariableByVariableName(variableName);
72
72
 
73
- if (variable === null) {
74
- localContext.debug(`The '${variableString}' variable is not present.`);
75
- } else {
73
+ if (variable !== null) {
76
74
  const type = variable.getType();
77
75
 
78
76
  this.type = type;
79
77
 
80
78
  verified = true;
79
+ } else {
80
+ localContext.debug(`The '${variableString}' variable is not present.`);
81
81
  }
82
82
 
83
83
  if (verified) {
@@ -115,12 +115,12 @@ class Variable {
115
115
  return typeVerified;
116
116
  }
117
117
 
118
- verifyAtTopLevel(fileContext) {
118
+ verifyWhenDeclared(fileContext) {
119
119
  let verifiedAtTopLevel;
120
120
 
121
121
  const variableString = this.string; ///
122
122
 
123
- fileContext.trace(`Verifying the '${variableString}' variable at top level...`);
123
+ fileContext.trace(`Verifying the '${variableString}' variable when declared...`);
124
124
 
125
125
  const variableNode = this.node, ///
126
126
  variableName = variableNameFromVariableNode(variableNode),
@@ -135,7 +135,7 @@ class Variable {
135
135
  }
136
136
 
137
137
  if (verifiedAtTopLevel) {
138
- fileContext.debug(`...verified the '${variableString}' variable at top level.`);
138
+ fileContext.debug(`...verified the '${variableString}' variable when declared.`);
139
139
  }
140
140
 
141
141
  return verifiedAtTopLevel;
@@ -248,11 +248,16 @@ class Variable {
248
248
  }
249
249
 
250
250
  static fromVariableNodeAndType(variableNode, type, localContext) {
251
- const node = variableNode, ///
252
- variableName = variableNameFromVariableNode(variableNode),
253
- string = localContext.nodeAsString(node),
254
- name = variableName, ///
255
- variable = new Variable(localContext, string, node, name, type);
251
+ let variable = null;
252
+
253
+ if (variableNode !== null) {
254
+ const node = variableNode, ///
255
+ variableName = variableNameFromVariableNode(variableNode),
256
+ string = localContext.nodeAsString(node),
257
+ name = variableName; ///
258
+
259
+ variable = new Variable(localContext, string, node, name, type);
260
+ }
256
261
 
257
262
  return variable;
258
263
  }
@@ -5,8 +5,8 @@ import Verifier from "../verifier";
5
5
 
6
6
  import { nodeQuery } from "../utilities/query";
7
7
 
8
- const termNodeQuery = nodeQuery("/term!"),
9
- statementNodeQuery = nodeQuery("/statement!");
8
+ const termNodeQuery = nodeQuery("/term"),
9
+ statementNodeQuery = nodeQuery("/statement");
10
10
 
11
11
  class MetaLevelVerifier extends Verifier {
12
12
  verify(node, assignments, stated, localContext) {
@@ -7,9 +7,9 @@ import LocalContext from "../context/local";
7
7
  import { nodeQuery } from "../utilities/query";
8
8
  import { typeNameFromTypeNode } from "../utilities/name";
9
9
 
10
- const termNodeQuery = nodeQuery("/term!"),
11
- typeNodeQuery = nodeQuery("/type!"),
12
- statementNodeQuery = nodeQuery("/statement!");
10
+ const termNodeQuery = nodeQuery("/term"),
11
+ typeNodeQuery = nodeQuery("/type"),
12
+ statementNodeQuery = nodeQuery("/statement");
13
13
 
14
14
  class StatementAsCombinatorVerifier extends Verifier {
15
15
  verifyStatement(statementNode, fileContext) {
@@ -7,8 +7,8 @@ import LocalContext from "../context/local";
7
7
  import { nodeQuery } from "../utilities/query";
8
8
  import {typeNameFromTypeNode} from "../utilities/name";
9
9
 
10
- const termNodeQuery = nodeQuery("/term!"),
11
- typeNodeQuery = nodeQuery("/type!");
10
+ const termNodeQuery = nodeQuery("/term"),
11
+ typeNodeQuery = nodeQuery("/type");
12
12
 
13
13
  class TermAsConstructorVerifier extends Verifier {
14
14
  verifyTerm(termNode, fileContext) {
@@ -1,13 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import Rule from "../rule";
3
+ import shim from "../shim";
4
4
  import Error from "../error";
5
- import Axiom from "../axiom";
6
- import Lemma from "../lemma";
7
- import Theorem from "../theorem";
8
- import MetaLemma from "../metaLemma";
9
- import Conjecture from "../conjecture";
10
- import Metatheorem from "../metatheorem";
11
5
  import TypeDeclaration from "../declaration/type";
12
6
  import VariableDeclaration from "../declaration/variable";
13
7
  import CombinatorDeclaration from "../declaration/combinator";
@@ -57,7 +51,8 @@ class TopLevelVerifier extends Verifier {
57
51
  {
58
52
  nodeQuery: ruleNodeQuery,
59
53
  verify: (ruleNode, fileContext) => {
60
- const rule = Rule.fromRuleNode(ruleNode, fileContext),
54
+ const { Rule } = shim,
55
+ rule = Rule.fromRuleNode(ruleNode, fileContext),
61
56
  ruleVerified = rule.verify();
62
57
 
63
58
  return ruleVerified;
@@ -66,7 +61,8 @@ class TopLevelVerifier extends Verifier {
66
61
  {
67
62
  nodeQuery: axiomNodeQuery,
68
63
  verify: (axiomNode, fileContext) => {
69
- const axiom = Axiom.fromAxiomNode(axiomNode, fileContext),
64
+ const { Axiom } = shim,
65
+ axiom = Axiom.fromAxiomNode(axiomNode, fileContext),
70
66
  axiomVerified = axiom.verify();
71
67
 
72
68
  return axiomVerified;
@@ -75,7 +71,8 @@ class TopLevelVerifier extends Verifier {
75
71
  {
76
72
  nodeQuery: lemmaNodeQuery,
77
73
  verify: (lemmaNode, fileContext) => {
78
- const lemma = Lemma.fromLemmaNode(lemmaNode, fileContext),
74
+ const { Lemma } = shim,
75
+ lemma = Lemma.fromLemmaNode(lemmaNode, fileContext),
79
76
  lemmaVerified = lemma.verify();
80
77
 
81
78
  return lemmaVerified;
@@ -84,7 +81,8 @@ class TopLevelVerifier extends Verifier {
84
81
  {
85
82
  nodeQuery: theoremNodeQuery,
86
83
  verify: (theoremNode, fileContext) => {
87
- const theorem = Theorem.fromTheoremNode(theoremNode, fileContext),
84
+ const { Theorem } = shim,
85
+ theorem = Theorem.fromTheoremNode(theoremNode, fileContext),
88
86
  theoremVerified = theorem.verify();
89
87
 
90
88
  return theoremVerified;
@@ -93,7 +91,8 @@ class TopLevelVerifier extends Verifier {
93
91
  {
94
92
  nodeQuery: metaLemmaNodeQuery,
95
93
  verify: (metaLemmaNode, fileContext) => {
96
- const metaLemma = MetaLemma.fromMetaLemmaNode(metaLemmaNode, fileContext),
94
+ const { MetaLemma } = shim,
95
+ metaLemma = MetaLemma.fromMetaLemmaNode(metaLemmaNode, fileContext),
97
96
  metaLemmaVerified = metaLemma.verify();
98
97
 
99
98
  return metaLemmaVerified;
@@ -102,7 +101,8 @@ class TopLevelVerifier extends Verifier {
102
101
  {
103
102
  nodeQuery: conjectureNodeQuery,
104
103
  verify: (conjectureNode, fileContext) => {
105
- const conjecture = Conjecture.fromConjectureNode(conjectureNode, fileContext),
104
+ const { Conjecture } = shim,
105
+ conjecture = Conjecture.fromConjectureNode(conjectureNode, fileContext),
106
106
  conjectureVerified = conjecture.verify();
107
107
 
108
108
  return conjectureVerified;
@@ -111,7 +111,8 @@ class TopLevelVerifier extends Verifier {
111
111
  {
112
112
  nodeQuery: metatheoremNodeQuery,
113
113
  verify: (metatheoremNode, fileContext) => {
114
- const metatheorem = Metatheorem.fromMetatheoremNode(metatheoremNode, fileContext),
114
+ const { Metatheorem } = shim,
115
+ metatheorem = Metatheorem.fromMetatheoremNode(metatheoremNode, fileContext),
115
116
  metatheoremVerified = metatheorem.verify();
116
117
 
117
118
  return metatheoremVerified;