occam-verify-cli 0.0.546 → 0.0.548

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.
@@ -186,6 +186,20 @@ class ProofContext {
186
186
 
187
187
  return proofContext;
188
188
  }
189
+
190
+ static fromProofContextAndAssignments(proofContext, assignments) {
191
+ const context = proofContext, ///
192
+ variables = assignments.map((assignment) => {
193
+ const variable = assignment.getVariable();
194
+
195
+ return variable;
196
+ }),
197
+ proofSteps = [];
198
+
199
+ proofContext = new ProofContext(context, variables, proofSteps);
200
+
201
+ return proofContext;
202
+ }
189
203
  }
190
204
 
191
205
  Object.assign(ProofContext.prototype, fileMixins);
@@ -349,27 +349,23 @@ export default class ReleaseContext {
349
349
 
350
350
  this.parser = florenceParser; ///
351
351
 
352
- if (this.json === null) {
353
- this.verified = false;
352
+ this.dependencyReleaseContexts = dependencyReleaseContexts;
354
353
 
355
- this.fileContexts = [];
356
- } else {
354
+ if (this.json !== null) {
357
355
  const fileContextsJSON = this.json; ///
358
356
 
359
- this.verified = true;
360
-
361
- this.fileContexts = fileContextsJSON.map((fileContextJSON) => {
357
+ fileContextsJSON.forEach((fileContextJSON) => {
362
358
  const json = fileContextJSON, ///
363
359
  { filePath } = json,
364
360
  fileContext = FileContext.fromFilePathAndReleaseContext(filePath, releaseContext);
365
361
 
366
362
  fileContext.initialise(json);
367
363
 
368
- return fileContext;
364
+ this.fileContexts.push(fileContext);
369
365
  });
370
- }
371
366
 
372
- this.dependencyReleaseContexts = dependencyReleaseContexts;
367
+ this.verified = true;
368
+ }
373
369
  }
374
370
 
375
371
  toJSON() {
@@ -386,9 +382,9 @@ export default class ReleaseContext {
386
382
  static fromLogJSONNameAndEntries(log, json, name, entries) {
387
383
  const lexer = null,
388
384
  parser = null,
389
- verified = null,
385
+ verified = false,
390
386
  customGrammar = customGrammarFromNameAndEntries(name, entries),
391
- fileContexts = null,
387
+ fileContexts = [],
392
388
  dependencyReleaseContexts = null,
393
389
  releaseContext = new ReleaseContext(log, json, name, entries, lexer, parser, verified, customGrammar, fileContexts, dependencyReleaseContexts);
394
390
 
package/src/label.js CHANGED
@@ -34,6 +34,13 @@ export default class Label {
34
34
  return json;
35
35
  }
36
36
 
37
+ static fromLabelNode(labelNode) {
38
+ const node = labelNode, ///
39
+ variable = new Label(node);
40
+
41
+ return variable;
42
+ }
43
+
37
44
  static fromJSONAndFileContext(json, fileContext) {
38
45
  const labelString = json, ///
39
46
  lexer = fileContext.getLexer(),
@@ -44,11 +51,4 @@ export default class Label {
44
51
 
45
52
  return label;
46
53
  }
47
-
48
- static fromLabelNode(labelNode) {
49
- const node = labelNode, ///
50
- variable = new Label(node);
51
-
52
- return variable;
53
- }
54
54
  }
@@ -75,6 +75,12 @@ export default class Supposition {
75
75
  return json;
76
76
  }
77
77
 
78
+ static fromStatementNode(statementNode) {
79
+ const supposition = new Supposition(statementNode);
80
+
81
+ return supposition;
82
+ }
83
+
78
84
  static fromJSONAndFileContext(json, fileContext) {
79
85
  const { statement } = json,
80
86
  statementString = statement, ///
@@ -85,10 +91,4 @@ export default class Supposition {
85
91
 
86
92
  return supposition;
87
93
  }
88
-
89
- static fromStatementNode(statementNode) {
90
- const supposition = new Supposition(statementNode);
91
-
92
- return supposition;
93
- }
94
94
  }
package/src/type.js CHANGED
@@ -186,20 +186,22 @@ class ObjectType extends Type {
186
186
  export const objectType = ObjectType.fromNothing();
187
187
 
188
188
  function superTypeFromSuperTypeJSONAndFileContext(superTypeJSON, fileContext) {
189
- let superType;
189
+ let superType = null;
190
190
 
191
- const json = superTypeJSON, ///
192
- { name } = json;
191
+ if (superTypeJSON !== null) {
192
+ const json = superTypeJSON, ///
193
+ { name } = json;
193
194
 
194
- if (name === OBJECT_TYPE_NAME) {
195
- superType = objectType; ///
196
- } else {
197
- const typeName = name, ///
198
- type = fileContext.findTypeByTypeName(typeName);
195
+ if (name === OBJECT_TYPE_NAME) {
196
+ superType = objectType; ///
197
+ } else {
198
+ const typeName = name, ///
199
+ type = fileContext.findTypeByTypeName(typeName);
199
200
 
200
- superType = (type !== null) ?
201
- type : ///
202
- Type.fromJSONAndFileContext(json, fileContext); ///
201
+ superType = (type !== null) ?
202
+ type : ///
203
+ Type.fromJSONAndFileContext(json, fileContext); ///
204
+ }
203
205
  }
204
206
 
205
207
  return superType;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  import Verifier from "../verifier";
4
+ import verifyTerm from "../verify/term";
4
5
  import TermForVariableSubstitution from "../substitution/termForVariable";
5
6
 
6
7
  import { first } from "../utilities/array";
7
8
  import { nodeQuery } from "../utilities/query";
8
9
  import { TERM_RULE_NAME } from "../ruleNames";
9
10
  import { variableNameFromVariableNode } from "../utilities/query";
10
- import { verifyTermAgainstConstructors } from "../verify/term";
11
11
 
12
12
  const variableNodeQuery = nodeQuery('/term/variable!');
13
13
 
@@ -54,10 +54,10 @@ export default class TermForVariableVerifier extends Verifier {
54
54
  return termNodeVerified;
55
55
  }
56
56
 
57
- verifyVariableNode(variableNodeB, termNodeB, substitutions, proofContextA, proofContextB) {
57
+ verifyVariableNode(variableNodeA, termNodeB, substitutions, proofContextA, proofContextB) {
58
58
  let variableVerified;
59
59
 
60
- const variableNameA = variableNameFromVariableNode(variableNodeB),
60
+ const variableNameA = variableNameFromVariableNode(variableNodeA),
61
61
  substitution = substitutions.find((substitution) => {
62
62
  const variableName = substitution.getVariableName();
63
63
 
@@ -83,7 +83,7 @@ export default class TermForVariableVerifier extends Verifier {
83
83
  const types = [],
84
84
  context = proofContextB, ///
85
85
  termNode = termNodeB, ///
86
- termVerified = verifyTermAgainstConstructors(termNodeB, types, context);
86
+ termVerified = verifyTerm(termNode, types, context);
87
87
 
88
88
  if (termVerified) {
89
89
  const firstType = first(types),
@@ -6,7 +6,7 @@ import { nodeQuery } from "../../utilities/query";
6
6
 
7
7
  const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
8
8
 
9
- export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, assignments, derived, metaproofContext) {
9
+ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, metaproofContext) {
10
10
  let unqualifiedMetastatementVerified = false;
11
11
 
12
12
  const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
@@ -23,7 +23,7 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
23
23
  }
24
24
 
25
25
  if (!unqualifiedMetastatementVerified) {
26
- const metastatementVerified = verifyMetastatement(metastatementNode, assignments, derived, metaproofContext);
26
+ const metastatementVerified = verifyMetastatement(metastatementNode, derived, metaproofContext);
27
27
 
28
28
  unqualifiedMetastatementVerified = metastatementVerified; ///
29
29
  }
@@ -57,7 +57,7 @@ class MetastatementVerifier extends Verifier {
57
57
 
58
58
  const metastatementVerifier = new MetastatementVerifier();
59
59
 
60
- export default function verifyMetastatement(metastatementNode, assignments, derived, metaproofContext) {
60
+ export default function verifyMetastatement(metastatementNode, derived, metaproofContext) {
61
61
  let metastatementVerified = false;
62
62
 
63
63
  if (!metastatementVerified) {
@@ -17,9 +17,8 @@ export default function verifyPremise(premiseNode, premises, metaproofContext) {
17
17
  metaproofContext.debug(`Verifying the '${premiseString}' premise...`, premiseNode);
18
18
 
19
19
  const derived = false,
20
- assignments = [],
21
20
  unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(premiseNode),
22
- unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, assignments, derived, metaproofContext);
21
+ unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, metaproofContext);
23
22
 
24
23
  if (unqualifiedMetastatementVerified) {
25
24
  const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
@@ -51,7 +51,7 @@ export default function verifyRule(ruleNode, fileContext) {
51
51
  let ruleProofVerified = true; ///
52
52
 
53
53
  if (ruleProofNode !== null) {
54
- ruleProofVerified = verifyRuleProof(ruleProofNode, conclusion, metaProofContext);
54
+ ruleProofVerified = verifyRuleProof(ruleProofNode, conclusion, assignments, metaProofContext);
55
55
  }
56
56
 
57
57
  if (ruleProofVerified) {
@@ -7,7 +7,7 @@ import { nodeQuery } from "../utilities/query";
7
7
 
8
8
  const ruleDerivationNodeQuery = nodeQuery("/ruleProof/ruleDerivation!");
9
9
 
10
- export default function verifyRuleProof(ruleProofNode, conclusion, metaproofContext) {
10
+ export default function verifyRuleProof(ruleProofNode, conclusion, assignments, metaproofContext) {
11
11
  let ruleProofVerified = false;
12
12
 
13
13
  const ruleDerivationNode = ruleDerivationNodeQuery(ruleProofNode),
@@ -30,7 +30,7 @@ export default function verifySupposition(suppositionNode, suppositions, proofCo
30
30
 
31
31
  proofContext.addProofStep(proofStep);
32
32
 
33
- assignments.every((assignment) => {
33
+ assignments.forEach((assignment) => {
34
34
  assignment.assign(proofContext);
35
35
  });
36
36