occam-verify-cli 0.0.1229 → 0.0.1231

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.
@@ -5,12 +5,13 @@ import dom from "../dom";
5
5
  import { domAssigned } from "../dom";
6
6
  import { assignAssignments } from "../utilities/assignments";
7
7
  import { subproofAssertionFromStatement } from "../utilities/verification";
8
- import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
8
+ import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
9
9
 
10
10
  export default domAssigned(class Premise {
11
- constructor(string, statement) {
11
+ constructor(string, statement, procedureCall) {
12
12
  this.string = string;
13
13
  this.statement = statement;
14
+ this.procedureCall = procedureCall;
14
15
  }
15
16
 
16
17
  getString() {
@@ -21,12 +22,24 @@ export default domAssigned(class Premise {
21
22
  return this.statement;
22
23
  }
23
24
 
25
+ getProcedureCall() {
26
+ return this.procedureCall;
27
+ }
28
+
24
29
  unifyIndependently(substitutions, generalContext, specificContext) {
25
30
  let unifiedIndependently;
26
31
 
27
- const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
32
+ if (this.statesment !== null) {
33
+ const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
34
+
35
+ unifiedIndependently = statementResolvedIndependently; ///
36
+ }
37
+
38
+ if (this.procedureCall !== null) {
39
+ const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, generalContext, specificContext);
28
40
 
29
- unifiedIndependently = statementResolvedIndependently; ///
41
+ unifiedIndependently = procedureCallResolvedIndependently; ///
42
+ }
30
43
 
31
44
  return unifiedIndependently;
32
45
  }
@@ -129,7 +142,9 @@ export default domAssigned(class Premise {
129
142
 
130
143
  context.trace(`Verifying the '${premiseString}' premise...`);
131
144
 
132
- if (this.statement !== null) {
145
+ if (false) {
146
+ ///
147
+ } else if (this.statement !== null) {
133
148
  const stated = true,
134
149
  assignments = [],
135
150
  statementVerified = this.statement.verify(assignments, stated, context);
@@ -147,6 +162,14 @@ export default domAssigned(class Premise {
147
162
  verified = true;
148
163
  }
149
164
  }
165
+ } else if (this.procedureCall !== null) {
166
+ const stated = true,
167
+ assignments = null,
168
+ procedureCallVerified = this.procedureCall.verify(assignments, stated, context);
169
+
170
+ if (procedureCallVerified) {
171
+ verified = true;
172
+ }
150
173
  } else {
151
174
  context.debug(`Unable to verify the '${premiseString}' premise because it is nonsense.`);
152
175
  }
@@ -160,9 +183,12 @@ export default domAssigned(class Premise {
160
183
 
161
184
  toJSON() {
162
185
  const statementJSON = statementToStatementJSON(this.statement),
186
+ procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
163
187
  statement = statementJSON, ///
188
+ procedureCall = procedureCallJSON, ///
164
189
  json = {
165
- statement
190
+ statement,
191
+ procedureCall
166
192
  };
167
193
 
168
194
  return json;
@@ -172,18 +198,39 @@ export default domAssigned(class Premise {
172
198
 
173
199
  static fromJSON(json, fileContext) {
174
200
  const statement = statementFromJSON(json, fileContext),
175
- string = statement.getString(),
176
- premise = new Premise(string, statement);
201
+ procedureCall = procedureCallFromJSON(json, fileContext);
202
+
203
+ let string;
204
+
205
+ if (statement !== null) {
206
+ string = statement.getString();
207
+ }
208
+
209
+ if (procedureCall !== null) {
210
+ string = procedureCall.getString();
211
+ }
212
+
213
+ const premise = new Premise(string, statement, procedureCall);
177
214
 
178
215
  return premise;
179
216
  }
180
217
 
181
218
  static fromPremiseNode(premiseNode, fileContext) {
182
- const { Statement } = dom,
219
+ const { Statement, ProcedureCall } = dom,
183
220
  statement = Statement.fromPremiseNode(premiseNode, fileContext),
184
- statementString = statement.getString(),
185
- string = statementString, ///
186
- premise = new Premise(string, statement);
221
+ procedureCall = ProcedureCall.fromPremiseNode(premiseNode, fileContext);
222
+
223
+ let string;
224
+
225
+ if (statement !== null) {
226
+ string = statement.getString();
227
+ }
228
+
229
+ if (procedureCall !== null) {
230
+ string = procedureCall.getString();
231
+ }
232
+
233
+ const premise = new Premise(string, statement, procedureCall);
187
234
 
188
235
  return premise
189
236
  }
@@ -8,7 +8,8 @@ import { domAssigned } from "../dom";
8
8
  import { nodeQuery, nodesQuery } from "../utilities/query";
9
9
 
10
10
  const parameterNodesQuery = nodesQuery("/procedureCall/parameter"),
11
- procedureCallNodeQuery = nodeQuery("/statement/procedureCall");
11
+ premiseProcedureCallNodeQuery = nodeQuery("/premise/procedureCall"),
12
+ suppositionProcedureCallNodeQuery = nodeQuery("/supposition/procedureCall");
12
13
 
13
14
  export default domAssigned(class ProcedureCall {
14
15
  constructor(string, reference, parameters) {
@@ -93,13 +94,32 @@ export default domAssigned(class ProcedureCall {
93
94
 
94
95
  static name = "ProcedureCall";
95
96
 
96
- static fromStatementNode(statementNode, context) {
97
+ static fromPremiseNode(premiseNode, context) {
97
98
  let procedureCall = null;
98
99
 
99
- const procedureCallNode = procedureCallNodeQuery(statementNode);
100
+ const premiseProcedureCallNode = premiseProcedureCallNodeQuery(premiseNode);
100
101
 
101
- if (procedureCallNode !== null) {
102
+ if (premiseProcedureCallNode !== null) {
102
103
  const { Reference } = dom,
104
+ procedureCallNode = premiseProcedureCallNode, ///
105
+ parameters = parametersFromProcedureCallNode(procedureCallNode, context),
106
+ reference = Reference.fromProcedureCallNode(procedureCallNode, context),
107
+ string = stringFromReferenceAndParameters(reference, parameters);
108
+
109
+ procedureCall = new ProcedureCall(string, reference, parameters);
110
+ }
111
+
112
+ return procedureCall;
113
+ }
114
+
115
+ static fromSuppositionNode(suppositionNode, context) {
116
+ let procedureCall = null;
117
+
118
+ const suppositionProcedureCallNode = suppositionProcedureCallNodeQuery(suppositionNode);
119
+
120
+ if (suppositionProcedureCallNode !== null) {
121
+ const { Reference } = dom,
122
+ procedureCallNode = suppositionProcedureCallNode, ///
103
123
  parameters = parametersFromProcedureCallNode(procedureCallNode, context),
104
124
  reference = Reference.fromProcedureCallNode(procedureCallNode, context),
105
125
  string = stringFromReferenceAndParameters(reference, parameters);
@@ -12,7 +12,7 @@ import { domAssigned } from "../dom";
12
12
  import { unifyStatement } from "../utilities/unification";
13
13
  import { nodeQuery, nodesQuery } from "../utilities/query";
14
14
  import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
15
- import { procedureCallFromStatement, definedAssertionFromStatement, subproofAssertionFromStatement, containedAssertionFromStatement } from "../utilities/verification";
15
+ import { definedAssertionFromStatement, subproofAssertionFromStatement, containedAssertionFromStatement } from "../utilities/verification";
16
16
 
17
17
  const { match, backwardsSome } = arrayUtilities;
18
18
 
@@ -170,21 +170,14 @@ export default domAssigned(class Statement {
170
170
  const context = specificContext, ///
171
171
  statement = this; ///
172
172
 
173
- const procedureCall = procedureCallFromStatement(statement, context),
174
- definedAssertion = definedAssertionFromStatement(statement, context),
173
+ const definedAssertion = definedAssertionFromStatement(statement, context),
175
174
  containedAssertion = containedAssertionFromStatement(statement, context);
176
175
 
177
- if ((procedureCall !== null) || (definedAssertion !== null) || (containedAssertion !== null)) {
176
+ if ((definedAssertion !== null) || (containedAssertion !== null)) {
178
177
  const statementString = this.string;
179
178
 
180
179
  specificContext.trace(`Unifying the '${statementString}' statement independently...`);
181
180
 
182
- if (procedureCall !== null) {
183
- const procedureCallUnifiedIndependently = procedureCall.unifyIndependently(substitutions, context);
184
-
185
- unifiedIndependently = procedureCallUnifiedIndependently; ///
186
- }
187
-
188
181
  if (definedAssertion !== null) {
189
182
  const definedAssertionUnifiedIndependently = definedAssertion.unifyIndependently(substitutions, context);
190
183
 
@@ -5,12 +5,13 @@ import dom from "../dom";
5
5
  import { domAssigned } from "../dom";
6
6
  import { assignAssignments } from "../utilities/assignments";
7
7
  import { subproofAssertionFromStatement } from "../utilities/verification";
8
- import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
8
+ import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
9
9
 
10
10
  export default domAssigned(class Supposition {
11
- constructor(string, statement) {
11
+ constructor(string, statement, procedureCall) {
12
12
  this.string = string;
13
13
  this.statement = statement;
14
+ this.procedureCall = procedureCall;
14
15
  }
15
16
 
16
17
  getString() {
@@ -21,12 +22,24 @@ export default domAssigned(class Supposition {
21
22
  return this.statement;
22
23
  }
23
24
 
25
+ getProcedureCall() {
26
+ return this.procedureCall;
27
+ }
28
+
24
29
  unifyIndependently(substitutions, generalContext, specificContext) {
25
30
  let unifiedIndependently;
26
31
 
27
- const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
32
+ if (this.statesment !== null) {
33
+ const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
34
+
35
+ unifiedIndependently = statementResolvedIndependently; ///
36
+ }
37
+
38
+ if (this.procedureCall !== null) {
39
+ const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(substitutions, generalContext, specificContext);
28
40
 
29
- unifiedIndependently = statementResolvedIndependently; ///
41
+ unifiedIndependently = procedureCallResolvedIndependently; ///
42
+ }
30
43
 
31
44
  return unifiedIndependently;
32
45
  }
@@ -129,7 +142,9 @@ export default domAssigned(class Supposition {
129
142
 
130
143
  context.trace(`Verifying the '${suppositionString}' supposition...`);
131
144
 
132
- if (this.statement !== null) {
145
+ if (false) {
146
+ ///
147
+ } else if (this.statement !== null) {
133
148
  const stated = true,
134
149
  assignments = [],
135
150
  statementVerified = this.statement.verify(assignments, stated, context);
@@ -147,6 +162,14 @@ export default domAssigned(class Supposition {
147
162
  verified = true;
148
163
  }
149
164
  }
165
+ } else if (this.procedureCall !== null) {
166
+ const stated = true,
167
+ assignments = null,
168
+ procedureCallVerified = this.procedureCall.verify(assignments, stated, context);
169
+
170
+ if (procedureCallVerified) {
171
+ verified = true;
172
+ }
150
173
  } else {
151
174
  context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`);
152
175
  }
@@ -160,9 +183,12 @@ export default domAssigned(class Supposition {
160
183
 
161
184
  toJSON() {
162
185
  const statementJSON = statementToStatementJSON(this.statement),
186
+ procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
163
187
  statement = statementJSON, ///
188
+ procedureCall = procedureCallJSON, ///
164
189
  json = {
165
- statement
190
+ statement,
191
+ procedureCall
166
192
  };
167
193
 
168
194
  return json;
@@ -172,18 +198,39 @@ export default domAssigned(class Supposition {
172
198
 
173
199
  static fromJSON(json, fileContext) {
174
200
  const statement = statementFromJSON(json, fileContext),
175
- string = statement.getString(),
176
- supposition = new Supposition(string, statement);
201
+ procedureCall = procedureCallFromJSON(json, fileContext);
202
+
203
+ let string;
204
+
205
+ if (statement !== null) {
206
+ string = statement.getString();
207
+ }
208
+
209
+ if (procedureCall !== null) {
210
+ string = procedureCall.getString();
211
+ }
212
+
213
+ const supposition = new Supposition(string, statement, procedureCall);
177
214
 
178
215
  return supposition;
179
216
  }
180
217
 
181
218
  static fromSuppositionNode(suppositionNode, fileContext) {
182
- const { Statement } = dom,
219
+ const { Statement, ProcedureCall } = dom,
183
220
  statement = Statement.fromSuppositionNode(suppositionNode, fileContext),
184
- statementString = statement.getString(),
185
- string = statementString, ///
186
- supposition = new Supposition(string, statement);
221
+ procedureCall = ProcedureCall.fromSuppositionNode(suppositionNode, fileContext);
222
+
223
+ let string;
224
+
225
+ if (statement !== null) {
226
+ string = statement.getString();
227
+ }
228
+
229
+ if (procedureCall !== null) {
230
+ string = procedureCall.getString();
231
+ }
232
+
233
+ const supposition = new Supposition(string, statement, procedureCall);
187
234
 
188
235
  return supposition
189
236
  }
@@ -5,7 +5,6 @@ import BracketedCombinator from "../../combinator/bracketed";
5
5
  import { equalityFromStatement,
6
6
  judgementFromStatement,
7
7
  metavariableFromStatement,
8
- procedureCallFromStatement,
9
8
  typeAssertionFromStatement,
10
9
  definedAssertionFromStatement,
11
10
  subproofAssertionFromStatement,
@@ -77,28 +76,6 @@ function verifyAsJudgement(statement, assignments, stated, context) {
77
76
  return verifiedAsJudgement;
78
77
  }
79
78
 
80
- function verifyAsProcedureCall(statement, assignments, stated, context) {
81
- let verifiedAsProcedureCall = false;
82
-
83
- const procedureCall = procedureCallFromStatement(statement, context);
84
-
85
- if (procedureCall !== null) {
86
- const statementString = statement.getString();
87
-
88
- context.trace(`Verifying the '${statementString}' statement as a procedure call...`);
89
-
90
- const procedureCallVerified = procedureCall.verify(assignments, stated, context);
91
-
92
- verifiedAsProcedureCall = procedureCallVerified; ///
93
-
94
- if (verifiedAsProcedureCall) {
95
- context.debug(`...verified the '${statementString}' statement as a procedure call.`);
96
- }
97
- }
98
-
99
- return verifiedAsProcedureCall;
100
- }
101
-
102
79
  function verifyAsTypeAssertion(statement, assignments, stated, context) {
103
80
  let verifiedAsTypeAssertion = false;
104
81
 
@@ -220,7 +197,6 @@ const verifyMixins = [
220
197
  verifyAsEquality,
221
198
  verifyAsJudgement,
222
199
  verifyAsTypeAssertion,
223
- verifyAsProcedureCall,
224
200
  verifyAsDefinedAssertion,
225
201
  verifyAsSubproofAssertion,
226
202
  verifyAsContainedAssertion,
@@ -62,14 +62,16 @@ export function superTypeFromJSON(json, fileContext) {
62
62
  }
63
63
 
64
64
  export function statementFromJSON(json, fileContext) {
65
- let { statement } = json;
65
+ let { statement = null } = json;
66
66
 
67
- const { Statement } = dom,
68
- statementJSON = statement; ///
67
+ if (statement !== null) {
68
+ const { Statement } = dom,
69
+ statementJSON = statement; ///
69
70
 
70
- json = statementJSON; ///
71
+ json = statementJSON; ///
71
72
 
72
- statement = Statement.fromJSON(json, fileContext);
73
+ statement = Statement.fromJSON(json, fileContext);
74
+ }
73
75
 
74
76
  return statement;
75
77
  }
@@ -113,6 +115,21 @@ export function metavariableFromJSON(json, fileContext) {
113
115
  return metavariable;
114
116
  }
115
117
 
118
+ export function procedureCallFromJSON(json, fileContext) {
119
+ let { procedureCall = null } = json;
120
+
121
+ if (procedureCall !== null) {
122
+ const { ProcedureCall } = dom,
123
+ procedureCallJSON = procedureCall; ///
124
+
125
+ json = procedureCallJSON; ///
126
+
127
+ procedureCall = ProcedureCall.fromJSON(json, fileContext);
128
+ }
129
+
130
+ return procedureCall;
131
+ }
132
+
116
133
  export function typesFromJSON(json, types, fileContext) {
117
134
  const { types: typesJSON } = json;
118
135
 
@@ -372,7 +389,11 @@ export function superTypeToSuperTypeJSON(superType) {
372
389
  }
373
390
 
374
391
  export function statementToStatementJSON(statement) {
375
- const statementJSON = statement.toJSON();
392
+ let statementJSON = null;
393
+
394
+ if (statement !== null) {
395
+ statementJSON = statement.toJSON();
396
+ }
376
397
 
377
398
  return statementJSON;
378
399
  }
@@ -395,6 +416,16 @@ export function metavariableToMetavariableJSON(metavariable) {
395
416
  return metavariableJSON;
396
417
  }
397
418
 
419
+ export function procedureCallToProcedureCallJSON(procedureCall) {
420
+ let procedureCallJSON = null;
421
+
422
+ if (procedureCall !== null) {
423
+ procedureCallJSON = procedureCall.toJSON();
424
+ }
425
+
426
+ return procedureCallJSON;
427
+ }
428
+
398
429
  export function typesToTypesJSON(types) {
399
430
  const typesJSON = types.map((type) => {
400
431
  const typeJSON = type.toJSON();
@@ -43,16 +43,6 @@ export function metavariableFromStatement(statement, context) {
43
43
  return metavariable;
44
44
  }
45
45
 
46
- export function procedureCallFromStatement(statement, context) {
47
- context = contextFromStatement(statement, context); ///
48
-
49
- const { ProcedureCall } = dom,
50
- statementNode = statement.getNode(),
51
- procedureCall = ProcedureCall.fromStatementNode(statementNode, context);
52
-
53
- return procedureCall;
54
- }
55
-
56
46
  export function typeAssertionFromStatement(statement, context) {
57
47
  context = contextFromStatement(statement, context); ///
58
48