occam-verify-cli 0.0.525 → 0.0.527

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/lib/assertion/type.js +10 -40
  2. package/lib/axiom.js +7 -7
  3. package/lib/axiomLemmaTheoremConjecture.js +190 -0
  4. package/lib/combinator.js +5 -5
  5. package/lib/conclusion.js +3 -3
  6. package/lib/conjecture.js +141 -0
  7. package/lib/consequence.js +5 -5
  8. package/lib/constants.js +4 -16
  9. package/lib/constructor.js +6 -6
  10. package/lib/context/file.js +85 -32
  11. package/lib/context/metaproof.js +46 -4
  12. package/lib/context/proof.js +38 -93
  13. package/lib/context/release/directory.js +20 -1
  14. package/lib/context/release/file.js +27 -3
  15. package/lib/equality.js +78 -51
  16. package/lib/index.js +1 -13
  17. package/lib/kinds.js +5 -1
  18. package/lib/label.js +5 -5
  19. package/lib/lemma.js +7 -7
  20. package/lib/matcher/metastatementForMetavariable.js +16 -19
  21. package/lib/matcher/statementForMetavariable.js +22 -20
  22. package/lib/matcher/{statementForVariable → termForVariable}/consequence.js +13 -13
  23. package/lib/matcher/{statementForVariable → termForVariable}/supposition.js +13 -13
  24. package/lib/matcher/termForVariable.js +198 -0
  25. package/lib/matcher.js +23 -64
  26. package/lib/mixins/file.js +62 -2
  27. package/lib/premise.js +6 -6
  28. package/lib/rule.js +5 -5
  29. package/lib/ruleNames.js +1 -9
  30. package/lib/step/proof.js +22 -1
  31. package/lib/substitution/statementForMetavariable.js +12 -8
  32. package/lib/substitution/termForVariable.js +86 -0
  33. package/lib/supposition.js +6 -6
  34. package/lib/theorem.js +7 -7
  35. package/lib/type.js +13 -6
  36. package/lib/utilities/string.js +17 -16
  37. package/lib/utilities/substitution.js +4 -5
  38. package/lib/variable.js +5 -39
  39. package/lib/verify/assertion/type.js +60 -37
  40. package/lib/verify/axiom.js +2 -3
  41. package/lib/verify/conclusion.js +2 -3
  42. package/lib/verify/conjecture.js +56 -0
  43. package/lib/verify/consequence.js +3 -4
  44. package/lib/verify/declaration/topLevel.js +7 -3
  45. package/lib/verify/label.js +2 -3
  46. package/lib/verify/lemma.js +2 -3
  47. package/lib/verify/metastatement/qualified.js +3 -4
  48. package/lib/verify/metastatement/unqualified.js +3 -4
  49. package/lib/verify/premise.js +3 -4
  50. package/lib/verify/rule.js +2 -3
  51. package/lib/verify/statement/qualified.js +41 -12
  52. package/lib/verify/statement/unqualified.js +3 -4
  53. package/lib/verify/statement.js +47 -51
  54. package/lib/verify/statementAsCombinator.js +2 -3
  55. package/lib/verify/supposition.js +3 -4
  56. package/lib/verify/term.js +3 -4
  57. package/lib/verify/termAsConstructor.js +4 -5
  58. package/lib/verify/theorem.js +2 -3
  59. package/lib/verify/type.js +2 -3
  60. package/lib/verify/variable.js +2 -3
  61. package/package.json +1 -1
  62. package/src/assertion/type.js +7 -32
  63. package/src/axiom.js +4 -4
  64. package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +9 -9
  65. package/src/combinator.js +4 -4
  66. package/src/conclusion.js +2 -2
  67. package/src/conjecture.js +13 -0
  68. package/src/consequence.js +4 -4
  69. package/src/constants.js +1 -4
  70. package/src/constructor.js +6 -6
  71. package/src/context/file.js +89 -32
  72. package/src/context/metaproof.js +44 -3
  73. package/src/context/proof.js +42 -37
  74. package/src/context/release/directory.js +24 -0
  75. package/src/context/release/file.js +34 -3
  76. package/src/equality.js +110 -61
  77. package/src/index.js +0 -3
  78. package/src/kinds.js +1 -0
  79. package/src/label.js +4 -4
  80. package/src/lemma.js +4 -4
  81. package/src/matcher/metastatementForMetavariable.js +22 -32
  82. package/src/matcher/statementForMetavariable.js +40 -34
  83. package/src/matcher/termForVariable/consequence.js +9 -0
  84. package/src/matcher/termForVariable/supposition.js +9 -0
  85. package/src/matcher/termForVariable.js +89 -0
  86. package/src/matcher.js +28 -22
  87. package/src/mixins/file.js +46 -1
  88. package/src/premise.js +6 -6
  89. package/src/rule.js +4 -4
  90. package/src/ruleNames.js +0 -2
  91. package/src/step/proof.js +27 -0
  92. package/src/substitution/statementForMetavariable.js +17 -10
  93. package/src/substitution/termForVariable.js +64 -0
  94. package/src/supposition.js +5 -5
  95. package/src/theorem.js +4 -4
  96. package/src/type.js +18 -8
  97. package/src/utilities/string.js +27 -21
  98. package/src/utilities/substitution.js +6 -4
  99. package/src/variable.js +5 -38
  100. package/src/verify/assertion/type.js +71 -65
  101. package/src/verify/axiom.js +1 -2
  102. package/src/verify/conclusion.js +1 -2
  103. package/src/verify/conjecture.js +73 -0
  104. package/src/verify/consequence.js +2 -3
  105. package/src/verify/declaration/topLevel.js +7 -0
  106. package/src/verify/label.js +1 -2
  107. package/src/verify/lemma.js +1 -2
  108. package/src/verify/metastatement/qualified.js +2 -3
  109. package/src/verify/metastatement/unqualified.js +2 -3
  110. package/src/verify/premise.js +2 -3
  111. package/src/verify/rule.js +1 -2
  112. package/src/verify/statement/qualified.js +55 -15
  113. package/src/verify/statement/unqualified.js +2 -3
  114. package/src/verify/statement.js +49 -70
  115. package/src/verify/statementAsCombinator.js +1 -2
  116. package/src/verify/supposition.js +2 -3
  117. package/src/verify/term.js +2 -3
  118. package/src/verify/termAsConstructor.js +3 -4
  119. package/src/verify/theorem.js +1 -2
  120. package/src/verify/type.js +1 -2
  121. package/src/verify/variable.js +1 -2
  122. package/lib/axiomLemmaTheorem.js +0 -190
  123. package/lib/jsonTypes.js +0 -30
  124. package/lib/matcher/statementForVariable.js +0 -201
  125. package/lib/substitution/statementForVariable.js +0 -86
  126. package/lib/utilities/json.js +0 -187
  127. package/lib/utilities/version.js +0 -32
  128. package/lib/versionChanges.js +0 -34
  129. package/src/jsonTypes.js +0 -6
  130. package/src/matcher/statementForVariable/consequence.js +0 -9
  131. package/src/matcher/statementForVariable/supposition.js +0 -9
  132. package/src/matcher/statementForVariable.js +0 -99
  133. package/src/substitution/statementForVariable.js +0 -64
  134. package/src/utilities/json.js +0 -264
  135. package/src/utilities/version.js +0 -30
  136. package/src/versionChanges.js +0 -11
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- import Matcher from "../matcher";
4
- import StatementForVariableSubstitution from "../substitution/statementForVariable";
5
-
6
- import { first } from "../utilities/array";
7
- import { variableNameFromVariableNode } from "../utilities/query";
8
- import { VARIABLE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
9
-
10
- export default class StatementForVariableMatcher extends Matcher {
11
- matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
12
- let nonTerminalNodeMatches = false;
13
-
14
- const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
15
- nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
16
- nonTerminalNodeARuleNameMetastatementRuleName = (nonTerminalNodeARuleName === STATEMENT_RULE_NAME),
17
- nonTerminalNodeBRuleNameMetastatementRuleName = (nonTerminalNodeBRuleName === STATEMENT_RULE_NAME);
18
-
19
- if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
20
- const statementNodeA = nonTerminalNodeA, ///
21
- statementNodeB = nonTerminalNodeB, ///
22
- statementNodeMatches = this.matchStatementNode(statementNodeA, statementNodeB, substitutions);
23
-
24
- if (statementNodeMatches) {
25
- nonTerminalNodeMatches = true; ///
26
- } else {
27
- nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
28
- }
29
- } else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
30
- nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
31
- }
32
-
33
- return nonTerminalNodeMatches;
34
- }
35
-
36
- matchStatementNode(statementNodeA, statementNodeB, substitutions) {
37
- let statementNodeMatches = false;
38
-
39
- const nonTerminalNodeA = statementNodeA, ///
40
- nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
41
- nonTerminalNodeAChildNodesLength = nonTerminalNodeAChildNodes.length;
42
-
43
- if (nonTerminalNodeAChildNodesLength === 1) {
44
- const firstNonTerminalNodeAChildNode = first(nonTerminalNodeAChildNodes),
45
- childNodeA = firstNonTerminalNodeAChildNode, ///
46
- childNodeANonTerminalNode = childNodeA.isNonTerminalNode();
47
-
48
- if (childNodeANonTerminalNode) {
49
- const nonTerminalNodeA = childNodeA, ///
50
- nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
51
- nonTerminalNodeARuleNameVariableRuleName = (nonTerminalNodeARuleName === VARIABLE_RULE_NAME);
52
-
53
- if (nonTerminalNodeARuleNameVariableRuleName) {
54
- const variableNodeA = nonTerminalNodeA, ///
55
- variableMatches = this.matchVariableNode(variableNodeA, statementNodeB, substitutions);
56
-
57
- statementNodeMatches = variableMatches; ///
58
- }
59
- }
60
- }
61
-
62
- return statementNodeMatches;
63
- }
64
-
65
- matchVariableNode(variableNodeB, statementNodeB, substitutions) {
66
- let variableMatches;
67
-
68
- const variableNameA = variableNameFromVariableNode(variableNodeB),
69
- substitution = substitutions.find((substitution) => {
70
- const variableName = substitution.getVariableName();
71
-
72
- if (variableName === variableNameA) {
73
- return true;
74
- }
75
- }) || null;
76
-
77
- if (substitution !== null) {
78
- const statementNode = statementNodeB, ///
79
- substitutionNodesMatch = substitution.matchStatementNode(statementNode);
80
-
81
- variableMatches = substitutionNodesMatch; ///
82
- } else {
83
- const { createSubstitutions } = this.constructor;
84
-
85
- if (createSubstitutions) {
86
- const variableName = variableNameA, ///
87
- statementNode = statementNodeB, ///
88
- statementForVariableSubstitution = StatementForVariableSubstitution.fromVariableNameAndStatementNode(variableName, statementNode),
89
- substitution = statementForVariableSubstitution; ///
90
-
91
- substitutions.push(substitution);
92
- }
93
-
94
- variableMatches = true;
95
- }
96
-
97
- return variableMatches;
98
- }
99
- }
@@ -1,64 +0,0 @@
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 StatementForVariableSubstitution {
8
- constructor(variableName, statementNode) {
9
- this.variableName = variableName;
10
- this.statementNode = statementNode;
11
- }
12
-
13
- getVariableName() {
14
- return this.variableName;
15
- }
16
-
17
- getStatementNode() {
18
- return this.statementNode;
19
- }
20
-
21
- matchStatementNode(statementNode) {
22
- let matchesStatementNode;
23
-
24
- const nodeA = this.statementNode, ///
25
- nodeB = statementNode,
26
- nodeMatches = matcher.matchNode(nodeA, nodeB);
27
-
28
- matchesStatementNode = nodeMatches; ///
29
-
30
- if (!matchesStatementNode) {
31
- const nonTerminalNode = statementNode, ///
32
- childNodes = nonTerminalNode.getChildNodes(), ///
33
- ruleName = STATEMENT_RULE_NAME;
34
-
35
- statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
36
-
37
- if (statementNode !== null) {
38
- const nodeA = this.statementNode, ///
39
- nodeB = statementNode,
40
- nodeMatches = matchNode(nodeA, nodeB);
41
-
42
- matchesStatementNode = nodeMatches; ///
43
- }
44
- }
45
-
46
- return matchesStatementNode;
47
- }
48
-
49
- static fromVariableNameAndStatementNode(variableName, statementNode) {
50
- let statementForVariableSubstitution = new StatementForVariableSubstitution(variableName, statementNode);
51
-
52
- const nonTerminalNode = statementNode, ///
53
- childNodes = nonTerminalNode.getChildNodes(),
54
- ruleName = STATEMENT_RULE_NAME;
55
-
56
- statementNode = bracketedNonTerminalChildNodeFromChildNodes(childNodes, ruleName); ///
57
-
58
- if (statementNode !== null) {
59
- statementForVariableSubstitution = new StatementForVariableSubstitution(variableName, statementNode);
60
- }
61
-
62
- return statementForVariableSubstitution;
63
- }
64
- }
@@ -1,264 +0,0 @@
1
- "use strict";
2
-
3
- import { arrayUtilities } from "necessary";
4
-
5
- import { STRING, NUMBER, BOOLEAN } from "../constants";
6
- import { NULL_JSON_TYPE, ARRAY_JSON_TYPE, OBJECT_JSON_TYPE, PRIMITIVE_JSON_TYPE } from "../jsonTypes";
7
- import { BREAKING_VERSION_CHANGE, ADDITIVE_VERSION_CHANGE, COSMETIC_VERSION_CHANGE } from "../versionChanges";
8
-
9
- const { first } = arrayUtilities;
10
-
11
- function compareJSON(jsonA, jsonB) {
12
- let result = BREAKING_VERSION_CHANGE;
13
-
14
- const jsonAType = typeOf(jsonA),
15
- jsonBType = typeOf(jsonB);
16
-
17
- if (jsonAType === jsonBType) {
18
- const jsonType = jsonAType; ///
19
-
20
- switch (jsonType) {
21
- case ARRAY_JSON_TYPE: {
22
- const arrayA = jsonA, ///
23
- arrayB = jsonB; ///
24
-
25
- result = compareArrays(arrayA, arrayB);
26
-
27
- break;
28
- }
29
-
30
- case OBJECT_JSON_TYPE: {
31
- const objectA = jsonA, ///
32
- objectB = jsonB; ///
33
-
34
- result = compareObjects(objectA, objectB);
35
-
36
- break;
37
- }
38
-
39
- case PRIMITIVE_JSON_TYPE: {
40
- const primitiveA = jsonA, ///
41
- primitiveB = jsonB; ///
42
-
43
- result = comparePrimitives(primitiveA, primitiveB);
44
-
45
- break;
46
- }
47
- }
48
- }
49
-
50
- return result;
51
- }
52
-
53
- export default {
54
- compareJSON
55
- };
56
-
57
- function compareArrays(arrayA, arrayB) {
58
- let result;
59
-
60
- const arrayALength = arrayA.length,
61
- arrayBLength = arrayB.length;
62
-
63
- if (arrayALength === 0) {
64
- if (arrayBLength === 0) {
65
- result = COSMETIC_VERSION_CHANGE;
66
- } else {
67
- result = ADDITIVE_VERSION_CHANGE;
68
- }
69
- } else {
70
- if (arrayBLength === 0) {
71
- result = BREAKING_VERSION_CHANGE;
72
- } else {
73
- const firstElementA = first(arrayA), ///
74
- elementA = firstElementA, ///
75
- elementB = arrayB.find((elementB) => {
76
- const jsonA = elementA, ///
77
- jsonB = elementB, ///
78
- result = compareJSON(jsonA, jsonB);
79
-
80
- if (result === COSMETIC_VERSION_CHANGE) {
81
- return true;
82
- }
83
- }) || null;
84
-
85
- if (elementB !== null) {
86
- arrayA = deleteElement(arrayA, elementA);
87
-
88
- arrayB = deleteElement(arrayB, elementB);
89
-
90
- result = compareArrays(arrayA, arrayB);
91
- } else {
92
- result = BREAKING_VERSION_CHANGE;
93
- }
94
- }
95
- }
96
-
97
- return result;
98
- }
99
-
100
- function compareObjects(objectA, objectB) {
101
- let result;
102
-
103
- const keysA = Object.keys(objectA),
104
- keysB = Object.keys(objectB),
105
- keysALength = keysA.length,
106
- keysBLength = keysB.length;
107
-
108
- if (keysALength === 0) {
109
- if (keysBLength === 0) {
110
- result = COSMETIC_VERSION_CHANGE;
111
- } else {
112
- result = ADDITIVE_VERSION_CHANGE;
113
- }
114
- } else {
115
- if (keysBLength === 0) {
116
- result = BREAKING_VERSION_CHANGE;
117
- } else {
118
- const firstKeyA = first(keysA), ///
119
- keyA = firstKeyA, ///
120
- keyB = keysB.find((keyB, index) => {
121
- if (keyA === keyB) {
122
- const valueA = objectA[keyA],
123
- valueB = objectB[keyB],
124
- jsonA = valueA, ///
125
- jsonB = valueB, ///
126
- result = compareJSON(jsonA, jsonB);
127
-
128
- if (result === COSMETIC_VERSION_CHANGE) { ///
129
- return true;
130
- }
131
- }
132
- }) || null;
133
-
134
- if (keyB !== null) {
135
- objectA = deleteKey(objectA, keyA);
136
-
137
- objectB = deleteKey(objectB, keyB);
138
-
139
- result = compareObjects(objectA, objectB);
140
- } else {
141
- result = BREAKING_VERSION_CHANGE;
142
- }
143
- }
144
- }
145
-
146
- return result;
147
- }
148
-
149
- function comparePrimitives(primitiveA, primitiveB) {
150
- let result = BREAKING_VERSION_CHANGE;
151
-
152
- if (primitiveA === primitiveB) {
153
- result = COSMETIC_VERSION_CHANGE;
154
- }
155
-
156
- return result;
157
- }
158
-
159
- function typeOf(json) {
160
- let type;
161
-
162
- const _null = isNull(json),
163
- array = isArray(json),
164
- object = isObject(json),
165
- primitive = isPrimitive(json);
166
-
167
- if (_null) {
168
- type = NULL_JSON_TYPE;
169
- }
170
-
171
- if (array) {
172
- type = ARRAY_JSON_TYPE;
173
- }
174
-
175
- if (object) {
176
- type = OBJECT_JSON_TYPE;
177
- }
178
-
179
- if (primitive) {
180
- type = PRIMITIVE_JSON_TYPE;
181
- }
182
-
183
- return type;
184
- }
185
-
186
- function isNull(json) {
187
- const _null = (json === null);
188
-
189
- return _null;
190
- }
191
-
192
- function isArray(json) {
193
- const array = Array.isArray(json);
194
-
195
- return array;
196
- }
197
-
198
- function isObject(json) {
199
- const array = isArray(json),
200
- primitive = isPrimitive(json),
201
- object = (!array && !primitive);
202
-
203
- return object;
204
- }
205
-
206
- function isString(json) {
207
- const string = ((typeof json) === STRING);
208
-
209
- return string;
210
- }
211
-
212
- function isNumber(json) {
213
- const number = ((typeof json) === NUMBER);
214
-
215
- return number;
216
- }
217
-
218
- function isBoolean(json) {
219
- const boolean = ((typeof json) === BOOLEAN);
220
-
221
- return boolean;
222
- }
223
-
224
- function isPrimitive(json) {
225
- const _null = isNull(json),
226
- string = isString(json),
227
- number = isNumber(json),
228
- boolean = isBoolean(json),
229
- primitive = (_null || string || number || boolean);
230
-
231
- return primitive;
232
- }
233
-
234
- function deleteElement(array, element) {
235
- const deletedElement = element; ///
236
-
237
- array = array.reduce((array, element) => { ///
238
- if (element !== deletedElement) {
239
- array.push(element);
240
- }
241
-
242
- return array;
243
- }, []);
244
-
245
- return array;
246
- }
247
-
248
- function deleteKey(object, key) {
249
- const deletedKey = key, ///
250
- keys = Object.keys(object),
251
- values = Object.values(object);
252
-
253
- object = keys.reduce((object, key, index) => { ///
254
- if (key !== deletedKey) {
255
- const value = values[index];
256
-
257
- object[key] = value;
258
- }
259
-
260
- return object;
261
- }, {});
262
-
263
- return object;
264
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- import { BREAKING_VERSION_CHANGE, ADDITIVE_VERSION_CHANGE, COSMETIC_VERSION_CHANGE } from "../versionChanges";
4
-
5
- function updateVersion(version, versionChange) {
6
- switch (versionChange) {
7
- case BREAKING_VERSION_CHANGE:
8
- version.bumpMajorNumber();
9
- version.resetMinorNumber();
10
- version.resetPatchNumber();
11
-
12
- break;
13
-
14
- case ADDITIVE_VERSION_CHANGE:
15
- version.bumpMinorNumber();
16
- version.resetPatchNumber();
17
-
18
- break;
19
-
20
- case COSMETIC_VERSION_CHANGE:
21
- version.bumpPatchNumber();
22
-
23
- break;
24
- }
25
- }
26
-
27
- export default {
28
- updateVersion
29
- };
30
-
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- export const BREAKING_VERSION_CHANGE = "breaking";
4
- export const ADDITIVE_VERSION_CHANGE = "additive";
5
- export const COSMETIC_VERSION_CHANGE = "cosmetic";
6
-
7
- export default {
8
- BREAKING_VERSION_CHANGE,
9
- ADDITIVE_VERSION_CHANGE,
10
- COSMETIC_VERSION_CHANGE
11
- };