occam-verify-cli 0.0.531 → 0.0.533

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 (53) hide show
  1. package/bin/utilities/releaseContext.js +3 -3
  2. package/lib/assertion.js +60 -0
  3. package/lib/axiom.js +3 -3
  4. package/lib/axiomLemmaTheoremConjecture.js +5 -5
  5. package/lib/combinator.js +3 -3
  6. package/lib/conclusion.js +3 -3
  7. package/lib/conjecture.js +3 -3
  8. package/lib/consequence.js +3 -3
  9. package/lib/constants.js +1 -5
  10. package/lib/constructor.js +5 -5
  11. package/lib/context/file.js +3 -2
  12. package/lib/context/proof.js +1 -20
  13. package/lib/context/release/file.js +10 -10
  14. package/lib/equality.js +61 -29
  15. package/lib/label.js +3 -3
  16. package/lib/lemma.js +3 -3
  17. package/lib/premise.js +3 -3
  18. package/lib/rule.js +5 -5
  19. package/lib/supposition.js +3 -3
  20. package/lib/theorem.js +3 -3
  21. package/lib/type.js +6 -6
  22. package/lib/utilities/node.js +3 -3
  23. package/lib/variable.js +23 -3
  24. package/lib/verify/assertion/type.js +56 -68
  25. package/lib/verify/statement.js +83 -28
  26. package/package.json +1 -1
  27. package/src/{assertion/type.js → assertion.js} +3 -3
  28. package/src/axiom.js +1 -1
  29. package/src/axiomLemmaTheoremConjecture.js +4 -4
  30. package/src/combinator.js +3 -1
  31. package/src/conclusion.js +3 -1
  32. package/src/conjecture.js +1 -1
  33. package/src/consequence.js +3 -1
  34. package/src/constants.js +0 -1
  35. package/src/constructor.js +5 -3
  36. package/src/context/file.js +3 -1
  37. package/src/context/proof.js +0 -25
  38. package/src/context/release/file.js +10 -11
  39. package/src/equality.js +35 -39
  40. package/src/label.js +3 -1
  41. package/src/lemma.js +1 -1
  42. package/src/premise.js +3 -1
  43. package/src/rule.js +4 -4
  44. package/src/supposition.js +3 -1
  45. package/src/theorem.js +1 -1
  46. package/src/type.js +5 -5
  47. package/src/utilities/node.js +3 -2
  48. package/src/variable.js +18 -2
  49. package/src/verify/assertion/type.js +83 -82
  50. package/src/verify/statement.js +76 -22
  51. package/lib/assertion/type.js +0 -60
  52. package/lib/node/statement/equality.js +0 -16
  53. package/src/node/statement/equality.js +0 -10
@@ -1,19 +1,25 @@
1
1
  "use strict";
2
2
 
3
- import Equality from "../equality";
3
+ import Variable from "../variable";
4
+ import Assertion from "../assertion";
4
5
  import verifyTerm from "../verify/term";
6
+ import equalityCombinator from "../ocmbinator/equality";
5
7
  import bracketedCombinator from "../ocmbinator/bracketed";
6
8
  import verifyTypeAssertion from "../verify/assertion/type";
7
9
 
8
10
  import { first } from "../utilities/array";
9
11
  import { objectType } from "../type";
12
+ import { nodeAsString } from "../utilities/string";
10
13
  import { OBJECT_TYPE_NAME } from "../typeNames";
11
14
  import { STATEMENT_META_TYPE } from "../metaTypes";
15
+ import { verifyTermAsVariable } from "../verify/term";
12
16
  import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
13
17
  import { ARGUMENT_RULE_NAME, META_ARGUMENT_RULE_NAME } from "../ruleNames";
14
18
 
15
19
  const termNodeQuery = nodeQuery("/argument/term!"),
16
20
  typeNodeQuery = nodeQuery("/argument/type!"),
21
+ leftTermNodeQuery = nodeQuery("/statement/argument[0]/term!"),
22
+ rightTermNodeQuery = nodeQuery("/statement/argument[1]/term!"),
17
23
  metaTypeNodeQuery = nodeQuery("/metaArgument/metaType!"),
18
24
  statementNodeQuery = nodeQuery("/metaArgument/statement!"),
19
25
  typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!"),
@@ -35,7 +41,7 @@ export default function verifyStatement(statementNode, assertions, derived, cont
35
41
  }
36
42
 
37
43
  if (!statementVerified) {
38
- const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode, derived, context);
44
+ const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode, assertions, derived, context);
39
45
 
40
46
  statementVerified = statementVerifiedAsEquality; //
41
47
  }
@@ -43,16 +49,6 @@ export default function verifyStatement(statementNode, assertions, derived, cont
43
49
  return statementVerified;
44
50
  }
45
51
 
46
- export function verifyStatementAgainstCombinator(statementNode, combinator, context) {
47
- const combinatorStatementNode = combinator.getStatementNode(),
48
- node = statementNode, ///
49
- combinatorNode = combinatorStatementNode, ///
50
- nodeVerified = verifyNode(node, combinatorNode, context),
51
- statementVerifiedAgainstCombinator = nodeVerified; ///
52
-
53
- return statementVerifiedAgainstCombinator;
54
- }
55
-
56
52
  function verifyStatementAgainstCombinators(statementNode, context) {
57
53
  let statementVerifiedAgainstCombinators = false;
58
54
 
@@ -78,6 +74,16 @@ function verifyStatementAgainstCombinators(statementNode, context) {
78
74
  return statementVerifiedAgainstCombinators;
79
75
  }
80
76
 
77
+ function verifyStatementAgainstCombinator(statementNode, combinator, context) {
78
+ const combinatorStatementNode = combinator.getStatementNode(),
79
+ node = statementNode, ///
80
+ combinatorNode = combinatorStatementNode, ///
81
+ nodeVerified = verifyNode(node, combinatorNode, context),
82
+ statementVerifiedAgainstCombinator = nodeVerified; ///
83
+
84
+ return statementVerifiedAgainstCombinator;
85
+ }
86
+
81
87
  function verifyStatementAsTypeAssertion(statementNode, assertions, derived, context) {
82
88
  let statementVerifiedAsTypeAssertion = false;
83
89
 
@@ -92,25 +98,73 @@ function verifyStatementAsTypeAssertion(statementNode, assertions, derived, cont
92
98
  return statementVerifiedAsTypeAssertion;
93
99
  }
94
100
 
95
- function verifyStatementAsEquality(statementNode, derived, context) {
101
+ function verifyStatementAsEquality(statementNode, assertions, derived, context) {
96
102
  let statementVerifiedAsEquality = false;
97
103
 
98
- const equality = Equality.fromStatementNode(statementNode, context);
104
+ const statementString = context.nodeAsString(statementNode);
99
105
 
100
- if (equality !== null) {
101
- statementVerifiedAsEquality = true; ///
106
+ const combinator = equalityCombinator, ///
107
+ statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context);
102
108
 
109
+ if (statementVerifiedAgainstCombinator) {
103
110
  if (derived) {
104
- const equalities = context.getEqualities();
105
-
106
- if (equalities !== null) {
107
- const equalityEquates = equality.equate(equalities, context);
108
-
109
- statementVerifiedAsEquality = equalityEquates; ///
111
+ debugger
112
+ } else {
113
+ const types = [],
114
+ variables = [],
115
+ leftTermNode = leftTermNodeQuery(statementNode),
116
+ rightTermNode = rightTermNodeQuery(statementNode),
117
+ leftTermVerifiedAsVariable = verifyTermAsVariable(leftTermNode, variables, context);
118
+
119
+ if (leftTermVerifiedAsVariable) {
120
+ verifyTerm(rightTermNode, types, context);
121
+
122
+ const firstVariable = first(variables),
123
+ leftVariable = firstVariable, ///
124
+ firstType = first(types),
125
+ rightTermType = firstType, ///
126
+ leftVariableType = leftVariable.getType(),
127
+ leftVariableName = leftVariable.getName(),
128
+ leftVariableTypeEqualToOrSuperTypeOfRightTermType = leftVariableType.isEqualToOrSuperTypeOf(rightTermType);
129
+
130
+ if (!leftVariableTypeEqualToOrSuperTypeOfRightTermType) {
131
+ const rightTermString = nodeAsString(rightTermNode),
132
+ rightTermTypeName = rightTermType.getName(),
133
+ leftVariableTypeName = leftVariableType.getName();
134
+
135
+ 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);
136
+ } else {
137
+ const type = leftVariableType, ///
138
+ name = leftVariableName, ///
139
+ termNode = rightTermNode, ///
140
+ variable = Variable.fromTypeNameAndTermNode(type, name, termNode),
141
+ assertion = Assertion.fromVariable(variable);
142
+
143
+ assertions.push(assertion);
144
+
145
+ statementVerifiedAsEquality = true;
146
+ }
147
+ } else {
148
+ const rightTermVerifiedAsVariable = verifyTermAsVariable(rightTermNode, variables, context);
149
+
150
+ if (rightTermVerifiedAsVariable) {
151
+ const firstVariable = first(variables),
152
+ rightVariable = firstVariable, ///
153
+ leftTermString = nodeAsString(leftTermNode),
154
+ rightVariableName = rightVariable.getName();
155
+
156
+ context.error(`The left '${leftTermString}' term cannot be equated with the right '${rightVariableName}' variable.`, statementNode);
157
+ } else {
158
+ statementVerifiedAsEquality = true;
159
+ }
110
160
  }
111
161
  }
112
162
  }
113
163
 
164
+ if (statementVerifiedAsEquality) {
165
+ context.info(`Verified the '${statementString}' statement as an equality.`, statementNode);
166
+ }
167
+
114
168
  return statementVerifiedAsEquality;
115
169
  }
116
170
 
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return TypeAssertion;
9
- }
10
- });
11
- function _classCallCheck(instance, Constructor) {
12
- if (!(instance instanceof Constructor)) {
13
- throw new TypeError("Cannot call a class as a function");
14
- }
15
- }
16
- function _defineProperties(target, props) {
17
- for(var i = 0; i < props.length; i++){
18
- var descriptor = props[i];
19
- descriptor.enumerable = descriptor.enumerable || false;
20
- descriptor.configurable = true;
21
- if ("value" in descriptor) descriptor.writable = true;
22
- Object.defineProperty(target, descriptor.key, descriptor);
23
- }
24
- }
25
- function _createClass(Constructor, protoProps, staticProps) {
26
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
- if (staticProps) _defineProperties(Constructor, staticProps);
28
- return Constructor;
29
- }
30
- var TypeAssertion = /*#__PURE__*/ function() {
31
- function TypeAssertion(variable) {
32
- _classCallCheck(this, TypeAssertion);
33
- this.variable = variable;
34
- }
35
- _createClass(TypeAssertion, [
36
- {
37
- key: "getVariable",
38
- value: function getVariable() {
39
- return this.variable;
40
- }
41
- },
42
- {
43
- key: "assert",
44
- value: function assert(proofContext) {
45
- proofContext.addVariable(this.variable);
46
- }
47
- }
48
- ], [
49
- {
50
- key: "fromVariable",
51
- value: function fromVariable(variable) {
52
- var typeAssertion = new TypeAssertion(variable);
53
- return typeAssertion;
54
- }
55
- }
56
- ]);
57
- return TypeAssertion;
58
- }();
59
-
60
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hc3NlcnRpb24vdHlwZS5qcyIsIjw8anN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U9DLFlBQVksRUFBRTtnQkFDbkJBLGFBQWFDLFdBQVcsQ0FBQyxJQUFJLENBQUNKLFFBQVE7WUFDeEM7Ozs7WUFFT0ssS0FBQUE7bUJBQVAsU0FBT0EsYUFBYUwsUUFBUSxFQUFFO2dCQUM1QixJQUFNTSxnQkFBZ0IsSUFkTFAsY0FjdUJDO2dCQUV4QyxPQUFPTTtZQUNUOzs7V0FqQm1CUCJ9
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
9
- }
10
- });
11
- var _node = require("../../utilities/node");
12
- var equalityStatementString = "n=m";
13
- var equalityStatementNode = (0, _node.statementNodeFromStatementString)(equalityStatementString);
14
- var _default = equalityStatementNode;
15
-
16
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9ub2RlL3N0YXRlbWVudC9lcXVhbGl0eS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHsgc3RhdGVtZW50Tm9kZUZyb21TdGF0ZW1lbnRTdHJpbmcgfSBmcm9tIFwiLi4vLi4vdXRpbGl0aWVzL25vZGVcIjtcblxuY29uc3QgZXF1YWxpdHlTdGF0ZW1lbnRTdHJpbmcgPSBcIm49bVwiO1xuXG5jb25zdCBlcXVhbGl0eVN0YXRlbWVudE5vZGUgPSBzdGF0ZW1lbnROb2RlRnJvbVN0YXRlbWVudFN0cmluZyhlcXVhbGl0eVN0YXRlbWVudFN0cmluZyk7XG5cbmV4cG9ydCBkZWZhdWx0IGVxdWFsaXR5U3RhdGVtZW50Tm9kZTtcblxuIl0sIm5hbWVzIjpbImVxdWFsaXR5U3RhdGVtZW50U3RyaW5nIiwiZXF1YWxpdHlTdGF0ZW1lbnROb2RlIiwic3RhdGVtZW50Tm9kZUZyb21TdGF0ZW1lbnRTdHJpbmciXSwibWFwcGluZ3MiOiJBQUFBOzs7OytCQVFBOzs7ZUFBQTs7O29CQU5pRDtBQUVqRCxJQUFNQSwwQkFBMEI7QUFFaEMsSUFBTUMsd0JBQXdCQyxJQUFBQSxzQ0FBZ0MsRUFBQ0Y7SUFFL0QsV0FBZUMifQ==
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- import { statementNodeFromStatementString } from "../../utilities/node";
4
-
5
- const equalityStatementString = "n=m";
6
-
7
- const equalityStatementNode = statementNodeFromStatementString(equalityStatementString);
8
-
9
- export default equalityStatementNode;
10
-