occam-verify-cli 0.0.1051 → 0.0.1052

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "occam-verify-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.1051",
4
+ "version": "0.0.1052",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/occam-verify-cli",
7
7
  "description": "Occam's Verifier",
@@ -124,11 +124,10 @@ export default class SubproofAssertion {
124
124
  return subproofUnified;
125
125
  }
126
126
 
127
- static fromStatement(statement, fileContext) {
127
+ static fromStatementNode(statementNode, fileContext) {
128
128
  let subproofAssertion = null;
129
129
 
130
- const statementNode = statement.getNode(),
131
- subproofAssertionNode = subproofAssertionNodeQuery(statementNode);
130
+ const subproofAssertionNode = subproofAssertionNodeQuery(statementNode);
132
131
 
133
132
  if (subproofAssertionNode !== null) {
134
133
  const { Statement } = shim,
@@ -150,16 +149,21 @@ export default class SubproofAssertion {
150
149
  }
151
150
 
152
151
  static fromSubproofAssertionNode(subproofAssertionNode, localContext) {
153
- const { Statement } = shim,
154
- statementNodes = statementNodesQuery(subproofAssertionNode),
155
- statements = statementNodes.map((statementNode) => {
156
- const statement = Statement.fromStatementNode(statementNode, localContext);
157
-
158
- return statement;
159
- }),
160
- node = subproofAssertionNode, ///
161
- string = stringFromStatements(statements),
162
- subproofAssertion = new SubproofAssertion(string, node, statements);
152
+ let subproofAssertion = null;
153
+
154
+ if (subproofAssertionNode !== null) {
155
+ const { Statement } = shim,
156
+ statementNodes = statementNodesQuery(subproofAssertionNode),
157
+ statements = statementNodes.map((statementNode) => {
158
+ const statement = Statement.fromStatementNode(statementNode, localContext);
159
+
160
+ return statement;
161
+ }),
162
+ node = subproofAssertionNode, ///
163
+ string = stringFromStatements(statements);
164
+
165
+ subproofAssertion = new SubproofAssertion(string, node, statements);
166
+ }
163
167
 
164
168
  return subproofAssertion;
165
169
  }
@@ -153,15 +153,20 @@ export default class TypeAssertion {
153
153
  }
154
154
 
155
155
  static fromTypeAssertionNode(typeAssertionNode, localContext) {
156
- const { Term, Type } = shim,
157
- termNode = termNodeQuery(typeAssertionNode),
158
- typeNode = typeNodeQuery(typeAssertionNode),
159
- variableNode = variableNodeQuery(termNode),
160
- term = Term.fromTermNode(termNode, localContext),
161
- type = Type.fromTypeNode(typeNode, localContext),
162
- variable = Variable.fromVariableNode(variableNode, localContext),
163
- string = stringFromTermAndType(term, type),
164
- typeAssertion = new TypeAssertion(string, term, type, variable);
156
+ let typeAssertion = null;
157
+
158
+ if (typeAssertionNode !== null) {
159
+ const { Term, Type } = shim,
160
+ termNode = termNodeQuery(typeAssertionNode),
161
+ typeNode = typeNodeQuery(typeAssertionNode),
162
+ variableNode = variableNodeQuery(termNode),
163
+ term = Term.fromTermNode(termNode, localContext),
164
+ type = Type.fromTypeNode(typeNode, localContext),
165
+ variable = Variable.fromVariableNode(variableNode, localContext),
166
+ string = stringFromTermAndType(term, type);
167
+
168
+ typeAssertion = new TypeAssertion(string, term, type, variable);
169
+ }
165
170
 
166
171
  return typeAssertion;
167
172
  }
package/src/conjecture.js CHANGED
@@ -46,11 +46,11 @@ export default class Conjecture extends TopLevelAssertion {
46
46
  const consequentVerified = this.consequent.verify(localContext);
47
47
 
48
48
  if (consequentVerified) {
49
- if (this.proof !== null) {
49
+ // if (this.proof !== null) {
50
50
  const substitutions = Substitutions.fromNothing();
51
51
 
52
52
  this.proof.verify(substitutions, this.consequent, localContext);
53
- }
53
+ // }
54
54
 
55
55
  const conjecture = this; ///
56
56
 
@@ -4,7 +4,6 @@ import shim from "./shim";
4
4
  import LocalContext from "./context/local";
5
5
 
6
6
  import { nodeQuery } from "./utilities/query";
7
- import { objectType } from "./type";
8
7
 
9
8
  const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
10
9
  typeNodeQuery = nodeQuery("/constructorDeclaration/type");
@@ -77,9 +76,7 @@ export default class Constructor {
77
76
  const { Term, Type } = shim,
78
77
  termNode = termNodeQuery(constructorDeclarationNode),
79
78
  typeNode = typeNodeQuery(constructorDeclarationNode),
80
- type = (typeNode === null) ?
81
- objectType :
82
- Type.fromTypeNode(typeNode),
79
+ type = Type.fromTypeNode(typeNode),
83
80
  localContext = LocalContext.fromFileContext(fileContext),
84
81
  term = Term.fromTermNodeAndType(termNode, type, localContext),
85
82
  string = stringFromTermAndType(term, type),
package/src/equality.js CHANGED
@@ -157,14 +157,19 @@ export default class Equality {
157
157
  }
158
158
 
159
159
  static fromEqualityNode(equalityNode, localContext) {
160
- const { Term } = shim,
161
- leftTermNode = leftTermNodeQuery(equalityNode),
162
- rightTermNode = rightTermNodeQuery(equalityNode),
163
- leftTerm = Term.fromTermNode(leftTermNode, localContext),
164
- rightTerm = Term.fromTermNode(rightTermNode, localContext),
165
- node = equalityNode, ///
166
- string = localContext.nodeAsString(node),
167
- equality = new Equality(string, leftTerm, rightTerm);
160
+ let equality = null;
161
+
162
+ if (equalityNode !== null) {
163
+ const { Term } = shim,
164
+ leftTermNode = leftTermNodeQuery(equalityNode),
165
+ rightTermNode = rightTermNodeQuery(equalityNode),
166
+ leftTerm = Term.fromTermNode(leftTermNode, localContext),
167
+ rightTerm = Term.fromTermNode(rightTermNode, localContext),
168
+ node = equalityNode, ///
169
+ string = localContext.nodeAsString(node);
170
+
171
+ equality = new Equality(string, leftTerm, rightTerm);
172
+ }
168
173
 
169
174
  return equality;
170
175
  }
@@ -51,15 +51,15 @@ function verifyAsEquality(statement, assignments, stated, localContext) {
51
51
  let verifiedAsEquality = false;
52
52
 
53
53
  const statementNode = statement.getNode(),
54
- equalityNode = equalityNodeQuery(statementNode);
54
+ equalityNode = equalityNodeQuery(statementNode),
55
+ equality = Equality.fromEqualityNode(equalityNode, localContext);
55
56
 
56
- if (equalityNode !== null) {
57
+ if (equality !== null) {
57
58
  const statementString = statement.getString();
58
59
 
59
60
  localContext.trace(`Verifying the '${statementString}' statement as an equality...`);
60
61
 
61
- const equality = Equality.fromEqualityNode(equalityNode, localContext),
62
- equalityVerified = equality.verify(assignments, stated, localContext);
62
+ const equalityVerified = equality.verify(assignments, stated, localContext);
63
63
 
64
64
  verifiedAsEquality = equalityVerified; ///
65
65
 
@@ -144,15 +144,15 @@ function verifyAsTypeAssertion(statement, assignments, stated, localContext) {
144
144
  let verifiedAsTypeAssertion = false;
145
145
 
146
146
  const statementNode = statement.getNode(),
147
- typeAssertionNode = typeAssertionNodeQuery(statementNode);
147
+ typeAssertionNode = typeAssertionNodeQuery(statementNode),
148
+ typeAssertion = TypeAssertion.fromTypeAssertionNode(typeAssertionNode, localContext);
148
149
 
149
- if (typeAssertionNode !== null) {
150
+ if (typeAssertion !== null) {
150
151
  const statementString = statement.getString();
151
152
 
152
153
  localContext.trace(`Verifying the '${statementString}' statement as a type assertion...`);
153
154
 
154
- const typeAssertion = TypeAssertion.fromTypeAssertionNode(typeAssertionNode, localContext),
155
- typeAssertionVerified = typeAssertion.verify(assignments, stated, localContext);
155
+ const typeAssertionVerified = typeAssertion.verify(assignments, stated, localContext);
156
156
 
157
157
  verifiedAsTypeAssertion = typeAssertionVerified; ///
158
158
 
@@ -191,15 +191,15 @@ function verifyAsSubproofAssertion(statement, assignments, stated, localContext)
191
191
  let verifiedAsSubproofAssertion = false;
192
192
 
193
193
  const statementNode = statement.getNode(),
194
- subproofAssertionNode = subproofAssertionNodeQuery(statementNode);
194
+ subproofAssertionNode = subproofAssertionNodeQuery(statementNode),
195
+ subproofAssertion = SubproofAssertion.fromSubproofAssertionNode(subproofAssertionNode, localContext);
195
196
 
196
197
  if (subproofAssertionNode !== null) {
197
198
  const statementString = statement.getString();
198
199
 
199
200
  localContext.trace(`Verifying the '${statementString}' statement as a subproof assertion...`);
200
201
 
201
- const subproofAssertion = SubproofAssertion.fromSubproofAssertionNode(subproofAssertionNode, localContext),
202
- subproofAssertionVerified = subproofAssertion.verify(assignments, stated, localContext);
202
+ const subproofAssertionVerified = subproofAssertion.verify(assignments, stated, localContext);
203
203
 
204
204
  verifiedAsSubproofAssertion = subproofAssertionVerified; ///
205
205
 
@@ -20,15 +20,14 @@ function unifyTermWithBracketedConstructor(term, localContext, verifyAhead) {
20
20
  termUnifiedWithBracketedConstructor = unifyTermWithConstructor(term, bracketedConstructor, localContext, () => {
21
21
  let verifiedAhead = false;
22
22
 
23
- const bracketedTerm = term, ///
23
+ const { Term } = shim,
24
+ bracketedTerm = term, ///
24
25
  bracketedTermNode = bracketedTerm.getNode(),
25
26
  termNode = termNodeQuery(bracketedTermNode); ///
26
27
 
27
- if (termNode !== null) {
28
- const { Term } = shim;
29
-
30
- term = Term.fromTermNode(termNode, localContext);
28
+ term = Term.fromTermNode(termNode, localContext);
31
29
 
30
+ if (term !== null) {
32
31
  const termVVerified = term.verify(localContext, () => {
33
32
  let verifiedAhead;
34
33
 
@@ -10,15 +10,15 @@ function verifyTermAsVariable(term, localContext, verifyAhead) {
10
10
  let termVerifiedAsVariable = false;
11
11
 
12
12
  const termNode = term.getNode(),
13
- variableNode = variableNodeQuery(termNode);
13
+ variableNode = variableNodeQuery(termNode),
14
+ variable = Variable.fromVariableNode(variableNode, localContext);
14
15
 
15
- if (variableNode !== null) {
16
+ if (variable !== null) {
16
17
  const termString = localContext.nodeAsString(termNode);
17
18
 
18
19
  localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
19
20
 
20
- const variable = Variable.fromVariableNode(variableNode, localContext),
21
- variableVerified = variable.verify(localContext);
21
+ const variableVerified = variable.verify(localContext);
22
22
 
23
23
  if (variableVerified) {
24
24
  let verifiedAhead;
package/src/premise.js CHANGED
@@ -40,7 +40,8 @@ export default class Premise {
40
40
  localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
41
41
 
42
42
  const statement = this.unqualifiedStatement.getStatement(),
43
- subproofAssertion = SubproofAssertion.fromStatement(statement, this.fileContext);
43
+ statementNode = statement.getNode(),
44
+ subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, this.fileContext);
44
45
 
45
46
  if (subproofAssertion !== null) {
46
47
  subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
package/src/proofStep.js CHANGED
@@ -90,23 +90,11 @@ class ProofStep {
90
90
  static fromProofStepNode(proofStepNode, fileContext) {
91
91
  const subproofNode = subproofNodeQuery(proofStepNode),
92
92
  qualifiedStatementNode = qualifiedStatementNodeQuery(proofStepNode),
93
- unqualifiedStatementNode = unqualifiedStatementNodeQuery(proofStepNode);
94
-
95
- let subproof = null,
96
- qualifiedStatement = null,
97
- unqualifiedStatement = null;
98
-
99
- if (false) {
100
- ///
101
- } else if (subproofNode !== null) {
102
- subproof = Subproof.fromSubproofNode(subproofNode, fileContext);
103
- } else if (qualifiedStatementNode !== null) {
104
- qualifiedStatement = QualifiedStatement.fromQualifiedStatementNode(qualifiedStatementNode, fileContext);
105
- } else if (unqualifiedStatementNode !== null) {
106
- unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext);
107
- }
108
-
109
- const proofStep = new ProofStep(subproof, qualifiedStatement, unqualifiedStatement);
93
+ unqualifiedStatementNode = unqualifiedStatementNodeQuery(proofStepNode),
94
+ subproof = Subproof.fromSubproofNode(subproofNode, fileContext),
95
+ qualifiedStatement = QualifiedStatement.fromQualifiedStatementNode(qualifiedStatementNode, fileContext),
96
+ unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
97
+ proofStep = new ProofStep(subproof, qualifiedStatement, unqualifiedStatement);
110
98
 
111
99
  return proofStep;
112
100
  }
@@ -87,21 +87,25 @@ export default class QualifiedStatement {
87
87
  }
88
88
 
89
89
  static fromQualifiedStatementNode(qualifiedStatementNode, fileContext) {
90
- let string;
90
+ let qualifiedStatement = null;
91
91
 
92
- const { Statement } = shim,
93
- statementNode = statementNodeQuery(qualifiedStatementNode),
94
- referenceNode = referenceNodeQuery(qualifiedStatementNode),
95
- localContext = LocalContext.fromFileContext(fileContext),
96
- statement = Statement.fromStatementNode(statementNode, localContext),
97
- reference = Reference.fromReferenceNode(referenceNode, fileContext),
98
- node = qualifiedStatementNode; ///
92
+ if (qualifiedStatementNode !== null) {
93
+ let string;
99
94
 
100
- string = fileContext.nodeAsString(node);
95
+ const { Statement } = shim,
96
+ statementNode = statementNodeQuery(qualifiedStatementNode),
97
+ referenceNode = referenceNodeQuery(qualifiedStatementNode),
98
+ localContext = LocalContext.fromFileContext(fileContext),
99
+ statement = Statement.fromStatementNode(statementNode, localContext),
100
+ reference = Reference.fromReferenceNode(referenceNode, fileContext),
101
+ node = qualifiedStatementNode; ///
101
102
 
102
- string = trim(string); ///
103
+ string = fileContext.nodeAsString(node);
103
104
 
104
- const qualifiedStatement = new QualifiedStatement(string, statement, reference);
105
+ string = trim(string); ///
106
+
107
+ qualifiedStatement = new QualifiedStatement(string, statement, reference);
108
+ }
105
109
 
106
110
  return qualifiedStatement;
107
111
  }
@@ -73,19 +73,23 @@ export default class UnqualifiedStatement {
73
73
  }
74
74
 
75
75
  static fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext) {
76
- let string;
76
+ let unqualifiedStatement = null;
77
77
 
78
- const { Statement } = shim,
79
- statementNode = statementNodeQuery(unqualifiedStatementNode),
80
- localContext = LocalContext.fromFileContext(fileContext),
81
- statement = Statement.fromStatementNode(statementNode, localContext),
82
- node = unqualifiedStatementNode; ///
78
+ if (unqualifiedStatementNode !== null) {
79
+ let string;
83
80
 
84
- string = fileContext.nodeAsString(node);
81
+ const { Statement } = shim,
82
+ statementNode = statementNodeQuery(unqualifiedStatementNode),
83
+ localContext = LocalContext.fromFileContext(fileContext),
84
+ statement = Statement.fromStatementNode(statementNode, localContext),
85
+ node = unqualifiedStatementNode; ///
85
86
 
86
- string = trim(string); ///
87
+ string = fileContext.nodeAsString(node);
87
88
 
88
- const unqualifiedStatement = new UnqualifiedStatement(string, statement);
89
+ string = trim(string); ///
90
+
91
+ unqualifiedStatement = new UnqualifiedStatement(string, statement);
92
+ }
89
93
 
90
94
  return unqualifiedStatement;
91
95
  }
package/src/statement.js CHANGED
@@ -153,9 +153,9 @@ class Statement {
153
153
 
154
154
  if (statementNode !== null) {
155
155
  const node = statementNode, ///
156
- string = localContext.nodeAsString(node),
157
- statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext),
158
- substitution = statementSubstitution; ///
156
+ string = localContext.nodeAsString(node),
157
+ statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext),
158
+ substitution = statementSubstitution; ///
159
159
 
160
160
  statement = new Statement(string, node, substitution);
161
161
  }
package/src/subproof.js CHANGED
@@ -77,17 +77,22 @@ export default class Subproof {
77
77
  }
78
78
 
79
79
  static fromSubproofNode(subproofNode, fileContext) {
80
- const subproofString = subproofStringFromSubproofNode(subproofNode, fileContext),
81
- suppositionNodes = suppositionNodesQuery(subproofNode),
82
- subDerivationNode = subDerivationNodeQuery(subproofNode),
83
- string = subproofString, ///
84
- suppositions = suppositionNodes.map((suppositionNode) => {
85
- const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
86
-
87
- return supposition;
88
- }),
89
- subDerivation = SubDerivation.fromSubDerivationNode(subDerivationNode, fileContext),
90
- subproof = new Subproof(string, suppositions, subDerivation);
80
+ let subproof = null;
81
+
82
+ if (subproofNode !== null) {
83
+ const subproofString = subproofStringFromSubproofNode(subproofNode, fileContext),
84
+ suppositionNodes = suppositionNodesQuery(subproofNode),
85
+ subDerivationNode = subDerivationNodeQuery(subproofNode),
86
+ string = subproofString, ///
87
+ suppositions = suppositionNodes.map((suppositionNode) => {
88
+ const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
89
+
90
+ return supposition;
91
+ }),
92
+ subDerivation = SubDerivation.fromSubDerivationNode(subDerivationNode, fileContext);
93
+
94
+ subproof = new Subproof(string, suppositions, subDerivation);
95
+ }
91
96
 
92
97
  return subproof;
93
98
  }
@@ -71,7 +71,8 @@ export default class Supposition {
71
71
  localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
72
72
 
73
73
  const statement = this.unqualifiedStatement.getStatement(),
74
- subproofAssertion = SubproofAssertion.fromStatement(statement, this.fileContext);
74
+ statementNode = statement.getNode(),
75
+ subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, this.fileContext);
75
76
 
76
77
  if (subproofAssertion !== null) {
77
78
  subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
package/src/term.js CHANGED
@@ -240,10 +240,15 @@ class Term {
240
240
  }
241
241
 
242
242
  static fromTermNode(termNode, localContext) {
243
- const node = termNode, ///
244
- string = localContext.nodeAsString(node),
245
- type = null,
246
- term = new Term(string, node, type);
243
+ let term = null;
244
+
245
+ if (termNode !== null) {
246
+ const node = termNode, ///
247
+ string = localContext.nodeAsString(node),
248
+ type = null;
249
+
250
+ term = new Term(string, node, type);
251
+ }
247
252
 
248
253
  return term;
249
254
  }