occam-verify-cli 0.0.940 → 0.0.942

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 (67) hide show
  1. package/lib/frame.js +2 -2
  2. package/lib/premise.js +3 -3
  3. package/lib/proofStep.js +4 -3
  4. package/lib/rule.js +10 -3
  5. package/lib/substitution/termForVariable.js +3 -3
  6. package/lib/substitutions.js +186 -0
  7. package/lib/supposition.js +3 -3
  8. package/lib/topLevelAssertion.js +13 -12
  9. package/lib/unify/metavariableAgainstStatement.js +4 -4
  10. package/lib/unify/variableAgainstTerm.js +4 -4
  11. package/lib/utilities/array.js +13 -1
  12. package/lib/verifier/metaLevel.js +7 -7
  13. package/lib/verifier/statementAsCombinator.js +13 -7
  14. package/lib/verifier/termAsConstructor.js +5 -5
  15. package/lib/verifier/topLevel.js +236 -0
  16. package/lib/verify/axiom.js +3 -2
  17. package/lib/verify/conjecture.js +5 -3
  18. package/lib/verify/declaration/metavariable.js +70 -4
  19. package/lib/verify/declaration/type.js +36 -3
  20. package/lib/verify/declaration/variable.js +38 -3
  21. package/lib/verify/error.js +18 -0
  22. package/lib/verify/file.js +7 -21
  23. package/lib/verify/lemma.js +4 -3
  24. package/lib/verify/metaLemma.js +3 -2
  25. package/lib/verify/metatheorem.js +3 -2
  26. package/lib/verify/metavariable.js +4 -26
  27. package/lib/verify/rule.js +3 -2
  28. package/lib/verify/statement.js +4 -26
  29. package/lib/verify/term.js +4 -23
  30. package/lib/verify/theorem.js +4 -3
  31. package/lib/verify/type.js +10 -57
  32. package/lib/verify/variable.js +10 -59
  33. package/package.json +5 -5
  34. package/src/frame.js +1 -1
  35. package/src/premise.js +2 -2
  36. package/src/proofStep.js +3 -2
  37. package/src/rule.js +19 -3
  38. package/src/substitution/termForVariable.js +2 -2
  39. package/src/substitutions.js +103 -0
  40. package/src/supposition.js +2 -2
  41. package/src/topLevelAssertion.js +22 -15
  42. package/src/unify/metavariableAgainstStatement.js +3 -3
  43. package/src/unify/variableAgainstTerm.js +3 -3
  44. package/src/utilities/array.js +15 -0
  45. package/src/verifier/metaLevel.js +7 -9
  46. package/src/verifier/statementAsCombinator.js +18 -9
  47. package/src/verifier/termAsConstructor.js +6 -7
  48. package/src/verifier/topLevel.js +160 -0
  49. package/src/verify/axiom.js +2 -1
  50. package/src/verify/conjecture.js +5 -2
  51. package/src/verify/declaration/metavariable.js +112 -2
  52. package/src/verify/declaration/type.js +48 -1
  53. package/src/verify/declaration/variable.js +50 -1
  54. package/src/verify/error.js +11 -0
  55. package/src/verify/file.js +8 -29
  56. package/src/verify/lemma.js +3 -2
  57. package/src/verify/metaLemma.js +2 -1
  58. package/src/verify/metatheorem.js +2 -1
  59. package/src/verify/metavariable.js +0 -22
  60. package/src/verify/rule.js +2 -1
  61. package/src/verify/statement.js +0 -25
  62. package/src/verify/term.js +0 -19
  63. package/src/verify/theorem.js +3 -2
  64. package/src/verify/type.js +6 -56
  65. package/src/verify/variable.js +6 -58
  66. package/lib/verify/declaration/topLevel.js +0 -75
  67. package/src/verify/declaration/topLevel.js +0 -101
@@ -4,6 +4,7 @@ import Conjecture from "../conjecture";
4
4
  import verifyProof from "../verify/proof";
5
5
  import verifyLabels from "../verify/labels";
6
6
  import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
7
8
  import verifyConsequent from "../verify/consequent";
8
9
  import verifySuppositions from "../verify/suppositions";
9
10
 
@@ -43,10 +44,12 @@ export default function verifyConjecture(conjectureNode, fileContext) {
43
44
  consequent = firstConsequent; ///
44
45
 
45
46
  if (proofNode !== null) {
46
- verifyProof(proofNode, consequent, localContext);
47
+ const substitutions = Substitutions.fromNothing();
48
+
49
+ verifyProof(proofNode, consequent, substitutions, localContext);
47
50
  }
48
51
 
49
- const substitutions = [],
52
+ const substitutions = Substitutions.fromNothing(),
50
53
  conjecture = Conjecture.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
51
54
 
52
55
  fileContext.addConjecture(conjecture);
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
2
 
3
- import verifyMetavariable from "../../verify/metavariable";
3
+ import Metavariable from "../../metavariable";
4
+ import MetavariableAssignment from "../../assignment/metavariable";
4
5
 
6
+ import { first } from "../../utilities/array";
5
7
  import { nodeQuery } from "../../utilities/query";
8
+ import { nameFromMetavariableNode } from "../../utilities/name";
6
9
 
7
- const metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
10
+ const termNodeQuery = nodeQuery("/argument/term"),
11
+ typeNodeQuery = nodeQuery("/argument/type"),
12
+ argumentNodeQuery = nodeQuery("/metavariable/argument!"),
13
+ metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
8
14
  metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable");
9
15
 
10
16
  export default function verifyMetavariableDeclaration(metavariableDeclarationNode, fileContext) {
@@ -27,3 +33,107 @@ export default function verifyMetavariableDeclaration(metavariableDeclarationNod
27
33
 
28
34
  return metavariableDeclarationVerified;
29
35
  }
36
+
37
+ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
38
+ let metavariableVerified = false;
39
+
40
+ const metavariableString = fileContext.nodeAsString(metavariableNode);
41
+
42
+ fileContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
43
+
44
+ const metavariablePresent = fileContext.isMetavariablePresentByMetavariableNode(metavariableNode);
45
+
46
+ if (metavariablePresent) {
47
+ fileContext.debug(`The metavariable '${metavariableString}' is already present.`, metavariableNode);
48
+ } else {
49
+ const termTypes = [],
50
+ metaTypes = [],
51
+ argumentNode = argumentNodeQuery(metavariableNode),
52
+ argumentVerified = verifyArgument(argumentNode, termTypes, fileContext),
53
+ metaTypeVerified = verifyMetaType(metaTypeNode, metaTypes, fileContext);
54
+
55
+ if (argumentVerified && metaTypeVerified) {
56
+ let termType,
57
+ metaType;
58
+
59
+ const firstMetaType = first(metaTypes);
60
+
61
+ metaType = firstMetaType; ///
62
+
63
+ const termTypesLength = termTypes.length;
64
+
65
+ if (termTypesLength === 0) {
66
+ termType = null;
67
+ } else {
68
+ const firstTermType = first(termTypes);
69
+
70
+ termType = firstTermType; ///
71
+ }
72
+
73
+ const node = metavariableNode, ///
74
+ name = nameFromMetavariableNode(metavariableNode),
75
+ metavariable = Metavariable.fromNodeNameTermTypeAndMetaType(node, name, termType, metaType),
76
+ metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
77
+ metavariableAssigned = metavariableAssignment.assign(fileContext);
78
+
79
+ if (metavariableAssigned) {
80
+ metavariableVerified = true;
81
+ }
82
+ }
83
+ }
84
+
85
+ if (metavariableVerified) {
86
+ fileContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
87
+ }
88
+
89
+ return metavariableVerified;
90
+ }
91
+
92
+ function verifyArgument(argumentNode, termTypes, fileContext) {
93
+ let argumentVerified = false;
94
+
95
+ if (argumentNode === null) {
96
+ argumentVerified = true;
97
+ } else {
98
+ const termNode = termNodeQuery(argumentNode);
99
+
100
+ if (termNode === null) {
101
+
102
+ } else {
103
+ const termString = fileContext.nodeAsString(termNode);
104
+
105
+ fileContext.debug(`The '${termString}' term was found when a type should have been present.`, termNode);
106
+ }
107
+ const typeNode = typeNodeQuery(argumentNode);
108
+
109
+ if (typeNode !== null) {
110
+ const type = fileContext.findTypeByTypeNode(typeNode);
111
+
112
+ if (type !== null) {
113
+ const termType = type; ///
114
+
115
+ termTypes.push(termType);
116
+
117
+ argumentVerified = true;
118
+ } else {
119
+ const typeString = fileContext.nodeAsString(typeNode);
120
+
121
+ fileContext.debug(`The '${typeString}' type is not present.`, typeNode);
122
+ }
123
+ }
124
+ }
125
+
126
+ return argumentVerified;
127
+ }
128
+
129
+ function verifyMetaType(metaTypeNode, metaTypes, fileContext) {
130
+ let metaTypeVerified;
131
+
132
+ const metaType = fileContext.findMetaTypeByMetaTypeNode(metaTypeNode);
133
+
134
+ metaTypes.push(metaType);
135
+
136
+ metaTypeVerified = true;
137
+
138
+ return metaTypeVerified;
139
+ }
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
 
3
- import verifyType from "../../verify/type";
3
+ import Type from "../../type";
4
4
 
5
5
  import { nodeQuery } from "../../utilities/query";
6
6
  import { EMPTY_STRING } from "../../constants";
7
+ import { typeNameFromTypeNode } from "../../utilities/name";
7
8
 
8
9
  const firstTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
9
10
  secondTypeNodeQuery = nodeQuery("/typeDeclaration/type[1]");
@@ -34,3 +35,49 @@ export default function verifyTypeDeclaration(typeDeclarationNode, fileContext)
34
35
 
35
36
  return typeDeclarationVerified;
36
37
  }
38
+
39
+ function verifyType(typeNode, superTypeNode, fileContext) {
40
+ let typeVerified = false;
41
+
42
+ const typeString = fileContext.nodeAsString(typeNode);
43
+
44
+ fileContext.trace(`Verifying the '${typeString}' type...`, typeNode);
45
+
46
+ const typePresent = fileContext.isTypePresentByTypeNode(typeNode);
47
+
48
+ if (typePresent) {
49
+ const typeString = fileContext.nodeAsString(typeNode);
50
+
51
+ fileContext.debug(`The type '${typeString}' is already present.`, typeNode);
52
+ } else {
53
+ let type;
54
+
55
+ const typeName = typeNameFromTypeNode(typeNode);
56
+
57
+ if (superTypeNode === null) {
58
+ type = Type.fromTypeName(typeName);
59
+ } else {
60
+ const superType = fileContext.findTypeByTypeNode(superTypeNode);
61
+
62
+ if (superType === null) {
63
+ const superTypeString = fileContext.nodeAsString(superTypeNode);
64
+
65
+ fileContext.debug(`The super-type '${superTypeString}' is not present.`, typeNode);
66
+ } else {
67
+ type = Type.fromTypeNameAndSuperType(typeName, superType);
68
+ }
69
+ }
70
+
71
+ if (type !== null) {
72
+ fileContext.addType(type);
73
+
74
+ typeVerified = true;
75
+ }
76
+ }
77
+
78
+ if (typeVerified) {
79
+ fileContext.debug(`...verified the '${typeString}' type.`, typeNode);
80
+ }
81
+
82
+ return typeVerified;
83
+ }
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
 
3
- import verifyVariable from "../../verify/variable";
3
+ import Variable from "../../variable";
4
+ import VariableAssignment from "../../assignment/variable";
4
5
 
5
6
  import { nodeQuery } from "../../utilities/query";
7
+ import { objectType } from "../../type";
6
8
  import { EMPTY_STRING } from "../../constants";
7
9
 
8
10
  const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
@@ -32,3 +34,50 @@ export default function verifyVariableDeclaration(variableDeclarationNode, fileC
32
34
 
33
35
  return variableDeclarationVerified;
34
36
  }
37
+
38
+ function verifyVariable(variableNode, typeNode, fileContext) {
39
+ let variableVerified = false;
40
+
41
+ const variableString = fileContext.nodeAsString(variableNode);
42
+
43
+ fileContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
44
+
45
+ const variablePresent = fileContext.isVariablePresentByVariableNode(variableNode);
46
+
47
+ if (variablePresent) {
48
+ fileContext.debug(`The variable '${variableString}' is already present.`, variableNode);
49
+ } else {
50
+ let variable;
51
+
52
+ if (typeNode === null) {
53
+ const type = objectType;
54
+
55
+ variable = Variable.fromVariableNodeAndType(variableNode, type);
56
+ } else {
57
+ const type = fileContext.findTypeByTypeNode(typeNode);
58
+
59
+ if (type === null) {
60
+ const typeString = fileContext.nodeAsString(typeNode);
61
+
62
+ fileContext.debug(`The '${variableString}' variable's '${typeString}' type is not present.`, variableNode);
63
+ } else {
64
+ variable = Variable.fromVariableNodeAndType(variableNode, type);
65
+ }
66
+ }
67
+
68
+ if (variable !== null) {
69
+ const variableAssignment = VariableAssignment.fromVariable(variable),
70
+ variableAssigned = variableAssignment.assign(fileContext);
71
+
72
+ if (variableAssigned) {
73
+ variableVerified = true;
74
+ }
75
+ }
76
+ }
77
+
78
+ if (variableVerified) {
79
+ fileContext.debug(`...verified the '${variableString}' variable.`, variableNode);
80
+ }
81
+
82
+ return variableVerified;
83
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ export default function verifyError(errorNode, fileContext) {
4
+ let errorVerified = false;
5
+
6
+ const errorString = fileContext.nodeAsString(errorNode)
7
+
8
+ fileContext.debug(`The '${errorString}' cannot be verified.`, errorNode);
9
+
10
+ return errorVerified;
11
+ }
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import FileContext from "../context/file";
4
- import verifyTopLevelDeclaration from "../verify/declaration/topLevel";
5
-
6
- import { nodesQuery } from "../utilities/query";
7
-
8
- const errorNodesQuery = nodesQuery("/document/error"),
9
- topLevelDeclarationNodesQuery = nodesQuery("/document/topLevelDeclaration");
4
+ import topLevelVerifier from "../verifier/topLevel";
10
5
 
11
6
  export default function verifyFile(filePath, releaseContext) {
12
7
  let fileVerified = false;
@@ -16,29 +11,13 @@ export default function verifyFile(filePath, releaseContext) {
16
11
  const fileContext = FileContext.fromFilePathAndReleaseContext(filePath, releaseContext),
17
12
  node = fileContext.getNode();
18
13
 
19
- if (node === null) {
20
- fileVerified = true;
21
- } else {
22
- const errorNodes = errorNodesQuery(node),
23
- errorNodesLength = errorNodes.length;
24
-
25
- if (errorNodesLength > 0) {
26
- releaseContext.warning(`The '${filePath}' file cannot be verified because it contains errors.`);
27
- } else {
28
- const topLevelDeclarationNodes = topLevelDeclarationNodesQuery(node),
29
- topLevelDeclarationsVerified = topLevelDeclarationNodes.every((topLevelDeclarationNode) => {
30
- const topLevelDeclarationVerified = verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext);
31
-
32
- if (topLevelDeclarationVerified) {
33
- return true;
34
- }
35
- });
36
-
37
- if (topLevelDeclarationsVerified) {
38
- releaseContext.addFileContext(fileContext);
39
-
40
- fileVerified = true;
41
- }
14
+ if (node !== null) {
15
+ const verified = topLevelVerifier.verify(node, fileContext);
16
+
17
+ if (verified) {
18
+ releaseContext.addFileContext(fileContext);
19
+
20
+ fileVerified = true;
42
21
  }
43
22
  }
44
23
 
@@ -4,6 +4,7 @@ import Lemma from "../lemma";
4
4
  import verifyProof from "../verify/proof";
5
5
  import verifyLabels from "../verify/labels";
6
6
  import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
7
8
  import verifyConsequent from "../verify/consequent";
8
9
  import verifySuppositions from "../verify/suppositions";
9
10
 
@@ -45,11 +46,11 @@ export default function verifyLemma(lemmaNode, fileContext) {
45
46
  firstConsequent = first(consequents),
46
47
  consequent = firstConsequent, ///
47
48
  statementNode = consequent.getStatementNode(),
48
- substitutions = [],
49
+ substitutions = Substitutions.fromNothing(),
49
50
  proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
50
51
 
51
52
  if (proofVerified) {
52
- const substitutions = [],
53
+ const substitutions = Substitutions.fromNothing(),
53
54
  lemma = Lemma.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
54
55
 
55
56
  fileContext.addLemma(lemma);
@@ -4,6 +4,7 @@ import MetaLemma from "../metaLemma";
4
4
  import verifyProof from "../verify/proof";
5
5
  import LocalContext from "../context/local";
6
6
  import verifyLabels from "../verify/labels";
7
+ import Substitutions from "../substitutions";
7
8
  import verifyConsequent from "../verify/consequent";
8
9
  import verifySuppositions from "../verify/suppositions";
9
10
 
@@ -45,7 +46,7 @@ export default function verifyMetaLemma(metaLemmaNode, fileContext) {
45
46
  firstConsequent = first(consequents),
46
47
  consequent = firstConsequent, ///
47
48
  statementNode = consequent.getStatementNode(),
48
- substitutions = [],
49
+ substitutions = Substitutions.fromNothing(),
49
50
  proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
50
51
 
51
52
  if (proofVerified) {
@@ -4,6 +4,7 @@ import verifyProof from "../verify/proof";
4
4
  import Metatheorem from "../metatheorem";
5
5
  import verifyLabels from "../verify/labels";
6
6
  import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
7
8
  import verifyConsequent from "../verify/consequent";
8
9
  import verifySuppositions from "../verify/suppositions";
9
10
 
@@ -41,7 +42,7 @@ export default function verifyMetatheorem(metatheoremNode, fileContext) {
41
42
  const proofNode = proofNodeQuery(metatheoremNode),
42
43
  firstConsequent = first(consequents),
43
44
  consequent = firstConsequent, ///
44
- substitutions = [],
45
+ substitutions = Substitutions.fromNothing(),
45
46
  statementNode = consequent.getStatementNode(),
46
47
  proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
47
48
 
@@ -66,28 +66,6 @@ export default function verifyMetavariable(metavariableNode, metaTypeNode, fileC
66
66
  return metavariableVerified;
67
67
  }
68
68
 
69
- export function verifyStandaloneMetavariable(metavariableNode, localContext, verifyAhead) {
70
- let standaloneMetavariableVerified = false;
71
-
72
- const metavariableString = localContext.nodeAsString(metavariableNode);
73
-
74
- localContext.trace(`Verifying the '${metavariableString}' standalone metavariable...`, metavariableNode);
75
-
76
- const metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode);
77
-
78
- if (metavariablePresent) {
79
- const verifiedAhead = verifyAhead();
80
-
81
- standaloneMetavariableVerified = verifiedAhead; ///
82
- }
83
-
84
- if (standaloneMetavariableVerified) {
85
- localContext.debug(`...verified the '${metavariableString}' standalone metavariable.`, metavariableNode);
86
- }
87
-
88
- return standaloneMetavariableVerified;
89
- }
90
-
91
69
  function verifyArgument(argumentNode, termTypes, fileContext) {
92
70
  let argumentVerified = false;
93
71
 
@@ -9,6 +9,7 @@ import verifyConclusion from "../verify/conclusion";
9
9
 
10
10
  import { first } from "../utilities/array";
11
11
  import { nodeQuery, nodesQuery } from "../utilities/query";
12
+ import Substitutions from "../substitutions";
12
13
 
13
14
  const proofNodeQuery = nodeQuery("/rule/proof!"),
14
15
  labelNodesQuery = nodesQuery("/rule/label"),
@@ -45,7 +46,7 @@ export default function verifyRule(ruleNode, fileContext) {
45
46
  conclusion = firstConclusion; ///
46
47
 
47
48
  if (proofNode !== null) {
48
- const substitutions = [],
49
+ const substitutions = Substitutions.fromNothing(),
49
50
  statementNode = conclusion.getStatementNode();
50
51
 
51
52
  proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
@@ -54,35 +54,10 @@ function verifyStatement(statementNode, assignments, derived, localContext) {
54
54
  return statementVerified;
55
55
  }
56
56
 
57
- export function verifyStandaloneStatement(statementNode, localContext, verifyAhead) {
58
- let standaloneStatementVerified = false;
59
-
60
- const statementString = localContext.nodeAsString(statementNode);
61
-
62
- localContext.trace(`Verifying the '${statementString}' standalone statement...`, statementNode);
63
-
64
- const derived = false,
65
- assignments = [],
66
- statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
67
-
68
- if (statementVerified) {
69
- const verifiedAhead = verifyAhead();
70
-
71
- standaloneStatementVerified = verifiedAhead; ///
72
- }
73
-
74
- if (standaloneStatementVerified) {
75
- localContext.debug(`...verified the '${statementString}' standalone statement.`, statementNode);
76
- }
77
-
78
- return standaloneStatementVerified;
79
- }
80
-
81
57
  Object.assign(shim, {
82
58
  verifyStatement
83
59
  });
84
60
 
85
-
86
61
  export default verifyStatement;
87
62
 
88
63
  function verifyStatementAsMetavariable(statementNode, assignments, derived, localContext) {
@@ -39,25 +39,6 @@ function verifyTerm(termNode, terms, localContext, verifyAhead) {
39
39
  return termVerified;
40
40
  }
41
41
 
42
- export function verifyStandaloneTerm(termNode, localContext, verifyAhead) {
43
- let standaloneTermVerified;
44
-
45
- const termString = localContext.nodeAsString(termNode);
46
-
47
- localContext.trace(`Verifying the '${termString}' standalone term...`, termNode);
48
-
49
- const terms = [],
50
- termVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
51
-
52
- standaloneTermVerified = termVerified; ///
53
-
54
- if (standaloneTermVerified) {
55
- localContext.debug(`...verified the '${termString}' standalone term.`, termNode);
56
- }
57
-
58
- return standaloneTermVerified;
59
- }
60
-
61
42
  Object.assign(shim, {
62
43
  verifyTerm
63
44
  });
@@ -4,6 +4,7 @@ import Theorem from "../theorem";
4
4
  import verifyProof from "../verify/proof";
5
5
  import verifyLabels from "../verify/labels";
6
6
  import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
7
8
  import verifyConsequent from "../verify/consequent";
8
9
  import verifySuppositions from "../verify/suppositions";
9
10
 
@@ -42,11 +43,11 @@ export default function verifyTheorem(theoremNode, fileContext) {
42
43
  firstConsequent = first(consequents),
43
44
  consequent = firstConsequent, ///
44
45
  statementNode = consequent.getStatementNode(),
45
- substitutions = [],
46
+ substitutions = Substitutions.fromNothing(),
46
47
  proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
47
48
 
48
49
  if (proofVerified) {
49
- const substitutions = [],
50
+ const substitutions = Substitutions.fromNothing(),
50
51
  theorem = Theorem.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
51
52
 
52
53
  fileContext.addTheorem(theorem);
@@ -1,73 +1,23 @@
1
1
  "use strict";
2
2
 
3
- import Type from "../type";
4
-
5
- import { typeNameFromTypeNode } from "../utilities/name";
6
-
7
- export default function verifyType(typeNode, superTypeNode, fileContext) {
3
+ export default function verifyType(typeNode, localContext, verifyAhead) {
8
4
  let typeVerified = false;
9
5
 
10
- const typeString = fileContext.nodeAsString(typeNode);
11
-
12
- fileContext.trace(`Verifying the '${typeString}' type...`, typeNode);
13
-
14
- const typePresent = fileContext.isTypePresentByTypeNode(typeNode);
15
-
16
- if (typePresent) {
17
- const typeString = fileContext.nodeAsString(typeNode);
18
-
19
- fileContext.debug(`The type '${typeString}' is already present.`, typeNode);
20
- } else {
21
- let type;
22
-
23
- const typeName = typeNameFromTypeNode(typeNode);
24
-
25
- if (superTypeNode === null) {
26
- type = Type.fromTypeName(typeName);
27
- } else {
28
- const superType = fileContext.findTypeByTypeNode(superTypeNode);
29
-
30
- if (superType === null) {
31
- const superTypeString = fileContext.nodeAsString(superTypeNode);
32
-
33
- fileContext.debug(`The super-type '${superTypeString}' is not present.`, typeNode);
34
- } else {
35
- type = Type.fromTypeNameAndSuperType(typeName, superType);
36
- }
37
- }
38
-
39
- if (type !== null) {
40
- fileContext.addType(type);
41
-
42
- typeVerified = true;
43
- }
44
- }
45
-
46
- if (typeVerified) {
47
- fileContext.debug(`...verified the '${typeString}' type.`, typeNode);
48
- }
49
-
50
- return typeVerified;
51
- }
52
-
53
- export function verifyStandaloneType(typeNode, localContext, verifyAhead) {
54
- let standaloneTypeVerified = false;
55
-
56
6
  const typeString = localContext.nodeAsString(typeNode);
57
7
 
58
- localContext.trace(`Verifying the '${typeString}' standalone type...`, typeNode);
8
+ localContext.trace(`Verifying the '${typeString}' type...`, typeNode);
59
9
 
60
10
  const typePresent = localContext.isTypePresentByTypeNode(typeNode);
61
11
 
62
12
  if (typePresent) {
63
13
  const verifiedAhead = verifyAhead();
64
14
 
65
- standaloneTypeVerified = verifiedAhead; ///
15
+ typeVerified = verifiedAhead; ///
66
16
  }
67
17
 
68
- if (standaloneTypeVerified) {
69
- localContext.debug(`...verified the '${typeString}' standalone type.`, typeNode);
18
+ if (typeVerified) {
19
+ localContext.debug(`...verified the '${typeString}' type.`, typeNode);
70
20
  }
71
21
 
72
- return standaloneTypeVerified;
22
+ return typeVerified;
73
23
  }