occam-verify-cli 1.0.448 → 1.0.472

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 (222) hide show
  1. package/lib/constants.js +13 -5
  2. package/lib/context/ephemeral.js +270 -0
  3. package/lib/context/file.js +136 -128
  4. package/lib/context/liminal.js +120 -0
  5. package/lib/context/literal.js +92 -0
  6. package/lib/context/nominal.js +15 -1
  7. package/lib/context/release.js +68 -9
  8. package/lib/context/scoped.js +322 -0
  9. package/lib/context/synthetic.js +133 -0
  10. package/lib/element/assertion/contained.js +66 -66
  11. package/lib/element/assertion/defined.js +32 -32
  12. package/lib/element/assertion/property.js +39 -39
  13. package/lib/element/assertion/satisfies.js +22 -22
  14. package/lib/element/assumption.js +71 -87
  15. package/lib/element/combinator/bracketed.js +1 -10
  16. package/lib/element/conclusion.js +19 -15
  17. package/lib/element/constructor/bracketed.js +1 -10
  18. package/lib/element/constructor.js +2 -2
  19. package/lib/element/declaration/combinator.js +1 -2
  20. package/lib/element/declaration/metavariable.js +3 -3
  21. package/lib/element/declaration/variable.js +3 -3
  22. package/lib/element/deduction.js +26 -20
  23. package/lib/element/derivation.js +3 -3
  24. package/lib/element/equality.js +5 -5
  25. package/lib/element/equivalence.js +112 -107
  26. package/lib/element/equivalences.js +24 -10
  27. package/lib/element/error.js +3 -3
  28. package/lib/element/frame.js +73 -62
  29. package/lib/element/hypothesis.js +2 -2
  30. package/lib/element/judgement.js +40 -60
  31. package/lib/element/metaType.js +4 -4
  32. package/lib/element/metavariable.js +49 -38
  33. package/lib/element/parameter.js +13 -5
  34. package/lib/element/procedureCall.js +16 -16
  35. package/lib/element/proof.js +14 -13
  36. package/lib/element/proofAssertion/premise.js +319 -0
  37. package/lib/element/proofAssertion/step.js +309 -0
  38. package/lib/element/proofAssertion/supposition.js +333 -0
  39. package/lib/element/proofAssertion.js +20 -10
  40. package/lib/element/propertyRelation.js +2 -2
  41. package/lib/element/reference.js +72 -30
  42. package/lib/element/rule.js +26 -28
  43. package/lib/element/section.js +5 -5
  44. package/lib/element/signature.js +9 -6
  45. package/lib/element/statement.js +44 -36
  46. package/lib/element/subproof.js +18 -17
  47. package/lib/element/substitution/frame.js +86 -49
  48. package/lib/element/substitution/reference.js +101 -19
  49. package/lib/element/substitution/statement.js +128 -105
  50. package/lib/element/substitution/term.js +93 -57
  51. package/lib/element/substitution.js +20 -69
  52. package/lib/element/substitutions.js +49 -34
  53. package/lib/element/term.js +41 -30
  54. package/lib/element/topLevelAssertion/axiom.js +331 -0
  55. package/lib/element/{conjecture.js → topLevelAssertion/conjecture.js} +10 -10
  56. package/lib/element/{lemma.js → topLevelAssertion/lemma.js} +9 -9
  57. package/lib/element/{theorem.js → topLevelAssertion/theorem.js} +8 -8
  58. package/lib/element/topLevelAssertion.js +434 -0
  59. package/lib/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +8 -8
  60. package/lib/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +8 -8
  61. package/lib/element/topLevelMetaAssertion.js +293 -0
  62. package/lib/element/type.js +4 -4
  63. package/lib/element/variable.js +48 -40
  64. package/lib/index.js +3 -3
  65. package/lib/main.js +3 -3
  66. package/lib/metaTypes.js +18 -15
  67. package/lib/node/frame.js +2 -2
  68. package/lib/node/metavariable.js +4 -4
  69. package/lib/node/parameter.js +28 -7
  70. package/lib/node/proofAssertion/premise.js +116 -0
  71. package/lib/node/proofAssertion/step.js +152 -0
  72. package/lib/node/proofAssertion/supposition.js +116 -0
  73. package/lib/node/{premise.js → proofAssertion.js} +11 -18
  74. package/lib/node/statement.js +2 -2
  75. package/lib/node/substitution/frame.js +9 -31
  76. package/lib/node/substitution/reference.js +137 -0
  77. package/lib/node/substitution/statement.js +9 -31
  78. package/lib/node/substitution/term.js +9 -23
  79. package/lib/node/{axiom.js → topLevelAssertion/axiom.js} +7 -7
  80. package/lib/node/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
  81. package/lib/node/{lemma.js → topLevelAssertion/lemma.js} +7 -7
  82. package/lib/node/{theorem.js → topLevelAssertion/theorem.js} +7 -7
  83. package/lib/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +9 -9
  84. package/lib/node/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
  85. package/lib/node/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
  86. package/lib/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +9 -9
  87. package/lib/nonTerminalNodeMap.js +15 -14
  88. package/lib/preamble.js +10 -10
  89. package/lib/process/instantiate.js +6 -21
  90. package/lib/process/unify.js +11 -10
  91. package/lib/tokenTypes.js +22 -0
  92. package/lib/types.js +3 -3
  93. package/lib/utilities/bnf.js +5 -5
  94. package/lib/utilities/context.js +63 -0
  95. package/lib/utilities/element.js +235 -408
  96. package/lib/utilities/instance.js +12 -34
  97. package/lib/utilities/json.js +3 -2
  98. package/lib/utilities/string.js +56 -21
  99. package/lib/utilities/unification.js +38 -32
  100. package/lib/utilities/validation.js +47 -50
  101. package/package.json +2 -2
  102. package/src/constants.js +12 -1
  103. package/src/context/ephemeral.js +257 -0
  104. package/src/context/file.js +108 -116
  105. package/src/context/liminal.js +67 -0
  106. package/src/context/literal.js +51 -0
  107. package/src/context/nominal.js +12 -0
  108. package/src/context/release.js +48 -8
  109. package/src/context/{local.js → scoped.js} +43 -125
  110. package/src/context/synthetic.js +60 -0
  111. package/src/element/assertion/contained.js +49 -47
  112. package/src/element/assertion/defined.js +29 -27
  113. package/src/element/assertion/property.js +35 -35
  114. package/src/element/assertion/satisfies.js +19 -18
  115. package/src/element/assumption.js +71 -93
  116. package/src/element/combinator/bracketed.js +0 -7
  117. package/src/element/conclusion.js +25 -24
  118. package/src/element/constructor/bracketed.js +0 -7
  119. package/src/element/constructor.js +1 -1
  120. package/src/element/declaration/combinator.js +0 -1
  121. package/src/element/declaration/metavariable.js +2 -2
  122. package/src/element/declaration/variable.js +5 -5
  123. package/src/element/deduction.js +33 -31
  124. package/src/element/derivation.js +2 -2
  125. package/src/element/equality.js +4 -4
  126. package/src/element/equivalence.js +115 -135
  127. package/src/element/equivalences.js +9 -7
  128. package/src/element/error.js +4 -2
  129. package/src/element/frame.js +80 -65
  130. package/src/element/hypothesis.js +1 -1
  131. package/src/element/judgement.js +42 -62
  132. package/src/element/metaType.js +3 -4
  133. package/src/element/metavariable.js +59 -56
  134. package/src/element/parameter.js +10 -5
  135. package/src/element/procedureCall.js +20 -18
  136. package/src/element/proof.js +14 -16
  137. package/src/element/{premise.js → proofAssertion/premise.js} +57 -53
  138. package/src/element/{step.js → proofAssertion/step.js} +59 -62
  139. package/src/element/{supposition.js → proofAssertion/supposition.js} +67 -56
  140. package/src/element/proofAssertion.js +24 -13
  141. package/src/element/propertyRelation.js +1 -1
  142. package/src/element/reference.js +87 -37
  143. package/src/element/rule.js +31 -37
  144. package/src/element/section.js +5 -5
  145. package/src/element/signature.js +8 -8
  146. package/src/element/statement.js +52 -48
  147. package/src/element/subproof.js +16 -18
  148. package/src/element/substitution/frame.js +104 -50
  149. package/src/element/substitution/reference.js +120 -20
  150. package/src/element/substitution/statement.js +169 -130
  151. package/src/element/substitution/term.js +104 -63
  152. package/src/element/substitution.js +16 -58
  153. package/src/element/substitutions.js +43 -41
  154. package/src/element/term.js +47 -41
  155. package/src/element/{axiom.js → topLevelAssertion/axiom.js} +22 -20
  156. package/src/element/{conjecture.js → topLevelAssertion/conjecture.js} +5 -6
  157. package/src/element/{lemma.js → topLevelAssertion/lemma.js} +5 -6
  158. package/src/element/{theorem.js → topLevelAssertion/theorem.js} +5 -5
  159. package/src/element/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +37 -33
  160. package/src/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +5 -6
  161. package/src/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +5 -6
  162. package/src/element/{metaLemmaMetatheorem.js → topLevelMetaAssertion.js} +19 -17
  163. package/src/element/type.js +2 -4
  164. package/src/element/variable.js +47 -48
  165. package/src/index.js +2 -1
  166. package/src/main.js +2 -1
  167. package/src/metaTypes.js +25 -9
  168. package/src/node/frame.js +1 -1
  169. package/src/node/metavariable.js +3 -3
  170. package/src/node/parameter.js +32 -5
  171. package/src/node/proofAssertion/premise.js +16 -0
  172. package/src/node/{step.js → proofAssertion/step.js} +4 -18
  173. package/src/node/proofAssertion/supposition.js +16 -0
  174. package/src/node/proofAssertion.js +23 -0
  175. package/src/node/statement.js +1 -1
  176. package/src/node/substitution/frame.js +6 -32
  177. package/src/node/substitution/reference.js +38 -0
  178. package/src/node/substitution/statement.js +6 -32
  179. package/src/node/substitution/term.js +6 -22
  180. package/src/node/topLevelAssertion/axiom.js +13 -0
  181. package/src/node/topLevelAssertion/conjecture.js +13 -0
  182. package/src/node/topLevelAssertion/lemma.js +13 -0
  183. package/src/node/topLevelAssertion/theorem.js +13 -0
  184. package/src/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +1 -1
  185. package/src/node/topLevelMetaAssertion/metaLemma.js +13 -0
  186. package/src/node/topLevelMetaAssertion/metatheorem.js +13 -0
  187. package/src/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +1 -1
  188. package/src/nonTerminalNodeMap.js +15 -12
  189. package/src/preamble.js +9 -9
  190. package/src/process/instantiate.js +27 -36
  191. package/src/process/unify.js +10 -9
  192. package/src/tokenTypes.js +4 -0
  193. package/src/types.js +4 -2
  194. package/src/utilities/bnf.js +3 -2
  195. package/src/utilities/context.js +46 -0
  196. package/src/utilities/element.js +302 -509
  197. package/src/utilities/instance.js +19 -42
  198. package/src/utilities/json.js +3 -1
  199. package/src/utilities/string.js +69 -28
  200. package/src/utilities/unification.js +41 -38
  201. package/src/utilities/validation.js +66 -75
  202. package/lib/context/local.js +0 -605
  203. package/lib/context/temporary.js +0 -752
  204. package/lib/element/axiom.js +0 -329
  205. package/lib/element/axiomLemmaTheoremConjecture.js +0 -427
  206. package/lib/element/metaLemmaMetatheorem.js +0 -289
  207. package/lib/element/premise.js +0 -307
  208. package/lib/element/step.js +0 -311
  209. package/lib/element/supposition.js +0 -320
  210. package/lib/log.js +0 -150
  211. package/lib/node/step.js +0 -166
  212. package/lib/node/supposition.js +0 -130
  213. package/src/context/temporary.js +0 -476
  214. package/src/log.js +0 -118
  215. package/src/node/axiom.js +0 -13
  216. package/src/node/conjecture.js +0 -13
  217. package/src/node/lemma.js +0 -13
  218. package/src/node/metaLemma.js +0 -13
  219. package/src/node/metatheorem.js +0 -13
  220. package/src/node/premise.js +0 -30
  221. package/src/node/supposition.js +0 -30
  222. package/src/node/theorem.js +0 -13
@@ -2,9 +2,9 @@
2
2
 
3
3
  import elements from "../elements";
4
4
 
5
+ import { bracketedConstructorFromNothing, bracketedCombinatorFromNothing } from "../utilities/instance";
5
6
  import { equalityFromStatement,
6
7
  judgementFromStatement,
7
- metavariableFromStatement,
8
8
  typeAssertionFromStatement,
9
9
  definedAssertionFromStatement,
10
10
  propertyAssertionFromStatement,
@@ -12,15 +12,38 @@ import { equalityFromStatement,
12
12
  containedAssertionFromStatement,
13
13
  satisfiesAssertionFromStatement } from "../utilities/statement";
14
14
 
15
- function unifyTermWithBracketedConstructor(term, context, validateAhead) {
16
- let termUnifiesWithBracketedConstructor;
15
+ function validateTermAsVariable(term, context, validateAhead) {
16
+ let termValidatesAsVariable = false;
17
17
 
18
- const { BracketedConstructor } = elements,
19
- bracketedConstructor = BracketedConstructor.fromNothing();
18
+ const termNode = term.getNode(),
19
+ variableNode = termNode.getVariableNode();
20
20
 
21
- termUnifiesWithBracketedConstructor = bracketedConstructor.unifyTerm(term, context, validateAhead);
21
+ if (variableNode !== null) {
22
+ const termString = term.getString();
22
23
 
23
- return termUnifiesWithBracketedConstructor;
24
+ context.trace(`Validating the '${termString}' term as a variable...`);
25
+
26
+ const variableIdentifier = variableNode.getVariableIdentifier(),
27
+ variable = context.findVariableByVariableIdentifier(variableIdentifier);
28
+
29
+ if (variable !== null) {
30
+ const type = variable.getType();
31
+
32
+ term.setType(type);
33
+
34
+ const verifiesAhead = validateAhead();
35
+
36
+ if (verifiesAhead) {
37
+ termValidatesAsVariable = true;
38
+ }
39
+ }
40
+
41
+ if (termValidatesAsVariable) {
42
+ context.debug(`...validated the '${termString}' term as a variable.`);
43
+ }
44
+ }
45
+
46
+ return termValidatesAsVariable;
24
47
  }
25
48
 
26
49
  function unifyTermWithConstructors(term, context, validateAhead) {
@@ -39,62 +62,33 @@ function unifyTermWithConstructors(term, context, validateAhead) {
39
62
  return termUnifiesWithConstructors;
40
63
  }
41
64
 
42
- function validateTermAsVariable(term, context, validateAhead) {
43
- let termValidatesAsVariable = false;
44
-
45
- const { Variable } = elements,
46
- termNode = term.getNode(),
47
- singularVariableNode = termNode.getSingularVariableNode();
48
-
49
- if (singularVariableNode !== null) {
50
- let variable;
51
-
52
- const termString = term.getString(),
53
- variableNode = singularVariableNode; ///
54
-
55
- variable = Variable.fromVariableNode(variableNode, context);
56
-
57
- context.trace(`Verifying the '${termString}' term as a variable...`);
58
-
59
- const variableValidates = variable.validate(context);
60
-
61
- if (variableValidates) {
62
- let verifiesAhead;
63
-
64
- const variableIdentifier = variable.getIdentifier();
65
-
66
- variable = context.findVariableByVariableIdentifier(variableIdentifier);
67
-
68
- const type = variable.getType();
69
-
70
- term.setType(type);
71
-
72
- verifiesAhead = validateAhead();
65
+ function unifyTermWithBracketedConstructor(term, context, validateAhead) {
66
+ let termUnifiesWithBracketedConstructor;
73
67
 
74
- termValidatesAsVariable = verifiesAhead; ///
75
- }
68
+ const bracketedConstructor = bracketedConstructorFromNothing();
76
69
 
77
- if (termValidatesAsVariable) {
78
- context.debug(`...verified the '${termString}' term as a variable.`);
79
- }
80
- }
70
+ termUnifiesWithBracketedConstructor = bracketedConstructor.unifyTerm(term, context, validateAhead);
81
71
 
82
- return termValidatesAsVariable;
72
+ return termUnifiesWithBracketedConstructor;
83
73
  }
84
74
 
85
- function validateStatementAsMetavariableAndSubstitution(statement, assignments, stated, context) {
75
+ function validateStatementAsMetavariable(statement, assignments, stated, context) {
86
76
  let statementValidatesAsMetavariableAndSubstitution = false;
87
77
 
88
- const metavariable = metavariableFromStatement(statement, context);
78
+ const statementNode = statement.getNode(),
79
+ metavariableNode = statementNode.getMetavariableNode();
89
80
 
90
- if (metavariable !== null) {
81
+ if (metavariableNode !== null) {
91
82
  const statementString = statement.getString();
92
83
 
93
- context.trace(`Validating the '${statementString}' statement as a metavariable and substitution...`);
84
+ context.trace(`Validating the '${statementString}' statement as a metavariable...`);
94
85
 
95
- const metavariableValidates = metavariable.validate(context);
86
+ const metavariableName = metavariableNode.getMetavariableName(),
87
+ metavariable = context.findMetavariableByMetavariableName(metavariableName);
88
+
89
+ if (metavariable !== null) {
90
+ statementValidatesAsMetavariableAndSubstitution = true;
96
91
 
97
- if (metavariableValidates) {
98
92
  const { TermSubstitution, FrameSubstitution } = elements,
99
93
  frameSubstitution = FrameSubstitution.fromStatement(statement, context),
100
94
  termSubstitution = TermSubstitution.fromStatement(statement, context),
@@ -103,49 +97,46 @@ function validateStatementAsMetavariableAndSubstitution(statement, assignments,
103
97
  if (substitution !== null) {
104
98
  const substitutionValidates = substitution.validate(context);
105
99
 
106
- if (substitutionValidates) {
107
- statementValidatesAsMetavariableAndSubstitution = true;
100
+ if (!substitutionValidates) {
101
+ statementValidatesAsMetavariableAndSubstitution = false;
108
102
  }
109
- } else {
110
- statementValidatesAsMetavariableAndSubstitution = true;
111
103
  }
112
104
  }
113
105
 
114
106
  if (statementValidatesAsMetavariableAndSubstitution) {
115
- context.debug(`...validated the '${statementString}' statement as a metavariable and substitution.`);
107
+ context.debug(`...validated the '${statementString}' statement as a metavariable.`);
116
108
  }
117
109
  }
118
110
 
119
111
  return statementValidatesAsMetavariableAndSubstitution;
120
112
  }
121
113
 
122
- function unifyStatementWithBracketedCombinator(statement, assignments, stated, context) {
114
+ function unifyStatementWithCombinators(statement, assignments, stated, context) {
123
115
  stated = true; ///
124
116
 
125
117
  assignments = null; ///
126
118
 
127
- const { BracketedCombinator } = elements,
128
- bracketedCombinator = BracketedCombinator.fromNothing(),
129
- statementUnifiesWithBracketedCombinator = bracketedCombinator.unifyStatement(statement, assignments, stated, context);
119
+ const combinators = context.getCombinators(),
120
+ statementUnifiesWithCombinators = combinators.some((combinator) => {
121
+ const unifiesWithCombinator = combinator.unifyStatement(statement, assignments, stated, context);
130
122
 
131
- return statementUnifiesWithBracketedCombinator;
123
+ if (unifiesWithCombinator) {
124
+ return true;
125
+ }
126
+ });
127
+
128
+ return statementUnifiesWithCombinators;
132
129
  }
133
130
 
134
- function unifyStatementWithCombinators(statement, assignments, stated, context) {
131
+ function unifyStatementWithBracketedCombinator(statement, assignments, stated, context) {
135
132
  stated = true; ///
136
133
 
137
134
  assignments = null; ///
138
135
 
139
- const combinators = context.getCombinators(),
140
- statementUnifiesWithCombinators = combinators.some((combinator) => {
141
- const unifiesWithCombinator = combinator.unifyStatement(statement, assignments, stated, context);
142
-
143
- if (unifiesWithCombinator) {
144
- return true;
145
- }
146
- });
136
+ const bracketedCombinator = bracketedCombinatorFromNothing(),
137
+ statementUnifiesWithBracketedCombinator = bracketedCombinator.unifyStatement(statement, assignments, stated, context);
147
138
 
148
- return statementUnifiesWithCombinators;
139
+ return statementUnifiesWithBracketedCombinator;
149
140
  }
150
141
 
151
142
  function validateStatementAsEquality(statement, assignments, stated, context) {
@@ -349,15 +340,15 @@ function validateStatementAsSatisfiesAssertion(statement, assignments, stated, c
349
340
  }
350
341
 
351
342
  export const validateTerms = [
352
- unifyTermWithBracketedConstructor,
343
+ validateTermAsVariable,
353
344
  unifyTermWithConstructors,
354
- validateTermAsVariable
345
+ unifyTermWithBracketedConstructor
355
346
  ];
356
347
 
357
348
  export const validateStatements = [
358
- validateStatementAsMetavariableAndSubstitution,
359
- unifyStatementWithBracketedCombinator,
349
+ validateStatementAsMetavariable,
360
350
  unifyStatementWithCombinators,
351
+ unifyStatementWithBracketedCombinator,
361
352
  validateStatementAsEquality,
362
353
  validateStatementAsJudgement,
363
354
  validateStatementAsTypeAssertion,