occam-verify-cli 0.0.1067 → 0.0.1069

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 (137) hide show
  1. package/bin/action/verify.js +3 -2
  2. package/lib/assertion/contained.js +2 -2
  3. package/lib/assertion/defined.js +2 -2
  4. package/lib/assertion/subproof.js +3 -3
  5. package/lib/assignment/judgement.js +3 -3
  6. package/lib/axiom.js +11 -6
  7. package/lib/combinator.js +9 -9
  8. package/lib/conclusion.js +13 -10
  9. package/lib/conjecture.js +11 -6
  10. package/lib/consequent.js +13 -10
  11. package/lib/constructor.js +9 -9
  12. package/lib/context/file.js +34 -126
  13. package/lib/context/local.js +16 -5
  14. package/lib/context/release.js +2 -3
  15. package/lib/declaration.js +96 -2
  16. package/lib/equivalence.js +2 -2
  17. package/lib/frame.js +179 -98
  18. package/lib/index.js +22 -6
  19. package/lib/judgement.js +84 -5
  20. package/lib/label.js +12 -8
  21. package/lib/lemma.js +12 -12
  22. package/lib/metaLemma.js +120 -8
  23. package/lib/metaType.js +24 -3
  24. package/lib/metatheorem.js +145 -9
  25. package/lib/metavariable.js +128 -43
  26. package/lib/mixins/statement/qualified/unify.js +6 -10
  27. package/lib/mixins/statement/unify.js +4 -19
  28. package/lib/mixins/statement/verify.js +13 -13
  29. package/lib/mixins/term/unify.js +2 -2
  30. package/lib/premise.js +21 -13
  31. package/lib/reference.js +17 -17
  32. package/lib/rule.js +28 -40
  33. package/lib/statement/unqualified.js +34 -9
  34. package/lib/statement.js +7 -5
  35. package/lib/substitution/frameForMetavariable.js +75 -70
  36. package/lib/substitution/statementForMetavariable.js +83 -42
  37. package/lib/substitution/termForVariable.js +65 -68
  38. package/lib/substitution.js +46 -43
  39. package/lib/substitutions.js +52 -40
  40. package/lib/supposition.js +15 -11
  41. package/lib/term.js +6 -11
  42. package/lib/theorem.js +11 -6
  43. package/lib/topLevelAssertion.js +24 -42
  44. package/lib/type.js +5 -12
  45. package/lib/unifier/intrinsicLevel.js +4 -4
  46. package/lib/unifier/metaLevel.js +11 -7
  47. package/lib/unifier/metavariable.js +6 -6
  48. package/lib/unifier/statementWithCombinator.js +16 -16
  49. package/lib/unifier/termWithConstructor.js +7 -7
  50. package/lib/utilities/brackets.js +10 -10
  51. package/lib/utilities/json.js +493 -0
  52. package/lib/utilities/node.js +26 -19
  53. package/lib/utilities/release.js +53 -0
  54. package/lib/utilities/releaseContext.js +4 -15
  55. package/lib/utilities/tokens.js +8 -1
  56. package/lib/variable.js +14 -15
  57. package/lib/verifier/topLevel.js +5 -5
  58. package/package.json +1 -1
  59. package/src/assertion/contained.js +1 -1
  60. package/src/assertion/defined.js +1 -1
  61. package/src/assertion/subproof.js +2 -3
  62. package/src/assignment/judgement.js +3 -4
  63. package/src/axiom.js +14 -6
  64. package/src/combinator.js +12 -13
  65. package/src/conclusion.js +16 -13
  66. package/src/conjecture.js +14 -6
  67. package/src/consequent.js +16 -13
  68. package/src/constructor.js +11 -13
  69. package/src/context/file.js +94 -202
  70. package/src/context/local.js +8 -6
  71. package/src/context/release.js +2 -3
  72. package/src/declaration.js +126 -45
  73. package/src/equivalence.js +2 -2
  74. package/src/frame.js +225 -141
  75. package/src/index.js +17 -1
  76. package/src/judgement.js +109 -3
  77. package/src/label.js +15 -10
  78. package/src/lemma.js +17 -10
  79. package/src/metaLemma.js +102 -1
  80. package/src/metaType.js +29 -3
  81. package/src/metatheorem.js +143 -2
  82. package/src/metavariable.js +189 -66
  83. package/src/mixins/statement/qualified/unify.js +7 -19
  84. package/src/mixins/statement/unify.js +3 -25
  85. package/src/mixins/statement/verify.js +15 -13
  86. package/src/mixins/term/unify.js +1 -1
  87. package/src/premise.js +31 -16
  88. package/src/reference.js +18 -18
  89. package/src/rule.js +40 -58
  90. package/src/statement/unqualified.js +41 -11
  91. package/src/statement.js +6 -3
  92. package/src/substitution/frameForMetavariable.js +85 -98
  93. package/src/substitution/statementForMetavariable.js +109 -45
  94. package/src/substitution/termForVariable.js +83 -94
  95. package/src/substitution.js +36 -34
  96. package/src/substitutions.js +53 -46
  97. package/src/supposition.js +22 -14
  98. package/src/term.js +5 -15
  99. package/src/theorem.js +14 -6
  100. package/src/topLevelAssertion.js +38 -64
  101. package/src/type.js +5 -20
  102. package/src/unifier/intrinsicLevel.js +4 -3
  103. package/src/unifier/metaLevel.js +19 -7
  104. package/src/unifier/metavariable.js +5 -5
  105. package/src/unifier/statementWithCombinator.js +19 -19
  106. package/src/unifier/termWithConstructor.js +7 -7
  107. package/src/utilities/brackets.js +5 -5
  108. package/src/utilities/json.js +551 -0
  109. package/src/utilities/node.js +28 -23
  110. package/src/{verify → utilities}/release.js +5 -1
  111. package/src/utilities/releaseContext.js +2 -2
  112. package/src/utilities/tokens.js +10 -0
  113. package/src/variable.js +18 -19
  114. package/src/verifier/topLevel.js +6 -4
  115. package/lib/argument.js +0 -106
  116. package/lib/metaTypes.js +0 -19
  117. package/lib/unify/metavariableWithFrame.js +0 -40
  118. package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
  119. package/lib/unify/statementWithSttaemetnGivenEquivalences.js +0 -45
  120. package/lib/verify/declaration.js +0 -83
  121. package/lib/verify/frame.js +0 -120
  122. package/lib/verify/judgement.js +0 -88
  123. package/lib/verify/metaLemma.js +0 -49
  124. package/lib/verify/metatheorem.js +0 -48
  125. package/lib/verify/metavariableGivenMetaType.js +0 -44
  126. package/lib/verify/release.js +0 -50
  127. package/src/argument.js +0 -79
  128. package/src/metaTypes.js +0 -11
  129. package/src/unify/metavariableWithFrame.js +0 -40
  130. package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
  131. package/src/unify/statementWithSttaemetnGivenEquivalences.js +0 -51
  132. package/src/verify/declaration.js +0 -113
  133. package/src/verify/frame.js +0 -157
  134. package/src/verify/judgement.js +0 -127
  135. package/src/verify/metaLemma.js +0 -72
  136. package/src/verify/metatheorem.js +0 -67
  137. package/src/verify/metavariableGivenMetaType.js +0 -45
package/src/lemma.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ import shim from "./shim";
3
4
  import Label from "./label";
4
5
  import Proof from "./proof";
5
6
  import Consequent from "./consequent";
@@ -8,23 +9,24 @@ import LocalContext from "./context/local";
8
9
  import Substitutions from "./substitutions";
9
10
  import TopLevelAssertion from "./topLevelAssertion";
10
11
 
12
+ import { EMPTY_STRING } from "./constants";
13
+ import { stringFromLabels } from "./topLevelAssertion";
11
14
  import { nodeQuery, nodesQuery } from "./utilities/query";
12
- import { labelsStringFromLabels } from "./topLevelAssertion";
13
15
 
14
16
  const proofNodeQuery = nodeQuery("/lemma/proof"),
15
17
  labelNodesQuery = nodesQuery("/lemma/label"),
16
18
  consequentNodeQuery = nodeQuery("/lemma/consequent"),
17
19
  suppositionNodesQuery = nodesQuery("/lemma/supposition");
18
20
 
19
- export default class Lemma extends TopLevelAssertion {
21
+ class Lemma extends TopLevelAssertion {
20
22
  verify() {
21
23
  let verified = false;
22
24
 
23
- const labelsString = labelsStringFromLabels(this.labels);
25
+ const lemmaString = this.string; ///
24
26
 
25
- (labelsString === null) ?
27
+ (lemmaString === EMPTY_STRING) ?
26
28
  this.fileContext.trace(`Verifying a lemma...`) :
27
- this.fileContext.trace(`Verifying the '${labelsString}' lemma...`);
29
+ this.fileContext.trace(`Verifying the '${lemmaString}' lemma...`);
28
30
 
29
31
  const labelsVerifiedAtTopLevel = this.labels.every((label) => {
30
32
  const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
@@ -63,16 +65,14 @@ export default class Lemma extends TopLevelAssertion {
63
65
  }
64
66
 
65
67
  if (verified) {
66
- (labelsString === null) ?
68
+ (lemmaString === EMPTY_STRING) ?
67
69
  this.fileContext.debug(`...verified a lemma.`) :
68
- this.fileContext.debug(`...verified the '${labelsString}' lemma.`);
70
+ this.fileContext.debug(`...verified the '${lemmaString}' lemma.`);
69
71
  }
70
72
 
71
73
  return verified;
72
74
  }
73
75
 
74
- static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Lemma, json, fileContext); }
75
-
76
76
  static fromLemmaNode(lemmaNode, fileContext) {
77
77
  const proofNode = proofNodeQuery(lemmaNode),
78
78
  labelNodes = labelNodesQuery(lemmaNode),
@@ -89,9 +89,16 @@ export default class Lemma extends TopLevelAssertion {
89
89
  return supposition;
90
90
  }),
91
91
  consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
92
+ string = stringFromLabels(labels),
92
93
  proof = Proof.fromProofNode(proofNode, fileContext),
93
- lemma = new Lemma(fileContext, labels, suppositions, consequent, proof);
94
+ lemma = new Lemma(fileContext, string, labels, suppositions, consequent, proof);
94
95
 
95
96
  return lemma;
96
97
  }
97
98
  }
99
+
100
+ Object.assign(shim, {
101
+ Lemma
102
+ });
103
+
104
+ export default Lemma;
package/src/metaLemma.js CHANGED
@@ -1,7 +1,108 @@
1
1
  "use strict";
2
2
 
3
+ import Label from "./label";
4
+ import Proof from "./proof";
5
+ import Consequent from "./consequent";
6
+ import Supposition from "./supposition";
7
+ import LocalContext from "./context/local";
8
+ import Substitutions from "./substitutions";
3
9
  import TopLevelAssertion from "./topLevelAssertion";
4
10
 
11
+ import { EMPTY_STRING } from "./constants";
12
+ import { stringFromLabels } from "./topLevelAssertion";
13
+ import { nodeQuery, nodesQuery } from "./utilities/query";
14
+
15
+ const proofNodeQuery = nodeQuery("/metaLemma/proof"),
16
+ labelNodesQuery = nodesQuery("/metaLemma/label"),
17
+ consequentNodeQuery = nodeQuery("/metaLemma/consequent"),
18
+ suppositionNodesQuery = nodesQuery("/metaLemma/supposition");
19
+
5
20
  export default class MetaLemma extends TopLevelAssertion {
6
- static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return MetaLemma.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Metatheorem, labels, suppositions, consequent, substitutions, fileContext); }
21
+ constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
22
+ super(fileContext, string, labels, suppositions, consequent, proof);
23
+
24
+ this.substitutions = substitutions;
25
+ }
26
+
27
+ getSubstitutions() {
28
+ return this.substitutions;
29
+ }
30
+
31
+ verify() {
32
+ let verified = false;
33
+
34
+ const metaLemmaString = this.string; ///
35
+
36
+ (metaLemmaString === EMPTY_STRING) ?
37
+ this.fileContext.trace(`Verifying a meta-lemma...`) :
38
+ this.fileContext.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
39
+
40
+ const labelsVerifiedAtTopLevel = this.labels.every((label) => {
41
+ const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
42
+
43
+ if (labelVVerifiedAtTopLevel) {
44
+ return true;
45
+ }
46
+ });
47
+
48
+ if (labelsVerifiedAtTopLevel) {
49
+ const localContext = LocalContext.fromFileContext(this.fileContext),
50
+ suppositionsVerified = this.suppositions.every((supposition) => {
51
+ const suppositionVerified = supposition.verify(localContext);
52
+
53
+ if (suppositionVerified) {
54
+ return true;
55
+ }
56
+ });
57
+
58
+ if (suppositionsVerified) {
59
+ const consequentVerified = this.consequent.verify(localContext);
60
+
61
+ if (consequentVerified) {
62
+ const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
63
+
64
+ if (proofVerified) {
65
+ const metaLemma = this; ///
66
+
67
+ this.fileContext.addMetaLemma(metaLemma);
68
+
69
+ verified = true;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ if (verified) {
76
+ (metaLemmaString === EMPTY_STRING) ?
77
+ this.fileContext.debug(`...verified a meta-lemma.`) :
78
+ this.fileContext.debug(`...verified the '${metaLemmaString}' meta-lemma.`);
79
+ }
80
+
81
+ return verified;
82
+ }
83
+
84
+ static fromMetaLemmaNode(metaLemmaNode, fileContext) {
85
+ const proofNode = proofNodeQuery(metaLemmaNode),
86
+ labelNodes = labelNodesQuery(metaLemmaNode),
87
+ consequentNode = consequentNodeQuery(metaLemmaNode),
88
+ suppositionNodes = suppositionNodesQuery(metaLemmaNode),
89
+ labels = labelNodes.map((labelNode) => {
90
+ const label = Label.fromLabelNode(labelNode, fileContext);
91
+
92
+ return label;
93
+ }),
94
+ suppositions = suppositionNodes.map((suppositionNode) => {
95
+ const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
96
+
97
+ return supposition;
98
+ }),
99
+ consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
100
+ proof = Proof.fromProofNode(proofNode, fileContext),
101
+ string = stringFromLabels(labels),
102
+ substitutions = Substitutions.fromNothing(),
103
+ metaLemma = new MetaLemma(fileContext, string, labels, suppositions, consequent, proof, substitutions);
104
+
105
+ return metaLemma;
106
+ }
7
107
  }
108
+
package/src/metaType.js CHANGED
@@ -57,15 +57,15 @@ class MetaType {
57
57
 
58
58
  static fromJSON(json, fileContext) {
59
59
  const { name } = json,
60
- metaType = new MetaType(name);
60
+ metaTypeName = name, ///
61
+ metaType = metaTypeFromMetaTypeName(metaTypeName);
61
62
 
62
63
  return metaType;
63
64
  }
64
65
 
65
66
  static fromMetaTypeNode(metaTypeNode, localContext) {
66
67
  const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
67
- name = metaTypeName, ///
68
- metaType = new MetaType(name);
68
+ metaType = metaTypeFromMetaTypeName(metaTypeName);
69
69
 
70
70
  return metaType;
71
71
  }
@@ -107,3 +107,29 @@ class StatementMetaType extends MetaType {
107
107
  export const frameMetaType = FrameMetaType.fromNothing();
108
108
  export const referenceMetaType = ReferenceMetaType.fromNothing();
109
109
  export const statementMetaType = StatementMetaType.fromNothing();
110
+
111
+ function metaTypeFromMetaTypeName(metaTypeName) {
112
+ let metaType;
113
+
114
+ switch (metaTypeName) {
115
+ case FRAME_META_TYPE_NAME: {
116
+ metaType = frameMetaType; ///
117
+
118
+ break;
119
+ }
120
+
121
+ case REFERENCE_META_TYPE_NAME: {
122
+ metaType = referenceMetaType; ///
123
+
124
+ break;
125
+ }
126
+
127
+ case STATEMENT_META_TYPE_NAME: {
128
+ metaType = statementMetaType; ///
129
+
130
+ break;
131
+ }
132
+ }
133
+
134
+ return metaType;
135
+ }
@@ -1,7 +1,148 @@
1
1
  "use strict";
2
2
 
3
+ import shim from "./shim";
4
+ import Label from "./label";
5
+ import Proof from "./proof";
6
+ import Consequent from "./consequent";
7
+ import Supposition from "./supposition";
8
+ import LocalContext from "./context/local";
9
+ import Substitutions from "./substitutions";
3
10
  import TopLevelAssertion from "./topLevelAssertion";
4
11
 
5
- export default class Metatheorem extends TopLevelAssertion {
6
- static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return TopLevelAssertion.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Metatheorem, labels, suppositions, consequent, substitutions, fileContext); }
12
+ import { nodeQuery, nodesQuery } from "./utilities/query";
13
+ import { stringFromLabels } from "./topLevelAssertion";
14
+ import { labelsFromJSON,
15
+ labelsToLabelsJSON,
16
+ consequentFromJSON,
17
+ suppositionsFromJSON,
18
+ substitutionsFromJSON,
19
+ consequentToConsequentJSON,
20
+ suppositionsToSuppositionsJSON,
21
+ substitutionsToSubstitutionsJSON } from "./utilities/json";
22
+
23
+ const proofNodeQuery = nodeQuery("/metatheorem/proof"),
24
+ labelNodesQuery = nodesQuery("/metatheorem/label"),
25
+ consequentNodeQuery = nodeQuery("/metatheorem/consequent"),
26
+ suppositionNodesQuery = nodesQuery("/metatheorem/supposition");
27
+
28
+ class Metatheorem extends TopLevelAssertion {
29
+ constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
30
+ super(fileContext, string, labels, suppositions, consequent, proof);
31
+
32
+ this.substitutions = substitutions;
33
+ }
34
+
35
+ getSubstitutions() {
36
+ return this.substitutions;
37
+ }
38
+
39
+ verify() {
40
+ let verified = false;
41
+
42
+ const metatheoremString = this.string; ///
43
+
44
+ this.fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
45
+
46
+ const labelsVerifiedAtTopLevel = this.labels.every((label) => {
47
+ const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
48
+
49
+ if (labelVVerifiedAtTopLevel) {
50
+ return true;
51
+ }
52
+ });
53
+
54
+ if (labelsVerifiedAtTopLevel) {
55
+ const localContext = LocalContext.fromFileContext(this.fileContext),
56
+ suppositionsVerified = this.suppositions.every((supposition) => {
57
+ const suppositionVerified = supposition.verify(localContext);
58
+
59
+ if (suppositionVerified) {
60
+ return true;
61
+ }
62
+ });
63
+
64
+ if (suppositionsVerified) {
65
+ const consequentVerified = this.consequent.verify(localContext);
66
+
67
+ if (consequentVerified) {
68
+ const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
69
+
70
+ if (proofVerified) {
71
+ const metatheorem = this; ///
72
+
73
+ this.fileContext.addMetatheorem(metatheorem);
74
+
75
+ verified = true;
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ if (verified) {
82
+ this.fileContext.debug(`...verified the '${metatheoremString}' metatheorem.`);
83
+ }
84
+
85
+ return verified;
86
+ }
87
+
88
+ toJSON() {
89
+ const labelsJSON = labelsToLabelsJSON(this.labels),
90
+ consequentJSON = consequentToConsequentJSON(this.consequent),
91
+ suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
92
+ substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
93
+ labels = labelsJSON, ///
94
+ consequent = consequentJSON, ///
95
+ suppositions = suppositionsJSON, ///
96
+ substitutions = substitutionsJSON, ///
97
+ json = {
98
+ labels,
99
+ consequent,
100
+ suppositions,
101
+ substitutions
102
+ };
103
+
104
+ return json;
105
+ }
106
+
107
+ static fromJSON(json, fileContext) {
108
+ const labels = labelsFromJSON(json, fileContext),
109
+ consequent = consequentFromJSON(json, fileContext),
110
+ suppositions = suppositionsFromJSON(json, fileContext),
111
+ substitutions = substitutionsFromJSON(json, fileContext),
112
+ string = stringFromLabels(labels),
113
+ proof = null,
114
+ topLevelAssertion = new Metatheorem(fileContext, string, labels, suppositions, consequent, proof, substitutions);
115
+
116
+ return topLevelAssertion;
117
+ }
118
+
119
+ static fromMetatheoremNode(metatheoremNode, fileContext) {
120
+ const proofNode = proofNodeQuery(metatheoremNode),
121
+ labelNodes = labelNodesQuery(metatheoremNode),
122
+ consequentNode = consequentNodeQuery(metatheoremNode),
123
+ suppositionNodes = suppositionNodesQuery(metatheoremNode),
124
+ labels = labelNodes.map((labelNode) => {
125
+ const label = Label.fromLabelNode(labelNode, fileContext);
126
+
127
+ return label;
128
+ }),
129
+ suppositions = suppositionNodes.map((suppositionNode) => {
130
+ const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
131
+
132
+ return supposition;
133
+ }),
134
+ consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
135
+ proof = Proof.fromProofNode(proofNode, fileContext),
136
+ string = stringFromLabels(labels),
137
+ substitutions = Substitutions.fromNothing(),
138
+ metatheorem = new Metatheorem(fileContext, string, labels, suppositions, consequent, proof, substitutions);
139
+
140
+ return metatheorem;
141
+ }
7
142
  }
143
+
144
+ Object.assign(shim, {
145
+ Metatheorem
146
+ });
147
+
148
+ export default Metatheorem;