occam-verify-cli 0.0.1247 → 0.0.1248

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.
@@ -1,28 +1,18 @@
1
1
  "use strict";
2
2
 
3
- import LocalContext from "../context/local";
4
- import TopLevelAssertion from "./topLevelAssertion";
3
+ import TopLevelMetaAssertion from "./topLevelMetaAssertion";
5
4
 
6
5
  import { domAssigned } from "../dom";
7
- import { stringFromLabels } from "./topLevelAssertion";
8
- import { labelsFromJSON,
9
- labelsToLabelsJSON,
10
- consequentFromJSON,
11
- suppositionsFromJSON,
12
- substitutionsFromJSON,
13
- consequentToConsequentJSON,
14
- suppositionsToSuppositionsJSON,
15
- substitutionsToSubstitutionsJSON } from "../utilities/json";
16
6
 
17
- export default domAssigned(class Metatheorem extends TopLevelAssertion {
7
+ export default domAssigned(class Metatheorem extends TopLevelMetaAssertion {
18
8
  verify() {
19
9
  let verified;
20
10
 
21
- const metatheorem = this, ///
11
+ const metaLemma = this, ///
22
12
  fileContext = this.getFileContext(),
23
- metatheoremString = metatheorem.getString();
13
+ metaLemmaString = metaLemma.getString();
24
14
 
25
- fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
15
+ fileContext.trace(`Verifying the '${metaLemmaString}' metatheorem...`);
26
16
 
27
17
  verified = super.verify();
28
18
 
@@ -31,86 +21,15 @@ export default domAssigned(class Metatheorem extends TopLevelAssertion {
31
21
 
32
22
  fileContext.addMetatheorem(metaTheorem);
33
23
 
34
- fileContext.debug(`...verified the '${metatheoremString}' metatheorem.`);
24
+ fileContext.debug(`...verified the '${metaLemmaString}' metatheorem.`);
35
25
  }
36
26
 
37
27
  return verified;
38
28
  }
39
29
 
40
- verifyLabels() {
41
- const labelsVerified = this.labels.every((label) => {
42
- const nameOnly = false,
43
- labelVerified = label.verify(nameOnly);
44
-
45
- if (labelVerified) {
46
- return true;
47
- }
48
- });
49
-
50
- return labelsVerified;
51
- }
52
-
53
- unifyStatement(statement, substitutions, context) {
54
- let statementUnified;
55
-
56
- const metatheorem = this, ///
57
- statementString = statement.getString(),
58
- metatheoremString = metatheorem.getString();
59
-
60
- context.trace(`Unifying the '${statementString}' statement with the '${metatheoremString}' metatheorem...`);
61
-
62
- const suppositions = this.getSuppositions(),
63
- suppositionsLength = suppositions.length;
64
-
65
- if (suppositionsLength === 0) {
66
- const fileContext = this.getFileContext(),
67
- localContext = LocalContext.fromFileContext(fileContext),
68
- generalContext = localContext, ///
69
- specificContext = context, ///
70
- statementUnifiedWithConsequent = this.unifyStatementWithConsequent(statement, substitutions, generalContext, specificContext);
71
-
72
- statementUnified = statementUnifiedWithConsequent; ///
73
- }
74
-
75
- if (statementUnified) {
76
- context.debug(`...unified the '${statementString}' statement with the '${metatheoremString}' metatheorem.`);
77
- }
78
-
79
- return statementUnified;
80
- }
81
-
82
- toJSON() {
83
- const labelsJSON = labelsToLabelsJSON(this.labels),
84
- consequentJSON = consequentToConsequentJSON(this.consequent),
85
- suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
86
- substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
87
- labels = labelsJSON, ///
88
- consequent = consequentJSON, ///
89
- suppositions = suppositionsJSON, ///
90
- substitutions = substitutionsJSON, ///
91
- json = {
92
- labels,
93
- consequent,
94
- suppositions,
95
- substitutions
96
- };
97
-
98
- return json;
99
- }
100
-
101
30
  static name = "Metatheorem";
102
31
 
103
- static fromJSON(json, fileContext) {
104
- const labels = labelsFromJSON(json, fileContext),
105
- consequent = consequentFromJSON(json, fileContext),
106
- suppositions = suppositionsFromJSON(json, fileContext),
107
- substitutions = substitutionsFromJSON(json, fileContext),
108
- string = stringFromLabels(labels),
109
- proof = null,
110
- topLevelAssertion = new Metatheorem(fileContext, string, labels, substitutions, suppositions, consequent, proof);
111
-
112
- return topLevelAssertion;
113
- }
32
+ static fromJSON(json, fileContext) { return TopLevelMetaAssertion.fromJSON(Metatheorem, json, fileContext); }
114
33
 
115
- static fromMetatheoremNode(metatheoremNode, fileContext) { return TopLevelAssertion.fromNode(Metatheorem, metatheoremNode, fileContext); }
34
+ static fromMetatheoremNode(axiomNode, fileContext) { return TopLevelMetaAssertion.fromNode(Metatheorem, axiomNode, fileContext); }
116
35
  });
@@ -80,7 +80,7 @@ export default domAssigned(class Reference {
80
80
  return metavariableVerified;
81
81
  }
82
82
 
83
- unifyLabel(label, substitutions, context) {
83
+ unifyLabel(label, context) {
84
84
  let labelUnified;
85
85
 
86
86
  const reference = this, ///
@@ -89,7 +89,7 @@ export default domAssigned(class Reference {
89
89
 
90
90
  context.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
91
91
 
92
- const labelUnifiedWithReference = unifyLabelWithReference(label, reference, substitutions, context);
92
+ const labelUnifiedWithReference = unifyLabelWithReference(label, reference, context);
93
93
 
94
94
  labelUnified = labelUnifiedWithReference; ///
95
95
 
@@ -100,6 +100,48 @@ export default domAssigned(class Reference {
100
100
  return labelUnified;
101
101
  }
102
102
 
103
+ unifyMetaLemma(metaLemma, context) {
104
+ let metaLemmaUnified;
105
+
106
+ const reference = this, ///
107
+ referenceString = reference.getString(),
108
+ metaLemmaString = metaLemma.getString();
109
+
110
+ context.trace(`Unifying the '${metaLemmaString}' meta-lemma with the '${referenceString}' reference...`);
111
+
112
+ const label = metaLemma.getLabel(),
113
+ labelUnified = this.unifyLabel(label, context);
114
+
115
+ metaLemmaUnified = labelUnified; ///
116
+
117
+ if (metaLemmaUnified) {
118
+ context.trace(`...unified the '${metaLemmaString}' meta-lemma with the '${referenceString}' reference.`);
119
+ }
120
+
121
+ return metaLemmaUnified;
122
+ }
123
+
124
+ unifyMetatheorem(metatheorem, context) {
125
+ let metatheoremUnified;
126
+
127
+ const reference = this, ///
128
+ referenceString = reference.getString(),
129
+ metatheoremString = metatheorem.getString();
130
+
131
+ context.trace(`Unifying the '${metatheoremString}' metatheorem with the '${referenceString}' reference...`);
132
+
133
+ const label = metatheorem.getLabel(),
134
+ labelUnified = this.unifyLabel(label, context);
135
+
136
+ metatheoremUnified = labelUnified; ///
137
+
138
+ if (metatheoremUnified) {
139
+ context.trace(`...unified the '${metatheoremString}' metatheorem with the '${referenceString}' reference.`);
140
+ }
141
+
142
+ return metatheoremUnified;
143
+ }
144
+
103
145
  unifyMetavariable(metavariable, context) {
104
146
  let metavariableUnified;
105
147
 
package/src/dom/rule.js CHANGED
@@ -7,8 +7,8 @@ import LocalContext from "../context/local";
7
7
  import Substitutions from "../substitutions";
8
8
 
9
9
  import { domAssigned } from "../dom";
10
- import { stringFromLabels } from "./topLevelAssertion";
11
10
  import { nodeQuery, nodesQuery } from "../utilities/query";
11
+ import { labelsStringFromLabels } from "./topLevelAssertion";
12
12
  import { labelsFromJSON,
13
13
  premisesFromJSON,
14
14
  conclusionFromJSON,
@@ -230,7 +230,8 @@ export default domAssigned(class Rule {
230
230
  labels = labelsFromJSON(json, fileContext),
231
231
  premises = premisesFromJSON(json, fileContext),
232
232
  conclusion = conclusionFromJSON(json, fileContext),
233
- string = stringFromLabels(labels);
233
+ labelsString = labelsStringFromLabels(labels),
234
+ string = labelsString; ///
234
235
 
235
236
  rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
236
237
 
@@ -242,7 +243,8 @@ export default domAssigned(class Rule {
242
243
  premises = premisesFromRuleNode(ruleNode, fileContext),
243
244
  conclusion = conclusionFromRuleNode(ruleNode, fileContext),
244
245
  proof = proofFromRuleNode(ruleNode, fileContext),
245
- string = stringFromLabels(labels),
246
+ labelsString = labelsStringFromLabels(labels),
247
+ string = labelsString, ///
246
248
  rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
247
249
 
248
250
  return rule;
@@ -6,7 +6,6 @@ import dom from "../dom";
6
6
  import LocalContext from "../context/local";
7
7
  import Substitutions from "../substitutions";
8
8
 
9
- import { EMPTY_STRING } from "../constants";
10
9
  import { nodeQuery, nodesQuery } from "../utilities/query";
11
10
  import { labelsFromJSON,
12
11
  labelsToLabelsJSON,
@@ -25,11 +24,10 @@ const proofNodeQuery = nodeQuery("/*/proof"),
25
24
  suppositionNodesQuery = nodesQuery("/*/supposition");
26
25
 
27
26
  export default class TopLevelAssertion {
28
- constructor(fileContext, string, labels, substitutions, suppositions, consequent, proof) {
27
+ constructor(fileContext, string, labels, suppositions, consequent, proof) {
29
28
  this.fileContext = fileContext;
30
29
  this.string = string;
31
30
  this.labels = labels;
32
- this.substitutions = substitutions;
33
31
  this.suppositions = suppositions;
34
32
  this.consequent = consequent;
35
33
  this.proof = proof;
@@ -47,10 +45,6 @@ export default class TopLevelAssertion {
47
45
  return this.labels;
48
46
  }
49
47
 
50
- getSubstitutions() {
51
- return this.substitutions;
52
- }
53
-
54
48
  getSuppositions() {
55
49
  return this.suppositions;
56
50
  }
@@ -84,14 +78,14 @@ export default class TopLevelAssertion {
84
78
 
85
79
  if (labelsVerified) {
86
80
  const localContext = LocalContext.fromFileContext(this.fileContext),
87
- context = localContext, ///
88
- suppositionsVerified = this.suppositions.every((supposition) => {
89
- const suppositionVerified = supposition.verify(context);
81
+ context = localContext, ///
82
+ suppositionsVerified = this.suppositions.every((supposition) => {
83
+ const suppositionVerified = supposition.verify(context);
90
84
 
91
- if (suppositionVerified) {
92
- return true;
93
- }
94
- });
85
+ if (suppositionVerified) {
86
+ return true;
87
+ }
88
+ });
95
89
 
96
90
  if (suppositionsVerified) {
97
91
  const consequentVerified = this.consequent.verify(context);
@@ -100,7 +94,8 @@ export default class TopLevelAssertion {
100
94
  if (this.proof === null) {
101
95
  verified = true;
102
96
  } else {
103
- const proofVerified = this.proof.verify(this.substitutions, this.consequent, context);
97
+ const substitutions = Substitutions.fromNothing(),
98
+ proofVerified = this.proof.verify(substitutions, this.consequent, context);
104
99
 
105
100
  verified = proofVerified; ///
106
101
  }
@@ -114,7 +109,7 @@ export default class TopLevelAssertion {
114
109
  verifyLabels() {
115
110
  const labelsVerified = this.labels.every((label) => {
116
111
  const nameOnly = true,
117
- labelVerified = label.verify(nameOnly);
112
+ labelVerified = label.verify(nameOnly);
118
113
 
119
114
  if (labelVerified) {
120
115
  return true;
@@ -229,16 +224,13 @@ export default class TopLevelAssertion {
229
224
  const labelsJSON = labelsToLabelsJSON(this.labels),
230
225
  consequentJSON = consequentToConsequentJSON(this.consequent),
231
226
  suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
232
- substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
233
227
  labels = labelsJSON, ///
234
228
  consequent = consequentJSON, ///
235
229
  suppositions = suppositionsJSON, ///
236
- substitutions = substitutionsJSON, ///
237
230
  json = {
238
231
  labels,
239
232
  consequent,
240
- suppositions,
241
- substitutions
233
+ suppositions
242
234
  };
243
235
 
244
236
  return json;
@@ -246,51 +238,29 @@ export default class TopLevelAssertion {
246
238
 
247
239
  static fromJSON(Class, json, fileContext) {
248
240
  const labels = labelsFromJSON(json, fileContext),
249
- consequent = consequentFromJSON(json, fileContext),
241
+ labelsString = labelsStringFromLabels(labels),
250
242
  suppositions = suppositionsFromJSON(json, fileContext),
251
- substitutions = substitutionsFromJSON(json, fileContext),
252
- string = stringFromLabels(labels),
243
+ consequent = consequentFromJSON(json, fileContext),
253
244
  proof = null,
254
- topLevelAssertion = new Class(fileContext, string, labels, substitutions, suppositions, consequent, proof);
245
+ string = labelsString, ///
246
+ topLevelAssertion = new Class(fileContext, string, labels, suppositions, consequent, proof);
255
247
 
256
248
  return topLevelAssertion;
257
249
  }
258
250
 
259
251
  static fromNode(Class, node, fileContext) {
260
252
  const labels = labelsFromNode(node, fileContext),
261
- substitutions = Substitutions.fromNothing(),
253
+ labelsString = labelsStringFromLabels(labels),
262
254
  suppositions = suppositionsFromNode(node, fileContext),
263
255
  consequent = consequentFromNode(node, fileContext),
264
256
  proof = proofFromNode(node, fileContext),
265
- string = stringFromLabels(labels),
266
- metaLemma = new Class(fileContext, string, labels, substitutions, suppositions, consequent, proof);
257
+ string = labelsString, ///
258
+ metaLemma = new Class(fileContext, string, labels, suppositions, consequent, proof);
267
259
 
268
260
  return metaLemma;
269
261
  }
270
262
  }
271
263
 
272
- export function stringFromLabels(labels) {
273
- const string = labels.reduce((string, label) => {
274
- const labelString = label.getString();
275
-
276
- string = (string === EMPTY_STRING) ?
277
- labelString: ///
278
- `${string},${labelString}`;
279
-
280
- return string;
281
- }, EMPTY_STRING);
282
-
283
- return string;
284
- }
285
-
286
- function proofFromNode(node, fileContext) {
287
- const { Proof } = dom,
288
- proofNode = proofNodeQuery(node),
289
- proof = Proof.fromProofNode(proofNode, fileContext);
290
-
291
- return proof;
292
- }
293
-
294
264
  function labelsFromNode(node, fileContext) {
295
265
  const { Label } = dom,
296
266
  labelNodes = labelNodesQuery(node),
@@ -303,7 +273,15 @@ function labelsFromNode(node, fileContext) {
303
273
  return labels;
304
274
  }
305
275
 
306
- function consequentFromNode(node, fileContext) {
276
+ export function proofFromNode(node, fileContext) {
277
+ const { Proof } = dom,
278
+ proofNode = proofNodeQuery(node),
279
+ proof = Proof.fromProofNode(proofNode, fileContext);
280
+
281
+ return proof;
282
+ }
283
+
284
+ export function consequentFromNode(node, fileContext) {
307
285
  const { Consequent } = dom,
308
286
  consequentNode = consequentNodeQuery(node),
309
287
  consequent = Consequent.fromConsequentNode(consequentNode, fileContext);
@@ -311,7 +289,7 @@ function consequentFromNode(node, fileContext) {
311
289
  return consequent;
312
290
  }
313
291
 
314
- function suppositionsFromNode(node, fileContext) {
292
+ export function suppositionsFromNode(node, fileContext) {
315
293
  const { Supposition } = dom,
316
294
  suppositionNodes = suppositionNodesQuery(node),
317
295
  suppositions = suppositionNodes.map((suppositionNode) => {
@@ -323,3 +301,16 @@ function suppositionsFromNode(node, fileContext) {
323
301
  return suppositions;
324
302
  }
325
303
 
304
+ export function labelsStringFromLabels(labels) {
305
+ const labelsString = labels.reduce((labelsString, label) => {
306
+ const labelString = label.getString();
307
+
308
+ labelsString = (labelsString === null) ?
309
+ labelString: ///
310
+ `${labelsString},${labelString}`;
311
+
312
+ return labelsString;
313
+ }, null);
314
+
315
+ return labelsString;
316
+ }
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ import { arrayUtilities } from "necessary";
4
+
5
+ import dom from "../dom";
6
+ import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
8
+ import TopLevelAssertion from "./topLevelAssertion";
9
+
10
+ import { nodeQuery } from "../utilities/query";
11
+ import { proofFromNode, consequentFromNode, suppositionsFromNode, labelsStringFromLabels } from "./topLevelAssertion";
12
+ import { labelsFromJSON,
13
+ labelsToLabelsJSON,
14
+ consequentFromJSON,
15
+ suppositionsFromJSON,
16
+ substitutionsFromJSON,
17
+ consequentToConsequentJSON,
18
+ suppositionsToSuppositionsJSON,
19
+ substitutionsToSubstitutionsJSON } from "../utilities/json";
20
+
21
+ const { first } = arrayUtilities;
22
+
23
+ const labelNodeQuery = nodeQuery("/metatheorem/label");
24
+
25
+ export default class TopLevelMetaAssertion extends TopLevelAssertion {
26
+ constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
27
+ super(fileContext, string, labels, suppositions, consequent, proof);
28
+
29
+ this.substitutions = substitutions;
30
+ }
31
+
32
+ getSubstitutions() {
33
+ return this.substitutions;
34
+ }
35
+
36
+ getLabel() {
37
+ const labels = this.getLabels(),
38
+ firstLabel = first(labels),
39
+ label = firstLabel; ///
40
+
41
+ return label;
42
+ }
43
+
44
+ verify() {
45
+ let verified = false;
46
+
47
+ const labelsVerified = this.verifyLabels();
48
+
49
+ if (labelsVerified) {
50
+ const localContext = LocalContext.fromFileContext(this.fileContext),
51
+ context = localContext, ///
52
+ suppositionsVerified = this.suppositions.every((supposition) => {
53
+ const suppositionVerified = supposition.verify(context);
54
+
55
+ if (suppositionVerified) {
56
+ return true;
57
+ }
58
+ });
59
+
60
+ if (suppositionsVerified) {
61
+ const consequentVerified = this.consequent.verify(context);
62
+
63
+ if (consequentVerified) {
64
+ if (this.proof === null) {
65
+ verified = true;
66
+ } else {
67
+ const proofVerified = this.proof.verify(this.substitutions, this.consequent, context);
68
+
69
+ verified = proofVerified; ///
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ return verified;
76
+ }
77
+
78
+ verifyLabels() {
79
+ const labelsVerified = this.labels.every((label) => {
80
+ const nameOnly = false,
81
+ labelVerified = label.verify(nameOnly);
82
+
83
+ if (labelVerified) {
84
+ return true;
85
+ }
86
+ });
87
+
88
+ return labelsVerified;
89
+ }
90
+
91
+ verifyWhenStated(statement, reference, context) {
92
+ let verifiedWhenStated;
93
+
94
+ debugger
95
+
96
+ return verifiedWhenStated;
97
+ }
98
+
99
+ toJSON() {
100
+ const labelsJSON = labelsToLabelsJSON(this.labels),
101
+ consequentJSON = consequentToConsequentJSON(this.consequent),
102
+ suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
103
+ substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
104
+ labels = labelsJSON, ///
105
+ consequent = consequentJSON, ///
106
+ suppositions = suppositionsJSON, ///
107
+ substitutions = substitutionsJSON, ///
108
+ json = {
109
+ labels,
110
+ consequent,
111
+ suppositions,
112
+ substitutions
113
+ };
114
+
115
+ return json;
116
+ }
117
+
118
+ static fromJSON(Class, json, fileContext) {
119
+ const labels = labelsFromJSON(json, fileContext),
120
+ substitutions = substitutionsFromJSON(json, fileContext),
121
+ labelsString = labelsStringFromLabels(labels),
122
+ suppositions = suppositionsFromJSON(json, fileContext),
123
+ consequent = consequentFromJSON(json, fileContext),
124
+ proof = null,
125
+ string = labelsString, ///
126
+ topLevelAssertion = new Class(fileContext, string, labels, suppositions, consequent, proof, substitutions);
127
+
128
+ return topLevelAssertion;
129
+ }
130
+
131
+ static fromNode(Class, node, fileContext) {
132
+ const labels = labelsFromNode(node, fileContext),
133
+ substitutions = Substitutions.fromNothing(),
134
+ labelsString = labelsStringFromLabels(labels),
135
+ suppositions = suppositionsFromNode(node, fileContext),
136
+ consequent = consequentFromNode(node, fileContext),
137
+ proof = proofFromNode(node, fileContext),
138
+ string = labelsString, ///
139
+ metaLemma = new Class(fileContext, string, labels, suppositions, consequent, proof, substitutions);
140
+
141
+ return metaLemma;
142
+ }
143
+ }
144
+
145
+ function labelsFromNode(node, fileContext) {
146
+ const { Label } = dom,
147
+ labelNode = labelNodeQuery(node),
148
+ label = Label.fromLabelNode(labelNode, fileContext),
149
+ labels = [
150
+ label
151
+ ];
152
+
153
+ return labels;
154
+ }
@@ -18,12 +18,12 @@ export function nodesAsString(nodes, tokens) {
18
18
  const string = nodes.reduce((string, node) => {
19
19
  const nodeString = nodeAsString(node, tokens);
20
20
 
21
- string = (string === EMPTY_STRING) ?
21
+ string = (string === null) ?
22
22
  nodeString :
23
23
  `${string},${nodeString}`;
24
24
 
25
25
  return string;
26
- }, EMPTY_STRING);
26
+ }, null);
27
27
 
28
28
  return string;
29
29
  }
@@ -82,7 +82,7 @@ export function unifyMetavariable(generalMetavariable, specificMetavariable, gen
82
82
  return metavariableUnified;
83
83
  }
84
84
 
85
- export function unifyLabelWithReference(label, reference, substitutions, context) {
85
+ export function unifyLabelWithReference(label, reference, context) {
86
86
  let labelUnifiedWithReference;
87
87
 
88
88
  let generalContext,
@@ -104,7 +104,8 @@ export function unifyLabelWithReference(label, reference, substitutions, context
104
104
 
105
105
  specificContext = contextFromTokens(referenceMetavariableTokens, specificContext); ///
106
106
 
107
- const referenceUnified = referenceUnifier.unify(labelMetavariableNode, referenceMetavariableNode, substitutions, generalContext, specificContext);
107
+ const substitutions = Substitutions.fromNothing(),
108
+ referenceUnified = referenceUnifier.unify(labelMetavariableNode, referenceMetavariableNode, substitutions, generalContext, specificContext);
108
109
 
109
110
  labelUnifiedWithReference = referenceUnified; ///
110
111