occam-verify-cli 0.0.538 → 0.0.540

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 (91) hide show
  1. package/bin/action/verify.js +7 -24
  2. package/bin/actions.js +20 -6
  3. package/lib/axiom.js +7 -7
  4. package/lib/axiomLemmaTheoremConjecture.js +33 -30
  5. package/lib/combinator.js +4 -4
  6. package/lib/conclusion.js +8 -8
  7. package/lib/conjecture.js +7 -7
  8. package/lib/consequence.js +3 -3
  9. package/lib/constructor.js +6 -6
  10. package/lib/context/file.js +215 -45
  11. package/lib/context/metaproof.js +3 -3
  12. package/lib/context/release.js +215 -2
  13. package/lib/kinds.js +13 -1
  14. package/lib/label.js +4 -4
  15. package/lib/lemma.js +7 -7
  16. package/lib/metaType.js +201 -0
  17. package/lib/metavariable.js +81 -0
  18. package/lib/premise.js +12 -12
  19. package/lib/rule.js +42 -35
  20. package/lib/ruleNames.js +16 -4
  21. package/lib/supposition.js +8 -8
  22. package/lib/theorem.js +7 -7
  23. package/lib/type.js +7 -7
  24. package/lib/utilities/node.js +17 -3
  25. package/lib/utilities/query.js +13 -2
  26. package/lib/variable.js +18 -12
  27. package/lib/verifier/metastatementForMetavariable.js +8 -8
  28. package/lib/verifier/statementForMetavariable.js +9 -9
  29. package/lib/verifier/termForVariable.js +22 -11
  30. package/lib/verifier.js +1 -1
  31. package/lib/verify/assertion/type.js +2 -2
  32. package/lib/verify/axiom.js +2 -2
  33. package/lib/verify/conjecture.js +2 -2
  34. package/lib/verify/declaration/metavariable.js +26 -0
  35. package/lib/verify/declaration/topLevel.js +7 -3
  36. package/lib/verify/lemma.js +2 -2
  37. package/lib/verify/metastatement/qualified.js +3 -3
  38. package/lib/verify/metastatement.js +147 -3
  39. package/lib/verify/metavariable.js +34 -0
  40. package/lib/verify/rule.js +2 -2
  41. package/lib/verify/statement/qualified.js +7 -7
  42. package/lib/verify/statement.js +6 -6
  43. package/lib/verify/theorem.js +2 -2
  44. package/lib/verify/variable.js +4 -4
  45. package/package.json +3 -3
  46. package/src/axiom.js +2 -2
  47. package/src/axiomLemmaTheoremConjecture.js +31 -32
  48. package/src/combinator.js +3 -3
  49. package/src/conclusion.js +11 -7
  50. package/src/conjecture.js +2 -2
  51. package/src/consequence.js +2 -2
  52. package/src/constructor.js +5 -5
  53. package/src/context/file.js +248 -45
  54. package/src/context/metaproof.js +1 -1
  55. package/src/context/release.js +254 -2
  56. package/src/kinds.js +3 -0
  57. package/src/label.js +3 -3
  58. package/src/lemma.js +2 -2
  59. package/src/metaType.js +81 -0
  60. package/src/metavariable.js +39 -0
  61. package/src/premise.js +19 -11
  62. package/src/rule.js +37 -32
  63. package/src/ruleNames.js +4 -1
  64. package/src/supposition.js +11 -7
  65. package/src/theorem.js +2 -2
  66. package/src/type.js +5 -5
  67. package/src/utilities/node.js +32 -2
  68. package/src/utilities/query.js +14 -0
  69. package/src/variable.js +12 -8
  70. package/src/verifier/metastatementForMetavariable.js +7 -7
  71. package/src/verifier/statementForMetavariable.js +8 -8
  72. package/src/verifier/termForVariable.js +33 -13
  73. package/src/verifier.js +1 -1
  74. package/src/verify/assertion/type.js +3 -3
  75. package/src/verify/axiom.js +1 -1
  76. package/src/verify/conjecture.js +2 -1
  77. package/src/verify/declaration/metavariable.js +20 -0
  78. package/src/verify/declaration/topLevel.js +9 -2
  79. package/src/verify/lemma.js +1 -1
  80. package/src/verify/metastatement/qualified.js +3 -2
  81. package/src/verify/metastatement.js +65 -2
  82. package/src/verify/metavariable.js +32 -0
  83. package/src/verify/rule.js +1 -1
  84. package/src/verify/statement/qualified.js +7 -6
  85. package/src/verify/statement.js +14 -14
  86. package/src/verify/theorem.js +2 -1
  87. package/src/verify/variable.js +4 -4
  88. package/lib/context/release/directory.js +0 -313
  89. package/lib/context/release/file.js +0 -387
  90. package/src/context/release/directory.js +0 -251
  91. package/src/context/release/file.js +0 -312
@@ -3,14 +3,16 @@
3
3
  import Verifier from "../verifier";
4
4
  import TermForVariableSubstitution from "../substitution/termForVariable";
5
5
 
6
+ import { first } from "../utilities/array";
6
7
  import { nodeQuery } from "../utilities/query";
7
8
  import { TERM_RULE_NAME } from "../ruleNames";
8
9
  import { variableNameFromVariableNode } from "../utilities/query";
10
+ import { verifyTermAgainstConstructors } from "../verify/term";
9
11
 
10
12
  const variableNodeQuery = nodeQuery('/term/variable!');
11
13
 
12
14
  export default class TermForVariableVerifier extends Verifier {
13
- verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
15
+ verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB) {
14
16
  let nonTerminalNodeVerified = false;
15
17
 
16
18
  const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
@@ -23,28 +25,28 @@ export default class TermForVariableVerifier extends Verifier {
23
25
  if (nonTerminalNodeARuleNameTermRuleName && nonTerminalNodeBRuleNameTermRuleName) {
24
26
  const termNodeA = nonTerminalNodeA, ///
25
27
  termNodeB = nonTerminalNodeB, ///
26
- termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions);
28
+ termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions, proofContextA, proofContextB);
27
29
 
28
30
  if (termNodeVerified) {
29
31
  nonTerminalNodeVerified = true; ///
30
32
  } else {
31
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
33
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB);
32
34
  }
33
35
  } else {
34
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
36
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB);
35
37
  }
36
38
  }
37
39
 
38
40
  return nonTerminalNodeVerified;
39
41
  }
40
42
 
41
- verifyTermNode(termNodeA, termNodeB, substitutions) {
43
+ verifyTermNode(termNodeA, termNodeB, substitutions, proofContextA, proofContextB) {
42
44
  let termNodeVerified = false;
43
45
 
44
46
  const variableNodeA = variableNodeQuery(termNodeA);
45
47
 
46
48
  if (variableNodeA !== null) {
47
- const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions);
49
+ const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions, proofContextA, proofContextB);
48
50
 
49
51
  termNodeVerified = variableVerified; ///
50
52
  }
@@ -52,7 +54,7 @@ export default class TermForVariableVerifier extends Verifier {
52
54
  return termNodeVerified;
53
55
  }
54
56
 
55
- verifyVariableNode(variableNodeB, termNodeB, substitutions) {
57
+ verifyVariableNode(variableNodeB, termNodeB, substitutions, proofContextA, proofContextB) {
56
58
  let variableVerified;
57
59
 
58
60
  const variableNameA = variableNameFromVariableNode(variableNodeB),
@@ -74,14 +76,32 @@ export default class TermForVariableVerifier extends Verifier {
74
76
 
75
77
  if (createSubstitutions) {
76
78
  const variableName = variableNameA, ///
77
- termNode = termNodeB, ///
78
- termForVariableSubstitution = TermForVariableSubstitution.fromVariableNameAndTermNode(variableName, termNode),
79
- substitution = termForVariableSubstitution; ///
79
+ proofContext = proofContextA, ///
80
+ variable = proofContext.findVariableByVariableName(variableName);
80
81
 
81
- substitutions.push(substitution);
82
- }
82
+ if (variable !== null) {
83
+ const types = [],
84
+ context = proofContextB, ///
85
+ termNode = termNodeB, ///
86
+ termVerified = verifyTermAgainstConstructors(termNodeB, types, context);
87
+
88
+ if (termVerified) {
89
+ const firstType = first(types),
90
+ termType = firstType,
91
+ variableType = variable.getType(),
92
+ variableTypeEqualToOrSuperTypeOfTermType = variableType.isEqualToOrSuperTypeOf(termType);
93
+
94
+ if (variableTypeEqualToOrSuperTypeOfTermType) {
95
+ const termForVariableSubstitution = TermForVariableSubstitution.fromVariableNameAndTermNode(variableName, termNode),
96
+ substitution = termForVariableSubstitution; ///
97
+
98
+ substitutions.push(substitution);
83
99
 
84
- variableVerified = true;
100
+ variableVerified = true;
101
+ }
102
+ }
103
+ }
104
+ }
85
105
  }
86
106
 
87
107
  return variableVerified;
package/src/verifier.js CHANGED
@@ -40,7 +40,7 @@ export default class Verifier {
40
40
  if (nodeVerified) {
41
41
  return true;
42
42
  }
43
- })
43
+ });
44
44
  }
45
45
 
46
46
  return nodesVerify;
@@ -85,9 +85,9 @@ function verifyVariableTypeAssertion(typeAssertionNode, assignments, derived, co
85
85
 
86
86
  context.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type.`, typeAssertionNode);
87
87
  } else {
88
- const type = assertedType, ///
89
- name = variableName, ///
90
- variable = Variable.fromTypeAndName(type, name),
88
+ const name = variableName, ///
89
+ type = assertedType, ///
90
+ variable = Variable.fromNameAndType(name, type),
91
91
  assignment = Assignment.fromVariable(variable);
92
92
 
93
93
  assignments.push(assignment);
@@ -44,7 +44,7 @@ export default function verifyAxiom(axiomNode, fileContext) {
44
44
  if (consequenceVerified) {
45
45
  const firstConsequence = first(consequences),
46
46
  consequence = firstConsequence, ///
47
- axiom = Axiom.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
47
+ axiom = Axiom.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
48
48
 
49
49
  fileContext.addAxiom(axiom);
50
50
 
@@ -9,6 +9,7 @@ import verifyConsequence from "./consequence";
9
9
 
10
10
  import { first } from "../utilities/array";
11
11
  import { nodeQuery, nodesQuery } from "../utilities/query";
12
+ import proof from "../context/proof";
12
13
 
13
14
  const proofNodeQuery = nodeQuery("/conjecture/proof!"),
14
15
  labelNodesQuery = nodesQuery("/conjecture/label"),
@@ -50,7 +51,7 @@ export default function verifyConjecture(conjectureNode, fileContext) {
50
51
 
51
52
  verifyProof(proofNode, consequence, proofContext);
52
53
 
53
- const conjecture = Conjecture.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
54
+ const conjecture = Conjecture.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
54
55
 
55
56
  fileContext.addConjecture(conjecture);
56
57
 
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ import verifyMetavariable from "../../verify/metavariable";
4
+
5
+ import { nodeQuery } from "../../utilities/query";
6
+
7
+ const metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
8
+ metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable");
9
+
10
+ export default function verifyMetavariableDeclaration(metavariableDeclarationNode, fileContext) {
11
+ let metavariableDeclarationVerified;
12
+
13
+ const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
14
+ metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
15
+ metavariableVVerified = verifyMetavariable(metavariableNode, metaTypeNode, fileContext);
16
+
17
+ metavariableDeclarationVerified = metavariableVVerified; ///
18
+
19
+ return metavariableDeclarationVerified;
20
+ }
@@ -9,6 +9,7 @@ import verifyTypeDeclaration from "../../verify/declaration/type";
9
9
  import verifyVariableDeclaration from "../../verify/declaration/variable";
10
10
  import verifyCombinatorDeclaration from "../../verify/declaration/combinator";
11
11
  import verifyConstructorDeclaration from "../../verify/declaration/constructor";
12
+ import verifyMetavariableDeclaration from "../../verify/declaration/metavariable";
12
13
 
13
14
  import { nodeQuery } from "../../utilities/query";
14
15
 
@@ -20,7 +21,8 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
20
21
  typeDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/typeDeclaration!"),
21
22
  variableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/variableDeclaration!"),
22
23
  combinatorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/combinatorDeclaration!"),
23
- constructorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/constructorDeclaration!");
24
+ constructorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/constructorDeclaration!"),
25
+ metavariableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/metavariableDeclaration!");
24
26
 
25
27
  export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext) {
26
28
  let topLevelDeclarationVerified = false;
@@ -34,7 +36,8 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
34
36
  typeDeclarationNode = typeDeclarationNodeQuery(node),
35
37
  variableDeclarationNode = variableDeclarationNodeQuery(node),
36
38
  combinatorDeclarationNode = combinatorDeclarationNodeQuery(node),
37
- constructorDeclarationNode = constructorDeclarationNodeQuery(node);
39
+ constructorDeclarationNode = constructorDeclarationNodeQuery(node),
40
+ metavariableDeclarationNode = metavariableDeclarationNodeQuery(node);
38
41
 
39
42
  if (false) {
40
43
  ///
@@ -74,6 +77,10 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
74
77
  const constructorDeclarationVerified = verifyConstructorDeclaration(constructorDeclarationNode, fileContext);
75
78
 
76
79
  topLevelDeclarationVerified = constructorDeclarationVerified; ///
80
+ } else if (metavariableDeclarationNode !== null) {
81
+ const metavariableDeclarationVerified = verifyMetavariableDeclaration(metavariableDeclarationNode, fileContext);
82
+
83
+ topLevelDeclarationVerified = metavariableDeclarationVerified; ///
77
84
  }
78
85
 
79
86
  return topLevelDeclarationVerified;
@@ -53,7 +53,7 @@ export default function verifyLemma(lemmaNode, fileContext) {
53
53
  proofVerified = verifyProof(proofNode, consequence, proofContext);
54
54
 
55
55
  if (proofVerified) {
56
- const lemma = Lemma.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
56
+ const lemma = Lemma.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
57
57
 
58
58
  fileContext.addLemma(lemma);
59
59
 
@@ -11,7 +11,8 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
11
11
  const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode);
12
12
 
13
13
  if (metastatementNode !== null) {
14
- const metastatementString = metaproofContext.nodeAsString(metastatementNode);
14
+ const metastatementString = metaproofContext.nodeAsString(metastatementNode),
15
+ metastatementMetaproofContext = metaproofContext; ///
15
16
 
16
17
  metaproofContext.debug(`Verifying the '${metastatementString}' qualified metastatement...`, qualifiedMetastatementNode);
17
18
 
@@ -20,7 +21,7 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
20
21
  rule = metaproofContext.findRuleByReferenceName(referenceName);
21
22
 
22
23
  if (rule !== null) {
23
- const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metaproofContext);
24
+ const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metastatementMetaproofContext);
24
25
 
25
26
  qualifiedMetastatementVerified = ruleMatchesMetastatement; ///
26
27
  }
@@ -1,9 +1,72 @@
1
1
  "use strict";
2
2
 
3
+ import Verifier from "../verifier";
4
+
5
+ import { METAVARIABLE_RULE_NAME } from "../ruleNames";
6
+ import { metavariableNameFromMetavariableNode } from "../utilities/query";
7
+
8
+ class MetastatementVerifier extends Verifier {
9
+ verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, metaproofContext) {
10
+ let nonTerminalNodeVerified = false;
11
+
12
+ const nonTerminalNode = nonTerminalNodeA, ///
13
+ ruleName = nonTerminalNode.getRuleName(); ///
14
+
15
+ switch (ruleName) {
16
+ case METAVARIABLE_RULE_NAME: {
17
+ const metavariableNode = nonTerminalNode, ///
18
+ metavariableNodeVerified = this.verifyMetavariableNode(metavariableNode, metaproofContext);
19
+
20
+ nonTerminalNodeVerified = metavariableNodeVerified; ///
21
+
22
+ break;
23
+ }
24
+
25
+ default: {
26
+ const childNodes = nonTerminalNode.getChildNodes(),
27
+ nodesA = childNodes, ///
28
+ nodesB = childNodes, ///
29
+ nodesVerified = this.verifyNodes(nodesA, nodesB, metaproofContext);
30
+
31
+ nonTerminalNodeVerified = nodesVerified; ///
32
+
33
+ break;
34
+ }
35
+ }
36
+
37
+ return nonTerminalNodeVerified;
38
+ }
39
+
40
+ verifyMetavariableNode(metavariableNode, metaproofContext) {
41
+ let metavariableNodeVerified = false;
42
+
43
+ const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
44
+ metavariablePresent = metaproofContext.isMetavariablePresentByMetavariableName(metavariableName);
45
+
46
+ if (!metavariablePresent) {
47
+ const metavariableString = metaproofContext.nodeAsString(metavariableNode);
48
+
49
+ metaproofContext.error(`The '${metavariableString}' metavariable is not present.`, metavariableNode);
50
+ } else {
51
+ metavariableNodeVerified = true;
52
+ }
53
+
54
+ return metavariableNodeVerified;
55
+ }
56
+ }
57
+
58
+ const metastatementVerifier = new MetastatementVerifier();
59
+
3
60
  export default function verifyMetastatement(metastatementNode, assignments, derived, metaproofContext) {
4
- let metastatementVerified = true; ///
61
+ let metastatementVerified = false;
62
+
63
+ if (!metastatementVerified) {
64
+ const nonTerminalNodeA = metastatementNode, ///
65
+ nonTerminalNodeB = metastatementNode, ///
66
+ nonTerminalNodeVerified = metastatementVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, metaproofContext);
5
67
 
6
- ///
68
+ metastatementVerified = nonTerminalNodeVerified; ///
69
+ }
7
70
 
8
71
  return metastatementVerified;
9
72
  }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ import Metavariable from "../metavariable";
4
+
5
+ import { metaTypeNameFromMetaTypeNode, metavariableNameFromMetavariableNode } from "../utilities/query";
6
+
7
+ export default function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
8
+ let metavariableVerified = false;
9
+
10
+ const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
11
+ metavariableString = fileContext.nodeAsString(metavariableNode),
12
+ metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
13
+
14
+ if (metavariablePresent) {
15
+ fileContext.error(`The metavariable '${metavariableName}' is already present.`, metavariableNode);
16
+ } else {
17
+ const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
18
+ metaType = fileContext.findMetaTypeByMetaTypeName(metaTypeName),
19
+ name = metavariableName, ///
20
+ metavariable = Metavariable.fromNameAndMetaType(name, metaType);
21
+
22
+ fileContext.addMetavariable(metavariable);
23
+
24
+ metavariableVerified = true;
25
+ }
26
+
27
+ if (metavariableVerified) {
28
+ fileContext.info(`Verified the '${metavariableString}' metavariable.`, metavariableNode);
29
+ }
30
+
31
+ return metavariableVerified;
32
+ }
@@ -55,7 +55,7 @@ export default function verifyRule(ruleNode, fileContext) {
55
55
  }
56
56
 
57
57
  if (ruleProofVerified) {
58
- const rule = Rule.fromLabelsPremisesAndConclusion(labels, premises, conclusion);
58
+ const rule = Rule.fromLabelsPremisesConclusionAndFileContext(labels, premises, conclusion, fileContext);
59
59
 
60
60
  fileContext.addRule(rule);
61
61
 
@@ -11,7 +11,8 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
11
11
  const statementNode = statementNodeQuery(qualifiedStatementNode);
12
12
 
13
13
  if (statementNode !== null) {
14
- const statementString = proofContext.nodeAsString(statementNode);
14
+ const statementString = proofContext.nodeAsString(statementNode),
15
+ statementProofContext = proofContext; ///
15
16
 
16
17
  proofContext.debug(`Verifying the '${statementString}' qualified statement...`, qualifiedStatementNode);
17
18
 
@@ -22,7 +23,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
22
23
  const rule = proofContext.findRuleByReferenceName(referenceName);
23
24
 
24
25
  if (rule !== null) {
25
- const ruleMatchesStatement = rule.matchStatement(statementNode, proofContext);
26
+ const ruleMatchesStatement = rule.matchStatement(statementNode, statementProofContext);
26
27
 
27
28
  qualifiedStatementVerified = ruleMatchesStatement; ///
28
29
  }
@@ -32,7 +33,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
32
33
  const axiom = proofContext.findAxiomByReferenceName(referenceName);
33
34
 
34
35
  if (axiom !== null) {
35
- const axiomMatchesStatement = axiom.matchStatement(statementNode, proofContext);
36
+ const axiomMatchesStatement = axiom.matchStatement(statementNode, statementProofContext);
36
37
 
37
38
  qualifiedStatementVerified = axiomMatchesStatement; ///
38
39
  }
@@ -42,7 +43,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
42
43
  const lemma = proofContext.findLemmaByReferenceName(referenceName);
43
44
 
44
45
  if (lemma !== null) {
45
- const lemmaMatchesStatement = lemma.matchStatement(statementNode, proofContext);
46
+ const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementProofContext);
46
47
 
47
48
  qualifiedStatementVerified = lemmaMatchesStatement; ///
48
49
  }
@@ -52,7 +53,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
52
53
  const theorem = proofContext.findTheoremByReferenceName(referenceName);
53
54
 
54
55
  if (theorem !== null) {
55
- const theoremMatchesStatement = theorem.matchStatement(statementNode, proofContext);
56
+ const theoremMatchesStatement = theorem.matchStatement(statementNode, statementProofContext);
56
57
 
57
58
  qualifiedStatementVerified = theoremMatchesStatement; ///
58
59
  }
@@ -62,7 +63,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
62
63
  const conjecture = proofContext.findConjectureByReferenceName(referenceName);
63
64
 
64
65
  if (conjecture !== null) {
65
- const conjectureMatchesStatement = conjecture.matchStatement(statementNode, proofContext);
66
+ const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementProofContext);
66
67
 
67
68
  qualifiedStatementVerified = conjectureMatchesStatement; ///
68
69
  }
@@ -192,8 +192,8 @@ function verifyStatementAgainstCombinator(statementNode, combinator, context) {
192
192
  const combinatorStatementNode = combinator.getStatementNode(),
193
193
  nonTerminalNodeA = statementNode, ///
194
194
  nonTerminalNodeB = combinatorStatementNode, ///
195
- nodeVerified = statementVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context),
196
- statementVerifiedAgainstCombinator = nodeVerified; ///
195
+ nonTerminalNodeVerified = statementVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context),
196
+ statementVerifiedAgainstCombinator = nonTerminalNodeVerified; ///
197
197
 
198
198
  return statementVerifiedAgainstCombinator;
199
199
  }
@@ -254,18 +254,18 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
254
254
  rightVariableTypeSuperTypeOfLeftVariableType = rightVariableType.isSuperTypeOf(leftVariableType);
255
255
 
256
256
  if (leftVariableTypeSuperTypeOfRightVariableType) {
257
- const type = rightVariableType, ///
258
- name = leftVariableName, ///
259
- variable = Variable.fromTypeAndName(type, name),
257
+ const name = leftVariableName, ///
258
+ type = rightVariableType, ///
259
+ variable = Variable.fromNameAndType(name, type),
260
260
  assignment = Assignment.fromVariable(variable);
261
261
 
262
262
  assignments.push(assignment);
263
263
  }
264
264
 
265
265
  if (rightVariableTypeSuperTypeOfLeftVariableType) {
266
- const type = leftVariableType, ///
267
- name = rightVariableName, ///
268
- variable = Variable.fromTypeAndName(type, name),
266
+ const name = rightVariableName, ///
267
+ type = leftVariableType, ///
268
+ variable = Variable.fromNameAndType(name, type),
269
269
  assignment = Assignment.fromVariable(variable);
270
270
 
271
271
  assignments.push(assignment);
@@ -293,9 +293,9 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
293
293
 
294
294
  context.error(`The left '${leftVariableName}' variable's '${leftVariableTypeName}' type is not equal to or a super-type of the right '${rightTermString}' term's '${rightTermTypeName}' type.`, statementNode);
295
295
  } else {
296
- const type = rightTermType, ///
297
- name = leftVariableName, ///
298
- variable = Variable.fromTypeAndName(type, name),
296
+ const name = leftVariableName, ///
297
+ type = rightTermType, ///
298
+ variable = Variable.fromNameAndType(name, type),
299
299
  assignment = Assignment.fromVariable(variable);
300
300
 
301
301
  assignments.push(assignment);
@@ -322,9 +322,9 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
322
322
 
323
323
  context.error(`The right '${rightVariableName}' variable's '${rightVariableTypeName}' type is not equal to or a super-type of the left '${leftTermString}' term's '${leftTermTypeName}' type.`, statementNode);
324
324
  } else {
325
- const type = leftTermType, ///
326
- name = rightVariableName, ///
327
- variable = Variable.fromTypeAndName(type, name),
325
+ const name = rightVariableName, ///
326
+ type = leftTermType, ///
327
+ variable = Variable.fromNameAndType(name, type),
328
328
  assignment = Assignment.fromVariable(variable);
329
329
 
330
330
  assignments.push(assignment);
@@ -9,6 +9,7 @@ import verifyConsequence from "./consequence";
9
9
 
10
10
  import { first } from "../utilities/array";
11
11
  import { nodeQuery, nodesQuery } from "../utilities/query";
12
+ import proof from "../context/proof";
12
13
 
13
14
  const proofNodeQuery = nodeQuery("/theorem/proof!"),
14
15
  labelNodesQuery = nodesQuery("/theorem/label"),
@@ -50,7 +51,7 @@ export default function verifyTheorem(theoremNode, fileContext) {
50
51
  proofVerified = verifyProof(proofNode, consequence, proofContext);
51
52
 
52
53
  if (proofVerified) {
53
- const theorem = Theorem.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
54
+ const theorem = Theorem.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
54
55
 
55
56
  fileContext.addTheorem(theorem);
56
57
 
@@ -20,10 +20,10 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
20
20
  const typeName = typeNameFromTypeNode(typeNode);
21
21
 
22
22
  if (typeName === null) {
23
- const type = objectType,
24
- name = variableName; ///
23
+ const name = variableName, ///
24
+ type = objectType;
25
25
 
26
- variable = Variable.fromTypeAndName(type, name);
26
+ variable = Variable.fromNameAndType(name, type);
27
27
  } else {
28
28
  const type = fileContext.findTypeByTypeName(typeName);
29
29
 
@@ -32,7 +32,7 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
32
32
  } else {
33
33
  const name = variableName; ///
34
34
 
35
- variable = Variable.fromTypeAndName(type, name);
35
+ variable = Variable.fromNameAndType(name, type);
36
36
  }
37
37
  }
38
38