occam-verify-cli 0.0.526 → 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 (106) 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/conjecture.js +141 -0
  5. package/lib/consequence.js +3 -3
  6. package/lib/constants.js +4 -16
  7. package/lib/context/file.js +76 -39
  8. package/lib/context/metaproof.js +40 -10
  9. package/lib/context/proof.js +38 -105
  10. package/lib/context/release/directory.js +20 -1
  11. package/lib/context/release/file.js +27 -3
  12. package/lib/equality.js +78 -51
  13. package/lib/index.js +1 -13
  14. package/lib/kinds.js +5 -1
  15. package/lib/lemma.js +7 -7
  16. package/lib/matcher/metastatementForMetavariable.js +16 -19
  17. package/lib/matcher/statementForMetavariable.js +22 -20
  18. package/lib/matcher/{statementForVariable → termForVariable}/consequence.js +13 -13
  19. package/lib/matcher/{statementForVariable → termForVariable}/supposition.js +13 -13
  20. package/lib/matcher/termForVariable.js +198 -0
  21. package/lib/matcher.js +23 -64
  22. package/lib/mixins/file.js +62 -2
  23. package/lib/premise.js +4 -4
  24. package/lib/ruleNames.js +1 -9
  25. package/lib/step/proof.js +22 -1
  26. package/lib/substitution/statementForMetavariable.js +12 -8
  27. package/lib/substitution/termForVariable.js +86 -0
  28. package/lib/supposition.js +4 -4
  29. package/lib/theorem.js +7 -7
  30. package/lib/type.js +9 -2
  31. package/lib/utilities/string.js +3 -7
  32. package/lib/utilities/substitution.js +4 -5
  33. package/lib/variable.js +4 -38
  34. package/lib/verify/assertion/type.js +59 -36
  35. package/lib/verify/axiom.js +1 -2
  36. package/lib/verify/conjecture.js +56 -0
  37. package/lib/verify/declaration/topLevel.js +7 -3
  38. package/lib/verify/lemma.js +1 -2
  39. package/lib/verify/metastatement/qualified.js +1 -2
  40. package/lib/verify/metastatement/unqualified.js +1 -2
  41. package/lib/verify/rule.js +1 -2
  42. package/lib/verify/statement/qualified.js +39 -10
  43. package/lib/verify/statement/unqualified.js +1 -2
  44. package/lib/verify/statement.js +44 -47
  45. package/lib/verify/theorem.js +1 -2
  46. package/package.json +1 -1
  47. package/src/assertion/type.js +7 -32
  48. package/src/axiom.js +4 -4
  49. package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +5 -5
  50. package/src/conjecture.js +13 -0
  51. package/src/consequence.js +2 -2
  52. package/src/constants.js +1 -4
  53. package/src/context/file.js +81 -37
  54. package/src/context/metaproof.js +42 -5
  55. package/src/context/proof.js +42 -41
  56. package/src/context/release/directory.js +24 -0
  57. package/src/context/release/file.js +34 -3
  58. package/src/equality.js +110 -61
  59. package/src/index.js +0 -3
  60. package/src/kinds.js +1 -0
  61. package/src/lemma.js +4 -4
  62. package/src/matcher/metastatementForMetavariable.js +22 -32
  63. package/src/matcher/statementForMetavariable.js +40 -34
  64. package/src/matcher/termForVariable/consequence.js +9 -0
  65. package/src/matcher/termForVariable/supposition.js +9 -0
  66. package/src/matcher/termForVariable.js +89 -0
  67. package/src/matcher.js +28 -22
  68. package/src/mixins/file.js +46 -1
  69. package/src/premise.js +4 -4
  70. package/src/ruleNames.js +0 -2
  71. package/src/step/proof.js +27 -0
  72. package/src/substitution/statementForMetavariable.js +17 -10
  73. package/src/substitution/termForVariable.js +64 -0
  74. package/src/supposition.js +3 -3
  75. package/src/theorem.js +4 -4
  76. package/src/type.js +14 -4
  77. package/src/utilities/string.js +4 -6
  78. package/src/utilities/substitution.js +6 -4
  79. package/src/variable.js +4 -37
  80. package/src/verify/assertion/type.js +70 -64
  81. package/src/verify/axiom.js +0 -1
  82. package/src/verify/conjecture.js +73 -0
  83. package/src/verify/declaration/topLevel.js +7 -0
  84. package/src/verify/lemma.js +0 -1
  85. package/src/verify/metastatement/qualified.js +0 -1
  86. package/src/verify/metastatement/unqualified.js +0 -1
  87. package/src/verify/rule.js +0 -1
  88. package/src/verify/statement/qualified.js +53 -13
  89. package/src/verify/statement/unqualified.js +0 -1
  90. package/src/verify/statement.js +46 -66
  91. package/src/verify/theorem.js +0 -1
  92. package/lib/axiomLemmaTheorem.js +0 -190
  93. package/lib/jsonTypes.js +0 -30
  94. package/lib/matcher/statementForVariable.js +0 -201
  95. package/lib/substitution/statementForVariable.js +0 -86
  96. package/lib/utilities/json.js +0 -187
  97. package/lib/utilities/version.js +0 -32
  98. package/lib/versionChanges.js +0 -34
  99. package/src/jsonTypes.js +0 -6
  100. package/src/matcher/statementForVariable/consequence.js +0 -9
  101. package/src/matcher/statementForVariable/supposition.js +0 -9
  102. package/src/matcher/statementForVariable.js +0 -99
  103. package/src/substitution/statementForVariable.js +0 -64
  104. package/src/utilities/json.js +0 -264
  105. package/src/utilities/version.js +0 -30
  106. package/src/versionChanges.js +0 -11
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ import Matcher from "../matcher";
4
+ import TermForVariableSubstitution from "../substitution/termForVariable";
5
+
6
+ import { nodeQuery } from "../utilities/query";
7
+ import { TERM_RULE_NAME } from "../ruleNames";
8
+ import { variableNameFromVariableNode } from "../utilities/query";
9
+
10
+ const variableNodeQuery = nodeQuery('/term/variable!');
11
+
12
+ export default class TermForVariableMatcher extends Matcher {
13
+ matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
14
+ let nonTerminalNodeMatches = false;
15
+
16
+ const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
17
+ nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName();
18
+
19
+ if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
20
+ const nonTerminalNodeARuleNameTermRuleName = (nonTerminalNodeARuleName === TERM_RULE_NAME),
21
+ nonTerminalNodeBRuleNameTermRuleName = (nonTerminalNodeBRuleName === TERM_RULE_NAME);
22
+
23
+ if (nonTerminalNodeARuleNameTermRuleName && nonTerminalNodeBRuleNameTermRuleName) {
24
+ const termNodeA = nonTerminalNodeA, ///
25
+ termNodeB = nonTerminalNodeB, ///
26
+ termNodeMatches = this.matchTermNode(termNodeA, termNodeB, substitutions);
27
+
28
+ if (termNodeMatches) {
29
+ nonTerminalNodeMatches = true; ///
30
+ } else {
31
+ nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
32
+ }
33
+ } else {
34
+ nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
35
+ }
36
+ }
37
+
38
+ return nonTerminalNodeMatches;
39
+ }
40
+
41
+ matchTermNode(termNodeA, termNodeB, substitutions) {
42
+ let termNodeMatches = false;
43
+
44
+ const variableNodeA = variableNodeQuery(termNodeA);
45
+
46
+ if (variableNodeA !== null) {
47
+ const variableMatches = this.matchVariableNode(variableNodeA, termNodeB, substitutions);
48
+
49
+ termNodeMatches = variableMatches; ///
50
+ }
51
+
52
+ return termNodeMatches;
53
+ }
54
+
55
+ matchVariableNode(variableNodeB, termNodeB, substitutions) {
56
+ let variableMatches;
57
+
58
+ const variableNameA = variableNameFromVariableNode(variableNodeB),
59
+ substitution = substitutions.find((substitution) => {
60
+ const variableName = substitution.getVariableName();
61
+
62
+ if (variableName === variableNameA) {
63
+ return true;
64
+ }
65
+ }) || null;
66
+
67
+ if (substitution !== null) {
68
+ const termNode = termNodeB, ///
69
+ substitutionNodesMatch = substitution.matchTermNode(termNode);
70
+
71
+ variableMatches = substitutionNodesMatch; ///
72
+ } else {
73
+ const { createSubstitutions } = this.constructor;
74
+
75
+ if (createSubstitutions) {
76
+ const variableName = variableNameA, ///
77
+ termNode = termNodeB, ///
78
+ termForVariableSubstitution = TermForVariableSubstitution.fromVariableNameAndTermNode(variableName, termNode),
79
+ substitution = termForVariableSubstitution; ///
80
+
81
+ substitutions.push(substitution);
82
+ }
83
+
84
+ variableMatches = true;
85
+ }
86
+
87
+ return variableMatches;
88
+ }
89
+ }
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, ///
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,7 +55,7 @@ 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;
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
@@ -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
  }
@@ -51,14 +51,12 @@ export function nodesAsString(nodes, tokens) {
51
51
  const string = nodes.reduce((string, node) => {
52
52
  const nodeString = nodeAsString(node, tokens);
53
53
 
54
- if (string === null) {
55
- string = nodeString; ///
56
- } else {
57
- string = `${string}${COMMA}${nodeString}`;
58
- }
54
+ string = (string === EMPTY_STRING) ?
55
+ nodeString :
56
+ `${string}${COMMA}${nodeString}`;
59
57
 
60
58
  return string;
61
- }, null);
59
+ }, EMPTY_STRING);
62
60
 
63
61
  return string;
64
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
23
  asString(tokens) {
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
- }
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
  }