occam-verify-cli 0.0.960 → 0.0.961

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/context/local.js +3 -9
  2. package/lib/proofStep.js +8 -5
  3. package/lib/substitution/termForVariable.js +24 -25
  4. package/lib/unifier/statementWithCombinator.js +6 -6
  5. package/lib/unify/statementAtainstStatement.js +16 -16
  6. package/lib/unify/statementWithBracketedCombinator.js +30 -0
  7. package/lib/unify/statementWithCombinators.js +40 -0
  8. package/lib/unify/statementWithMetaType.js +6 -30
  9. package/lib/unify/termWithBracketedConstructor.js +37 -0
  10. package/lib/unify/termWithConstructors.js +53 -0
  11. package/lib/unify/termWithType.js +4 -12
  12. package/lib/utilities/assignments.js +9 -12
  13. package/lib/verifier/intrinsicLevel.js +140 -0
  14. package/lib/verifier/metaLevel.js +11 -20
  15. package/lib/verifier/statementAsCombinator.js +9 -9
  16. package/lib/verifier/termAsConstructor.js +5 -5
  17. package/lib/verify/assertion/contained.js +2 -3
  18. package/lib/verify/assertion/defined.js +2 -4
  19. package/lib/verify/assertion/subproof.js +20 -18
  20. package/lib/verify/assertion/type.js +1 -2
  21. package/lib/verify/declaration.js +27 -9
  22. package/lib/verify/frame.js +25 -6
  23. package/lib/verify/premise.js +3 -3
  24. package/lib/verify/proofStep.js +23 -30
  25. package/lib/verify/statement/qualified.js +93 -137
  26. package/lib/verify/statement/unqualified.js +18 -104
  27. package/lib/verify/statement.js +95 -76
  28. package/lib/verify/statementAsCombinator.js +2 -2
  29. package/lib/verify/statementGivenMetaType.js +41 -0
  30. package/lib/verify/supposition.js +3 -3
  31. package/lib/verify/term.js +36 -64
  32. package/lib/verify/termAsConstructor.js +2 -2
  33. package/lib/verify/termGivenType.js +34 -0
  34. package/package.json +1 -1
  35. package/src/context/local.js +4 -13
  36. package/src/proofStep.js +10 -5
  37. package/src/substitution/termForVariable.js +33 -30
  38. package/src/unifier/statementWithCombinator.js +5 -5
  39. package/src/unify/statementAtainstStatement.js +13 -13
  40. package/src/unify/statementWithBracketedCombinator.js +22 -0
  41. package/src/unify/statementWithCombinators.js +38 -0
  42. package/src/unify/statementWithMetaType.js +6 -42
  43. package/src/unify/termWithBracketedConstructor.js +36 -0
  44. package/src/unify/termWithConstructors.js +63 -0
  45. package/src/unify/termWithType.js +4 -20
  46. package/src/utilities/assignments.js +6 -13
  47. package/src/verifier/intrinsicLevel.js +42 -0
  48. package/src/verifier/metaLevel.js +13 -21
  49. package/src/verifier/statementAsCombinator.js +11 -7
  50. package/src/verifier/termAsConstructor.js +4 -3
  51. package/src/verify/assertion/contained.js +1 -3
  52. package/src/verify/assertion/defined.js +1 -4
  53. package/src/verify/assertion/subproof.js +22 -18
  54. package/src/verify/assertion/type.js +0 -1
  55. package/src/verify/declaration.js +34 -11
  56. package/src/verify/frame.js +32 -5
  57. package/src/verify/premise.js +3 -3
  58. package/src/verify/proofStep.js +26 -38
  59. package/src/verify/statement/qualified.js +104 -184
  60. package/src/verify/statement/unqualified.js +19 -149
  61. package/src/verify/statement.js +126 -72
  62. package/src/verify/statementAsCombinator.js +1 -1
  63. package/src/verify/statementGivenMetaType.js +37 -0
  64. package/src/verify/supposition.js +3 -3
  65. package/src/verify/term.js +38 -93
  66. package/src/verify/termAsConstructor.js +1 -1
  67. package/src/verify/termGivenType.js +32 -0
@@ -2,34 +2,42 @@
2
2
 
3
3
  import shim from "../shim";
4
4
  import Term from "../term";
5
- import bracketedConstructor from "../constructor/bracketed";
6
- import termWithConstructorUnifier from "../unifier/termWithConstructor";
5
+ import unifyTermWithConstructors from "../unify/termWithConstructors";
6
+ import unifyTermWithBracketedConstructor from "../unify/termWithBracketedConstructor";
7
7
 
8
8
  import { nodeQuery } from "../utilities/query";
9
9
 
10
- const termNodeQuery = nodeQuery("/term/argument/term"),
11
- variableNodeQuery = nodeQuery("/term/variable!");
10
+ const variableNodeQuery = nodeQuery("/term/variable!");
11
+
12
+ const unifyTermFunctions = [
13
+ unifyTermWithBracketedConstructor,
14
+ unifyTermWithConstructors,
15
+ ];
12
16
 
13
17
  function verifyTerm(termNode, terms, localContext, verifyAhead) {
14
- let termVerified;
18
+ let termVerified = false;
15
19
 
16
20
  const termString = localContext.nodeAsString(termNode);
17
21
 
18
22
  localContext.trace(`Verifying the '${termString}' term...`, termNode);
19
23
 
20
- const verifyTermFunctions = [
21
- verifyTermAsVariable,
22
- unifyTermWithConstructors,
23
- unifyTermWithBracketedConstructor
24
- ];
24
+ if (!termVerified) {
25
+ const termVerifiedAsVariable = verifyTermAsVariable(termNode, terms, localContext, verifyAhead);
25
26
 
26
- termVerified = verifyTermFunctions.some((verifyTermFunction) => {
27
- const termVerified = verifyTermFunction(termNode, terms, localContext, verifyAhead);
27
+ termVerified = termVerifiedAsVariable; ///
28
+ }
28
29
 
29
- if (termVerified) {
30
- return true;
31
- }
32
- });
30
+ if (!termVerified) {
31
+ const termUnified = unifyTermFunctions.some((unifyTermFunction) => {
32
+ const termUnified = unifyTermFunction(termNode, terms, localContext, verifyAhead);
33
+
34
+ if (termUnified) {
35
+ return true;
36
+ }
37
+ });
38
+
39
+ termVerified = termUnified; ///
40
+ }
33
41
 
34
42
  if (termVerified) {
35
43
  localContext.debug(`...verified the '${termString}' term.`, termNode);
@@ -54,9 +62,9 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
54
62
 
55
63
  localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
56
64
 
57
- const variable = localContext.findVariableByVariableNode(variableNode);
65
+ const variableVerified = verifyVariable(variableNode, localContext);
58
66
 
59
- if (variable !== null) {
67
+ if (variableVerified) {
60
68
  let verifiedAhead;
61
69
 
62
70
  const type = variable.getType(),
@@ -79,87 +87,24 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
79
87
  return termVerifiedAsVariable;
80
88
  }
81
89
 
82
- function unifyTermWithConstructors(termNode, terms, localContext, verifyAhead) {
83
- let termUnifiedWithConstructors = false;
84
-
85
- const variableNode = variableNodeQuery(termNode);
86
-
87
- if (variableNode === null) {
88
- const constructors = localContext.getConstructors();
89
-
90
- termUnifiedWithConstructors = constructors.some((constructor) => {
91
- const termUnifiedWithConstructor = unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead);
92
-
93
- if (termUnifiedWithConstructor) {
94
- return true;
95
- }
96
- });
97
- }
98
-
99
- return termUnifiedWithConstructors;
100
- }
101
-
102
- function unifyTermWithBracketedConstructor(termNode, terms, localContext, verifyAhead) {
103
- let termUnifiedWithBracketedConstructor;
104
-
105
- const termString = localContext.nodeAsString(termNode),
106
- bracketedTerms = [];
107
-
108
- localContext.trace(`Unifying the '${termString}' term with the bracketed constructor...`, termNode);
109
-
110
- termUnifiedWithBracketedConstructor = unifyTermWithConstructor(termNode, bracketedTerms, bracketedConstructor, localContext, () => {
111
- let verifiedAhead;
112
-
113
- const bracketedTermNode = termNode; ///
114
-
115
- termNode = termNodeQuery(bracketedTermNode); ///
116
-
117
- const termVVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
118
-
119
- verifiedAhead = termVVerified; ///
120
-
121
- return verifiedAhead;
122
- });
123
-
124
- if (termUnifiedWithBracketedConstructor) {
125
- localContext.debug(`...unified the '${termString}' term with the bracketed constructor.`, termNode);
126
- }
127
-
128
- return termUnifiedWithBracketedConstructor;
129
- }
130
-
131
- function unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead) {
132
- let termUnifiedWithConstructor = false;
133
-
134
- const termString = localContext.nodeAsString(termNode),
135
- constructorString = constructor.getString(),
136
- constructorTermNode = constructor.getTermNode();
90
+ function verifyVariable(variableNode, localContext) {
91
+ let variableVerified = false;
137
92
 
138
- localContext.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, termNode);
93
+ const variableString = localContext.nodeAsString(variableNode);
139
94
 
140
- const termNodeA = termNode, ///
141
- constructorTermNodeB = constructorTermNode, ///
142
- unified = termWithConstructorUnifier.unify(termNodeA, constructorTermNodeB, localContext);
95
+ localContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
143
96
 
144
- if (unified) {
145
- let verifiedAhead;
97
+ const variablePresent = localContext.isVariablePresentByVariableNode(variableNode);
146
98
 
147
- const type = constructor.getType(),
148
- term = Term.fromTermNodeAndType(termNode, type);
149
-
150
- terms.push(term);
151
-
152
- verifiedAhead = verifyAhead();
153
-
154
- terms.pop();
155
-
156
- termUnifiedWithConstructor = verifiedAhead; ///
99
+ if (!variablePresent) {
100
+ localContext.trace(`The '${variableString}' variable is not present.`, variableNode);
101
+ } else {
102
+ variableVerified = true;
157
103
  }
158
104
 
159
- if (termUnifiedWithConstructor) {
160
- localContext.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, termNode);
105
+ if (variableVerified) {
106
+ localContext.debug(`...verified the '${variableString}' variable.`, variableNode);
161
107
  }
162
108
 
163
- return termUnifiedWithConstructor;
109
+ return variableVerified;
164
110
  }
165
-
@@ -22,7 +22,7 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
22
22
 
23
23
  type = firstType; ///
24
24
 
25
- termVerifiedAsConstructor = termAsConstructorVerifier.verify(termNode, fileContext);
25
+ termVerifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
26
26
  }
27
27
 
28
28
  if (termVerifiedAsConstructor) {
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ import shim from "../shim";
4
+
5
+ import { first } from "../utilities/array";
6
+
7
+ export default function verifyTermGivenType(termNode, type, localContext) {
8
+ let termVerifiedGivenType = false;
9
+
10
+ if (type !== null) {
11
+ const { verifyTerm } = shim,
12
+ terms = [],
13
+ termVerified = verifyTerm(termNode, terms, localContext, () => {
14
+ let verifiedAhead = false;
15
+
16
+ const firstTerm = first(terms),
17
+ term = firstTerm, ///
18
+ termType = term.getType(),
19
+ termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
20
+
21
+ if (termTypeEqualToOrSubTypeOfType) {
22
+ verifiedAhead = true;
23
+ }
24
+
25
+ return verifiedAhead;
26
+ });
27
+
28
+ termVerifiedGivenType = termVerified; ///
29
+ }
30
+
31
+ return termVerifiedGivenType;
32
+ }