occam-verify-cli 0.0.525 → 0.0.527

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 (136) hide show
  1. package/lib/assertion/type.js +10 -40
  2. package/lib/axiom.js +7 -7
  3. package/lib/axiomLemmaTheoremConjecture.js +190 -0
  4. package/lib/combinator.js +5 -5
  5. package/lib/conclusion.js +3 -3
  6. package/lib/conjecture.js +141 -0
  7. package/lib/consequence.js +5 -5
  8. package/lib/constants.js +4 -16
  9. package/lib/constructor.js +6 -6
  10. package/lib/context/file.js +85 -32
  11. package/lib/context/metaproof.js +46 -4
  12. package/lib/context/proof.js +38 -93
  13. package/lib/context/release/directory.js +20 -1
  14. package/lib/context/release/file.js +27 -3
  15. package/lib/equality.js +78 -51
  16. package/lib/index.js +1 -13
  17. package/lib/kinds.js +5 -1
  18. package/lib/label.js +5 -5
  19. package/lib/lemma.js +7 -7
  20. package/lib/matcher/metastatementForMetavariable.js +16 -19
  21. package/lib/matcher/statementForMetavariable.js +22 -20
  22. package/lib/matcher/{statementForVariable → termForVariable}/consequence.js +13 -13
  23. package/lib/matcher/{statementForVariable → termForVariable}/supposition.js +13 -13
  24. package/lib/matcher/termForVariable.js +198 -0
  25. package/lib/matcher.js +23 -64
  26. package/lib/mixins/file.js +62 -2
  27. package/lib/premise.js +6 -6
  28. package/lib/rule.js +5 -5
  29. package/lib/ruleNames.js +1 -9
  30. package/lib/step/proof.js +22 -1
  31. package/lib/substitution/statementForMetavariable.js +12 -8
  32. package/lib/substitution/termForVariable.js +86 -0
  33. package/lib/supposition.js +6 -6
  34. package/lib/theorem.js +7 -7
  35. package/lib/type.js +13 -6
  36. package/lib/utilities/string.js +17 -16
  37. package/lib/utilities/substitution.js +4 -5
  38. package/lib/variable.js +5 -39
  39. package/lib/verify/assertion/type.js +60 -37
  40. package/lib/verify/axiom.js +2 -3
  41. package/lib/verify/conclusion.js +2 -3
  42. package/lib/verify/conjecture.js +56 -0
  43. package/lib/verify/consequence.js +3 -4
  44. package/lib/verify/declaration/topLevel.js +7 -3
  45. package/lib/verify/label.js +2 -3
  46. package/lib/verify/lemma.js +2 -3
  47. package/lib/verify/metastatement/qualified.js +3 -4
  48. package/lib/verify/metastatement/unqualified.js +3 -4
  49. package/lib/verify/premise.js +3 -4
  50. package/lib/verify/rule.js +2 -3
  51. package/lib/verify/statement/qualified.js +41 -12
  52. package/lib/verify/statement/unqualified.js +3 -4
  53. package/lib/verify/statement.js +47 -51
  54. package/lib/verify/statementAsCombinator.js +2 -3
  55. package/lib/verify/supposition.js +3 -4
  56. package/lib/verify/term.js +3 -4
  57. package/lib/verify/termAsConstructor.js +4 -5
  58. package/lib/verify/theorem.js +2 -3
  59. package/lib/verify/type.js +2 -3
  60. package/lib/verify/variable.js +2 -3
  61. package/package.json +1 -1
  62. package/src/assertion/type.js +7 -32
  63. package/src/axiom.js +4 -4
  64. package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +9 -9
  65. package/src/combinator.js +4 -4
  66. package/src/conclusion.js +2 -2
  67. package/src/conjecture.js +13 -0
  68. package/src/consequence.js +4 -4
  69. package/src/constants.js +1 -4
  70. package/src/constructor.js +6 -6
  71. package/src/context/file.js +89 -32
  72. package/src/context/metaproof.js +44 -3
  73. package/src/context/proof.js +42 -37
  74. package/src/context/release/directory.js +24 -0
  75. package/src/context/release/file.js +34 -3
  76. package/src/equality.js +110 -61
  77. package/src/index.js +0 -3
  78. package/src/kinds.js +1 -0
  79. package/src/label.js +4 -4
  80. package/src/lemma.js +4 -4
  81. package/src/matcher/metastatementForMetavariable.js +22 -32
  82. package/src/matcher/statementForMetavariable.js +40 -34
  83. package/src/matcher/termForVariable/consequence.js +9 -0
  84. package/src/matcher/termForVariable/supposition.js +9 -0
  85. package/src/matcher/termForVariable.js +89 -0
  86. package/src/matcher.js +28 -22
  87. package/src/mixins/file.js +46 -1
  88. package/src/premise.js +6 -6
  89. package/src/rule.js +4 -4
  90. package/src/ruleNames.js +0 -2
  91. package/src/step/proof.js +27 -0
  92. package/src/substitution/statementForMetavariable.js +17 -10
  93. package/src/substitution/termForVariable.js +64 -0
  94. package/src/supposition.js +5 -5
  95. package/src/theorem.js +4 -4
  96. package/src/type.js +18 -8
  97. package/src/utilities/string.js +27 -21
  98. package/src/utilities/substitution.js +6 -4
  99. package/src/variable.js +5 -38
  100. package/src/verify/assertion/type.js +71 -65
  101. package/src/verify/axiom.js +1 -2
  102. package/src/verify/conclusion.js +1 -2
  103. package/src/verify/conjecture.js +73 -0
  104. package/src/verify/consequence.js +2 -3
  105. package/src/verify/declaration/topLevel.js +7 -0
  106. package/src/verify/label.js +1 -2
  107. package/src/verify/lemma.js +1 -2
  108. package/src/verify/metastatement/qualified.js +2 -3
  109. package/src/verify/metastatement/unqualified.js +2 -3
  110. package/src/verify/premise.js +2 -3
  111. package/src/verify/rule.js +1 -2
  112. package/src/verify/statement/qualified.js +55 -15
  113. package/src/verify/statement/unqualified.js +2 -3
  114. package/src/verify/statement.js +49 -70
  115. package/src/verify/statementAsCombinator.js +1 -2
  116. package/src/verify/supposition.js +2 -3
  117. package/src/verify/term.js +2 -3
  118. package/src/verify/termAsConstructor.js +3 -4
  119. package/src/verify/theorem.js +1 -2
  120. package/src/verify/type.js +1 -2
  121. package/src/verify/variable.js +1 -2
  122. package/lib/axiomLemmaTheorem.js +0 -190
  123. package/lib/jsonTypes.js +0 -30
  124. package/lib/matcher/statementForVariable.js +0 -201
  125. package/lib/substitution/statementForVariable.js +0 -86
  126. package/lib/utilities/json.js +0 -187
  127. package/lib/utilities/version.js +0 -32
  128. package/lib/versionChanges.js +0 -34
  129. package/src/jsonTypes.js +0 -6
  130. package/src/matcher/statementForVariable/consequence.js +0 -9
  131. package/src/matcher/statementForVariable/supposition.js +0 -9
  132. package/src/matcher/statementForVariable.js +0 -99
  133. package/src/substitution/statementForVariable.js +0 -64
  134. package/src/utilities/json.js +0 -264
  135. package/src/utilities/version.js +0 -30
  136. package/src/versionChanges.js +0 -11
package/src/matcher.js CHANGED
@@ -1,41 +1,47 @@
1
1
  "use strict";
2
2
 
3
3
  export default class Matcher {
4
- matchNode(nodeA, nodeB, ...remainingArguments) {
4
+ matchNode(nodeA, nodeB, substitutions, depth = Infinity) {
5
5
  let nodeMatches = false;
6
6
 
7
- const nodeATerminalNode = nodeA.isTerminalNode(),
8
- nodeBTerminalNode = nodeB.isTerminalNode();
9
-
10
- if (nodeATerminalNode === nodeBTerminalNode) {
11
- if (nodeATerminalNode) {
12
- const terminalNodeA = nodeA, ///
13
- terminalNodeB = nodeB, ///
14
- terminalNodeMatches = this.matchTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments);
15
-
16
- nodeMatches = terminalNodeMatches; ///
17
- } else {
18
- const nonTerminalNodeA = nodeA, ///
19
- nonTerminalNodeB = nodeB, ///
20
- nonTerminalNodeMatches = this.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments);
21
-
22
- nodeMatches = nonTerminalNodeMatches; ///
7
+ if (depth === 0) {
8
+ nodeMatches = true;
9
+ } else {
10
+ const nodeATerminalNode = nodeA.isTerminalNode(),
11
+ nodeBTerminalNode = nodeB.isTerminalNode();
12
+
13
+ if (nodeATerminalNode === nodeBTerminalNode) {
14
+ if (nodeATerminalNode) {
15
+ const terminalNodeA = nodeA, ///
16
+ terminalNodeB = nodeB, ///
17
+ terminalNodeMatches = this.matchTerminalNode(terminalNodeA, terminalNodeB);
18
+
19
+ nodeMatches = terminalNodeMatches; ///
20
+ } else {
21
+ const nonTerminalNodeA = nodeA, ///
22
+ nonTerminalNodeB = nodeB, ///
23
+ nonTerminalNodeMatches = this.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, depth);
24
+
25
+ nodeMatches = nonTerminalNodeMatches; ///
26
+ }
23
27
  }
24
28
  }
25
29
 
26
30
  return nodeMatches;
27
31
  }
28
32
 
29
- matchNodes(nodesA, nodesB, ...remainingArguments) {
33
+ matchNodes(nodesA, nodesB, substitutions, depth = Infinity) {
30
34
  let nodesMatch = false;
31
35
 
32
36
  const nodesALength = nodesA.length,
33
37
  nodesBLength = nodesB.length;
34
38
 
35
39
  if (nodesALength === nodesBLength) {
40
+ depth --;
41
+
36
42
  nodesMatch = nodesA.every((nodeA, index) => {
37
43
  const nodeB = nodesB[index],
38
- nodeMatches = this.matchNode(nodeA, nodeB, ...remainingArguments);
44
+ nodeMatches = this.matchNode(nodeA, nodeB, substitutions, depth);
39
45
 
40
46
  if (nodeMatches) {
41
47
  return true;
@@ -46,14 +52,14 @@ export default class Matcher {
46
52
  return nodesMatch;
47
53
  }
48
54
 
49
- matchTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments) {
55
+ matchTerminalNode(terminalNodeA, terminalNodeB, substitutions, depth) {
50
56
  const matches = terminalNodeA.match(terminalNodeB),
51
57
  terminalNodeMatches = matches; ///
52
58
 
53
59
  return terminalNodeMatches;
54
60
  }
55
61
 
56
- matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments) {
62
+ matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, depth = Infinity) {
57
63
  let nonTerminalNodeMatches = false;
58
64
 
59
65
  const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(), ///
@@ -64,7 +70,7 @@ export default class Matcher {
64
70
  nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
65
71
  nodesA = nonTerminalNodeAChildNodes, ///
66
72
  nodesB = nonTerminalNodeBChildNodes, ///
67
- nodesMatch = this.matchNodes(nodesA, nodesB, ...remainingArguments);
73
+ nodesMatch = this.matchNodes(nodesA, nodesB, substitutions, depth);
68
74
 
69
75
  nonTerminalNodeMatches = nodesMatch; ///
70
76
  }
@@ -1,12 +1,57 @@
1
1
  "use strict";
2
2
 
3
+ function getAxioms() { return this.context.getAxioms(); }
4
+
5
+ function getLemmas() { return this.context.getLemmas(); }
6
+
7
+ function getTheorems() { return this.context.getTheorems(); }
8
+
9
+ function getConjectures() { return this.context.getConjectures(); }
10
+
11
+ function getCombinators() { return this.context.getCombinators(); }
12
+
13
+ function getConstructors() { return this.context.getConstructors(); }
14
+
15
+ function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
16
+
17
+ function findLabelByTypeName(labelName) { return this.context.findLabelByTypeName(labelName); }
18
+
3
19
  function findRuleByReferenceName(referenceName) { return this.context.findRuleByReferenceName(referenceName); }
4
20
 
5
21
  function findAxiomByReferenceName(referenceName) { return this.context.findAxiomByReferenceName(referenceName); }
6
22
 
23
+ function findLemmaByReferenceName(referenceName) { return this.context.findLemmaByReferenceName(referenceName); }
24
+
25
+ function findTheoremByReferenceName(referenceName) { return this.context.findTheoremByReferenceName(referenceName); }
26
+
27
+ function findConjectureByReferenceName(referenceName) { return this.context.findConjectureByReferenceName(referenceName); }
28
+
29
+ function isLabelPresentByLabelName(labelName) { return this.context.isLabelPresentByLabelName(labelName); }
30
+
31
+ function isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
32
+
33
+ function nodeAsString(node) { return this.context.nodeAsString(node); }
34
+
35
+ function nodesAsString(node) { return this.context.nodesAsString(node); }
36
+
7
37
  const fileMixins = {
38
+ getAxioms,
39
+ getLemmas,
40
+ getTheorems,
41
+ getConjectures,
42
+ getCombinators,
43
+ getConstructors,
44
+ findTypeByTypeName,
45
+ findLabelByTypeName,
8
46
  findRuleByReferenceName,
9
- findAxiomByReferenceName
47
+ findAxiomByReferenceName,
48
+ findLemmaByReferenceName,
49
+ findTheoremByReferenceName,
50
+ findConjectureByReferenceName,
51
+ isLabelPresentByLabelName,
52
+ isTypePresentByTypeName,
53
+ nodeAsString,
54
+ nodesAsString
10
55
  };
11
56
 
12
57
  export default fileMixins;
package/src/premise.js CHANGED
@@ -34,12 +34,12 @@ export default class Premise {
34
34
  ...subproofSuppositionStatementNodes,
35
35
  subproofSubDerivationLastStatementNode
36
36
  ],
37
- ruleSubproofAssertionMetaSubproofStatementNodes = ruleSubproofAssertionMetaSubproofStatementNodesQuery(subproofAssertionNode),
37
+ ruleSubproofAssertionMetastatementNodes = ruleSubproofAssertionMetastatementNodesQuery(subproofAssertionNode),
38
38
  subproofStatementNodesLength = subproofStatementNodes.length,
39
- ruleSubproofAssertionMetaSubproofStatementNodesLength = ruleSubproofAssertionMetaSubproofStatementNodes.length;
39
+ ruleSubproofAssertionMetastatementNodesLength = ruleSubproofAssertionMetastatementNodes.length;
40
40
 
41
- if (subproofStatementNodesLength === ruleSubproofAssertionMetaSubproofStatementNodesLength) {
42
- subproofNodeMatches = ruleSubproofAssertionMetaSubproofStatementNodes.every((ruleSubproofAssertionMetastatementNode, index) => {
41
+ if (subproofStatementNodesLength === ruleSubproofAssertionMetastatementNodesLength) {
42
+ subproofNodeMatches = ruleSubproofAssertionMetastatementNodes.every((ruleSubproofAssertionMetastatementNode, index) => {
43
43
  const subproofStatementNode = subproofStatementNodes[index],
44
44
  nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
45
45
  nonTerminalNodeB = subproofStatementNode, ///
@@ -106,8 +106,8 @@ export default class Premise {
106
106
  return metastatementNodeMatches;
107
107
  }
108
108
 
109
- toJSON() {
110
- const metastatementString = nodeAsString(this.metastatementNode),
109
+ toJSON(tokens) {
110
+ const metastatementString = nodeAsString(this.metastatementNode, tokens),
111
111
  metastatement = metastatementString, ///
112
112
  json = {
113
113
  metastatement
package/src/rule.js CHANGED
@@ -108,18 +108,18 @@ export default class Rule {
108
108
  return metastatementNatches;
109
109
  }
110
110
 
111
- toJSON() {
111
+ toJSON(tokens) {
112
112
  const labelsJSON = this.labels.map((label) => {
113
- const labelJSON = label.toJSON();
113
+ const labelJSON = label.toJSON(tokens);
114
114
 
115
115
  return labelJSON;
116
116
  }),
117
117
  premisesJSON = this.premises.map((premise) => {
118
- const premiseJSON = premise.toJSON();
118
+ const premiseJSON = premise.toJSON(tokens);
119
119
 
120
120
  return premiseJSON;
121
121
  }),
122
- conclusionJSON = this.conclusion.toJSON(),
122
+ conclusionJSON = this.conclusion.toJSON(tokens),
123
123
  kind = RULE_KIND,
124
124
  labels = labelsJSON, ///
125
125
  premises = premisesJSON, ///
package/src/ruleNames.js CHANGED
@@ -5,9 +5,7 @@ export const TYPE_RULE_NAME = "type";
5
5
  export const LABEL_RULE_NAME = "label";
6
6
  export const ARGUMENT_RULE_NAME = "argument";
7
7
  export const SUBPROOF_RULE_NAME = "subproof";
8
- export const VARIABLE_RULE_NAME = "variable";
9
8
  export const STATEMENT_RULE_NAME = "statement";
10
- export const METAVARIABLE_RULE_NAME = "metavariable";
11
9
  export const METASTATEMENT_RULE_NAME = "metastatement";
12
10
  export const RULE_SUBPROOF_RULE_NAME = "ruleSubproof";
13
11
  export const META_ARGUMENT_RULE_NAME = "metaArgument";
package/src/step/proof.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import { matchBracketedNonTerminalNode } from "../utilities/substitution";
4
+
3
5
  export default class ProofStep {
4
6
  constructor(subproofNode, statementNode) {
5
7
  this.subproofNode = subproofNode;
@@ -14,6 +16,31 @@ export default class ProofStep {
14
16
  return this.statementNode;
15
17
  }
16
18
 
19
+ matchStatement(statementNode) {
20
+ let statementMatches;
21
+
22
+ const statementsMatch = this.matchStatements(statementNode);
23
+
24
+ statementMatches = statementsMatch; //
25
+
26
+ return statementMatches;
27
+ }
28
+
29
+ matchStatements(statementNode) {
30
+ let statementsMatch = false;
31
+
32
+ if (this.statementNode !== null) {
33
+ const nonTerminalNodeA = statementNode, ///
34
+ nonTerminalNodeB = this.statementNode, ///
35
+ bracketedNodeMatches = matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB),
36
+ statementNodeMatches = bracketedNodeMatches; ///
37
+
38
+ return statementNodeMatches;
39
+ }
40
+
41
+ return statementsMatch;
42
+ }
43
+
17
44
  static fromSubproofNode(subproofNode) {
18
45
  const statementNode = null,
19
46
  metaProofStep = new ProofStep(subproofNode, statementNode);
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  import { matcher } from "../matcher";
4
- import { STATEMENT_RULE_NAME } from "../ruleNames";
4
+ import { nodeQuery } from "../utilities/query";
5
+ import { META_ARGUMENT_RULE_NAME } from "../ruleNames";
5
6
  import { bracketedNonTerminalChildNodeFromChildNodes } from "../utilities/substitution";
6
7
 
8
+ const statementNodeQuery = nodeQuery('/metaArgument/statement!');
9
+
7
10
  export default class StatementForMetavariableSubstitution {
8
11
  constructor(metavariableName, statementNode) {
9
12
  this.metavariableName = metavariableName;
@@ -30,16 +33,19 @@ export default class StatementForMetavariableSubstitution {
30
33
  if (!matchesStatementNode) {
31
34
  const nonTerminalNode = statementNode, ///
32
35
  childNodes = nonTerminalNode.getChildNodes(), ///
33
- ruleName = STATEMENT_RULE_NAME;
36
+ ruleName = META_ARGUMENT_RULE_NAME,
37
+ metaArgumentNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
34
38
 
35
- statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
39
+ if (metaArgumentNode !== null) {
40
+ const statementNode = statementNodeQuery(metaArgumentNode);
36
41
 
37
- if (statementNode !== null) {
38
- const nodeA = this.statementNode, ///
39
- nodeB = statementNode,
40
- nodeMatches = matchNode(nodeA, nodeB);
42
+ if (statementNode !== null) {
43
+ const nodeA = this.statementNode, ///
44
+ nodeB = statementNode,
45
+ nodeMatches = matcher.matchNode(nodeA, nodeB);
41
46
 
42
- matchesStatementNode = nodeMatches; ///
47
+ matchesStatementNode = nodeMatches; ///
48
+ }
43
49
  }
44
50
  }
45
51
 
@@ -51,9 +57,10 @@ export default class StatementForMetavariableSubstitution {
51
57
 
52
58
  const nonTerminalNode = statementNode, ///
53
59
  childNodes = nonTerminalNode.getChildNodes(),
54
- ruleName = STATEMENT_RULE_NAME;
60
+ ruleName = META_ARGUMENT_RULE_NAME,
61
+ metaArgumentNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
55
62
 
56
- statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
63
+ statementNode = statementNodeQuery(metaArgumentNode);
57
64
 
58
65
  if (statementNode !== null) {
59
66
  statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(metavariableName, statementNode);
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ import { matcher } from "../matcher";
4
+ import { STATEMENT_RULE_NAME } from "../ruleNames";
5
+ import { bracketedNonTerminalChildNodeFromChildNodes } from "../utilities/substitution";
6
+
7
+ export default class TermForVariableSubstitution {
8
+ constructor(variableName, termNode) {
9
+ this.variableName = variableName;
10
+ this.termNode = termNode;
11
+ }
12
+
13
+ getVariableName() {
14
+ return this.variableName;
15
+ }
16
+
17
+ getTermNode() {
18
+ return this.termNode;
19
+ }
20
+
21
+ matchTermNode(termNode) {
22
+ let matchesTermNode;
23
+
24
+ const nodeA = this.termNode, ///
25
+ nodeB = termNode,
26
+ nodeMatches = matcher.matchNode(nodeA, nodeB);
27
+
28
+ matchesTermNode = nodeMatches; ///
29
+
30
+ if (!matchesTermNode) {
31
+ const nonTerminalNode = termNode, ///
32
+ childNodes = nonTerminalNode.getChildNodes(), ///
33
+ ruleName = STATEMENT_RULE_NAME;
34
+
35
+ termNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
36
+
37
+ if (termNode !== null) {
38
+ const nodeA = this.termNode, ///
39
+ nodeB = termNode,
40
+ nodeMatches = matcher.matchNode(nodeA, nodeB);
41
+
42
+ matchesTermNode = nodeMatches; ///
43
+ }
44
+ }
45
+
46
+ return matchesTermNode;
47
+ }
48
+
49
+ static fromVariableNameAndTermNode(variableName, termNode) {
50
+ let termForVariableSubstitution = new TermForVariableSubstitution(variableName, termNode);
51
+
52
+ const nonTerminalNode = termNode, ///
53
+ childNodes = nonTerminalNode.getChildNodes(),
54
+ ruleName = STATEMENT_RULE_NAME;
55
+
56
+ termNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
57
+
58
+ if (termNode !== null) {
59
+ termForVariableSubstitution = new TermForVariableSubstitution(variableName, termNode);
60
+ }
61
+
62
+ return termForVariableSubstitution;
63
+ }
64
+ }
@@ -3,7 +3,7 @@
3
3
  import { nodeAsString } from "./utilities/string";
4
4
  import { nodeQuery, nodesQuery } from "./utilities/query";
5
5
  import { statementNodeFromStatementString } from "./utilities/string";
6
- import { suppositionStatementForVariableMatcher } from "./matcher/statementForVariable/supposition";
6
+ import { suppositionTermForVariableMatcher } from "./matcher/termForVariable/supposition";
7
7
 
8
8
  const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
9
9
  subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
@@ -40,7 +40,7 @@ export default class Supposition {
40
40
  const subproofStatementNode = subproofStatementNodes[index],
41
41
  nonTerminalNodeA = subproofAssertionStatementNode, ///
42
42
  nonTerminalNodeB = subproofStatementNode, ///
43
- nonTerminalNodeMatches = suppositionStatementForVariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
43
+ nonTerminalNodeMatches = suppositionTermForVariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
44
44
 
45
45
  if (nonTerminalNodeMatches) {
46
46
  return true;
@@ -55,14 +55,14 @@ export default class Supposition {
55
55
  matchStatementNode(statementNode, substitutions) {
56
56
  const nonTerminalNodeA = this.statementNode, ///
57
57
  nonTerminalNodeB = statementNode, ///
58
- nonTerminalNodeMatches = suppositionStatementForVariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
58
+ nonTerminalNodeMatches = suppositionTermForVariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
59
59
  statementNodeMatches = nonTerminalNodeMatches; ///
60
60
 
61
61
  return statementNodeMatches;
62
62
  }
63
63
 
64
- toJSON() {
65
- const statementString = nodeAsString(this.statementNode),
64
+ toJSON(tokens) {
65
+ const statementString = nodeAsString(this.statementNode, tokens),
66
66
  statement = statementString, ///
67
67
  json = {
68
68
  statement
package/src/theorem.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- import AxiomLemmaTheorem from "./axiomLemmaTheorem";
3
+ import AxiomLemmaTheoremConjecture from "./axiomLemmaTheoremConjecture";
4
4
 
5
5
  import { THEOREM_KIND } from "./kinds";
6
6
 
7
- export default class Theorem extends AxiomLemmaTheorem {
7
+ export default class Theorem extends AxiomLemmaTheoremConjecture {
8
8
  static kind = THEOREM_KIND;
9
9
 
10
- static fromJSON(json, releaseContext) { return AxiomLemmaTheorem.fromJSON(Theorem, json, releaseContext); }
10
+ static fromJSON(json, releaseContext) { return AxiomLemmaTheoremConjecture.fromJSON(Theorem, json, releaseContext); }
11
11
 
12
- static fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence) { return AxiomLemmaTheorem.fromLabelsSuppositionsAndConsequence(Theorem, labels, suppositions, consequence); }
12
+ static fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsAndConsequence(Theorem, labels, suppositions, consequence); }
13
13
  }
package/src/type.js CHANGED
@@ -96,7 +96,7 @@ export default class Type {
96
96
  return matchesTypeName;
97
97
  }
98
98
 
99
- asString(noSuperType) {
99
+ asString(tokens, noSuperType) {
100
100
  let string;
101
101
 
102
102
  if (noSuperType) {
@@ -110,8 +110,8 @@ export default class Type {
110
110
  return string;
111
111
  }
112
112
 
113
- toJSON() {
114
- const superTypeJSON = this.superType.toJSON(),
113
+ toJSON(tokens) {
114
+ const superTypeJSON = this.superType.toJSON(tokens),
115
115
  kind = TYPE_KIND,
116
116
  name = this.name,
117
117
  superType = superTypeJSON, ///
@@ -157,7 +157,7 @@ export default class Type {
157
157
  }
158
158
 
159
159
  class ObjectType extends Type {
160
- toJSON() {
160
+ toJSON(tokens) {
161
161
  const kind = TYPE_KIND,
162
162
  name = this.name,
163
163
  superType = null, ///
@@ -182,11 +182,21 @@ class ObjectType extends Type {
182
182
  export const objectType = ObjectType.fromNothing();
183
183
 
184
184
  function superTypeFromSuperTypeJSON(superTypeJSON, releaseContext) {
185
+ let superType;
186
+
185
187
  const json = superTypeJSON, ///
186
- { name } = json,
187
- superType = (name === OBJECT_TYPE_NAME) ?
188
- objectType :
189
- Type.fromJSON(json, releaseContext);
188
+ { name } = json;
189
+
190
+ if (name === OBJECT_TYPE_NAME) {
191
+ superType = objectType; ///
192
+ } else {
193
+ const typeName = name, ///
194
+ type = releaseContext.findTypeByTypeName(typeName);
195
+
196
+ superType = (type !== null) ?
197
+ type : ///
198
+ Type.fromJSON(json, releaseContext); ///
199
+ }
190
200
 
191
201
  return superType;
192
202
  }
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
2
 
3
- import { COMMA } from "../constants";
4
3
  import { nodeQuery } from "../utilities/query";
5
- import { LABEL_RULE_NAME,
6
- UNQUALIFIED_STATEMENT_RULE_NAME,
7
- CONSTRUCTOR_DECLARATIONRULE_NAME,
8
- UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
4
+ import { COMMA, EMPTY_STRING } from "../constants";
5
+ import { LABEL_RULE_NAME, UNQUALIFIED_STATEMENT_RULE_NAME, CONSTRUCTOR_DECLARATIONRULE_NAME, UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
9
6
 
10
7
  const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
11
8
  statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
12
9
  metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
13
10
 
14
- export function nodeAsString(node) {
11
+ export function nodeAsString(node, tokens) {
15
12
  let string = null;
16
13
 
17
14
  if (node !== null) {
@@ -24,33 +21,42 @@ export function nodeAsString(node) {
24
21
  string = content; ///
25
22
  } else {
26
23
  const nonTerminalNode = node, ///
27
- childNodes = nonTerminalNode.getChildNodes();
24
+ firstSignificantToken = nonTerminalNode.getFirstSignificantToken(),
25
+ lastSignificantToken = nonTerminalNode.getLastSignificantToken(),
26
+ firstSignificantTokenIndex = tokens.indexOf(firstSignificantToken),
27
+ lastSignificantTokenIndex = tokens.indexOf(lastSignificantToken),
28
+ start = firstSignificantTokenIndex, ///
29
+ end = lastSignificantTokenIndex + 1;
28
30
 
29
- childNodes.forEach((childNode) => {
30
- const nodeString = nodeAsString(childNode);
31
+ tokens = tokens.slice(start, end); ///
31
32
 
32
- string = (string === null) ?
33
- nodeString : ///
34
- `${string}${nodeString}`;
35
- });
33
+ string = tokens.reduce((string, token) => {
34
+ const content = token.getContent();
35
+
36
+ string = `${string}${content}`;
37
+
38
+ return string;
39
+ }, EMPTY_STRING);
36
40
  }
37
41
  }
38
42
 
43
+ if (string !== null) {
44
+ string = string.replace(/[\r\n]/, EMPTY_STRING)
45
+ }
46
+
39
47
  return string;
40
48
  }
41
49
 
42
- export function nodesAsString(nodes) {
50
+ export function nodesAsString(nodes, tokens) {
43
51
  const string = nodes.reduce((string, node) => {
44
- const nodeString = nodeAsString(node);
52
+ const nodeString = nodeAsString(node, tokens);
45
53
 
46
- if (string === null) {
47
- string = nodeString; ///
48
- } else {
49
- string = `${string}${COMMA}${nodeString}`;
50
- }
54
+ string = (string === EMPTY_STRING) ?
55
+ nodeString :
56
+ `${string}${COMMA}${nodeString}`;
51
57
 
52
58
  return string;
53
- }, null);
59
+ }, EMPTY_STRING);
54
60
 
55
61
  return string;
56
62
  }
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ "use strict";
2
2
 
3
3
  import { matcher } from "../matcher";
4
4
  import { first, second, third } from "../utilities/array";
@@ -17,7 +17,8 @@ export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB
17
17
  if (!bracketedNodeMatches) {
18
18
  const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
19
19
  childNodesA = nonTerminalNodeAChildNodes, ///
20
- bracketedNonTerminalChildNodeA = bracketedNonTerminalChildNodeFromChildNodes(childNodesA);
20
+ ruleName = METASTATEMENT_RULE_NAME,
21
+ bracketedNonTerminalChildNodeA = bracketedNonTerminalChildNodeFromChildNodes(childNodesA, ruleName);
21
22
 
22
23
  if (bracketedNonTerminalChildNodeA !== null) {
23
24
  const nodeA = bracketedNonTerminalChildNodeA, ///
@@ -31,7 +32,8 @@ export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB
31
32
  if (!bracketedNodeMatches) {
32
33
  const nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
33
34
  childNodesB = nonTerminalNodeBChildNodes, ///
34
- bracketedNonTerminalChildNodeB = bracketedNonTerminalChildNodeFromChildNodes(childNodesB);
35
+ ruleName = METASTATEMENT_RULE_NAME,
36
+ bracketedNonTerminalChildNodeB = bracketedNonTerminalChildNodeFromChildNodes(childNodesB, ruleName);
35
37
 
36
38
  if (bracketedNonTerminalChildNodeB !== null) {
37
39
  const nodeB = bracketedNonTerminalChildNodeB, ///
@@ -45,7 +47,7 @@ export function matchBracketedNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB
45
47
  return bracketedNodeMatches;
46
48
  }
47
49
 
48
- export function bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName = METASTATEMENT_RULE_NAME) {
50
+ export function bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName) {
49
51
  let bracketedNonTerminalChildNode = null;
50
52
 
51
53
  const childNodesLength = childNodes.length;
package/src/variable.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  export default class Variable {
4
- constructor(type, name, termNode) {
4
+ constructor(type, name) {
5
5
  this.type = type;
6
6
  this.name = name;
7
- this.termNode = termNode;
8
7
  }
9
8
 
10
9
  getType() {
@@ -15,53 +14,21 @@ export default class Variable {
15
14
  return this.name;
16
15
  }
17
16
 
18
- getTermNode() {
19
- return this.termNode;
20
- }
21
-
22
- setTermNode(termNode) {
23
- this.termNode = termNode;
24
- }
25
-
26
17
  matchName(name) {
27
18
  const matchesName = (this.name === name);
28
19
 
29
20
  return matchesName;
30
21
  }
31
22
 
32
- isEqualTo(variable) {
33
- let equalTo = false;
34
-
35
- if (variable === this) {
36
- equalTo = true;
37
- } else {
38
- const termNode = variable.getTermNode();
39
-
40
- if (termNode === this.termNode) {
41
- equalTo = true;
42
- }
43
- }
44
-
45
- return equalTo;
46
- }
47
-
48
- asString() {
49
- let string;
50
-
51
- if (this.type === null) {
52
- string = this.name;
53
- } else {
54
- const typeName = this.type.getName();
55
-
56
- string = `${this.name}:${typeName}`;
57
- }
23
+ asString(tokens) {
24
+ const typeName = this.type.getName(),
25
+ string = `${this.name}:${typeName}`;
58
26
 
59
27
  return string;
60
28
  }
61
29
 
62
30
  static fromTypeAndName(type, name) {
63
- const termNode = null,
64
- variable = new Variable(type, name, termNode);
31
+ const variable = new Variable(type, name);
65
32
 
66
33
  return variable;
67
34
  }