occam-verify-cli 1.0.304 → 1.0.307

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.
@@ -7,10 +7,10 @@ import { domAssigned } from "../dom";
7
7
  import { unifyStatementIntrinsically } from "../utilities/unification";
8
8
 
9
9
  export default domAssigned(class Declaration {
10
- constructor(string, node, reference, statement) {
10
+ constructor(string, node, metavariable, statement) {
11
11
  this.string = string;
12
12
  this.node = node;
13
- this.reference = reference;
13
+ this.metavariable = metavariable;
14
14
  this.statement = statement;
15
15
  }
16
16
 
@@ -22,26 +22,18 @@ export default domAssigned(class Declaration {
22
22
  return this.node;
23
23
  }
24
24
 
25
- getReference() {
26
- return this.reference;
25
+ getMetavariable() {
26
+ return this.metavariable;
27
27
  }
28
28
 
29
29
  getStatement() {
30
30
  return this.statement;
31
31
  }
32
32
 
33
- isSimple() { return this.node.isSimple(); }
34
-
35
- getMetavariable() {
36
- let metavariable = null;
37
-
38
- const simple = this.isSimple();
39
-
40
- if (simple) {
41
- metavariable = this.reference.getMetavariable();
42
- }
33
+ isSimple() {
34
+ const simple = (this.statement === null);
43
35
 
44
- return metavariable;
36
+ return simple;
45
37
  }
46
38
 
47
39
  matchSubstitution(substitution, context) {
@@ -55,8 +47,7 @@ export default domAssigned(class Declaration {
55
47
  const simple = this.isSimple();
56
48
 
57
49
  if (simple) {
58
- const metavariable = this.reference.getMetavariable(),
59
- judgement = context.findJudgementByMetavariable(metavariable);
50
+ const judgement = context.findJudgementByMetavariable(this.metavariable);
60
51
 
61
52
  if (judgement !== null) {
62
53
  const declaration = judgement.getDeclaration();
@@ -67,9 +58,9 @@ export default domAssigned(class Declaration {
67
58
  const statement = substitution.getStatement(),
68
59
  metavariable = substitution.getMetavariable(),
69
60
  statementEqualToStatement = this.statement.isEqualTo(statement),
70
- referenceMetavariableEqualToMetavariable = this.reference.isMetavariableEqualTo(metavariable);
61
+ metavariableEqualToMetavariable = this.metavariable.isEqualTo(metavariable);
71
62
 
72
- if (referenceMetavariableEqualToMetavariable && statementEqualToStatement) {
63
+ if (metavariableEqualToMetavariable && statementEqualToStatement) {
73
64
  substitutionMatches = true;
74
65
  }
75
66
  }
@@ -91,13 +82,13 @@ export default domAssigned(class Declaration {
91
82
  const simple = this.isSimple();
92
83
 
93
84
  if (simple) {
94
- const referenceVerifiesAsMetavariable = this.verifyReferenceAsMetavariable(assignments, stated, context);
85
+ const verifiesAsMetavariable = this.verifyAsMetavariable(assignments, stated, context);
95
86
 
96
- verifies = referenceVerifiesAsMetavariable; ///
87
+ verifies = verifiesAsMetavariable; ///
97
88
  } else {
98
- const referenceVerifies = this.verifyReference(assignments, stated, context);
89
+ const metavariableVerifiesAsReference = this.verifyMetavariableAsReference(assignments, stated, context);
99
90
 
100
- if (referenceVerifies) {
91
+ if (metavariableVerifiesAsReference) {
101
92
  const statementVerifies = this.verifyStatement(assignments, stated, context);
102
93
 
103
94
  if (statementVerifies) {
@@ -124,20 +115,24 @@ export default domAssigned(class Declaration {
124
115
  return verifies;
125
116
  }
126
117
 
127
- verifyReference(assignments, stated, context) {
128
- let referenceVerifies;
118
+ verifyMetavariableAsReference(assignments, stated, context) {
119
+ let metavariableVerifiesAsReference;
129
120
 
130
- const referenceString = this.reference.getString();
121
+ const declarationString = this.string,
122
+ metavariableString = this.metavariable.getString();
131
123
 
132
- context.trace(`Verifying the '${referenceString}' reference...`);
124
+ context.trace(`Verifying the '${declarationString}' declaration's '${metavariableString}' metavariable as a reference...`);
133
125
 
134
- referenceVerifies = this.reference.verify(context);
126
+ const reference = referenceFromMetavariable(this.metavariable, context),
127
+ referenceVerifies = reference.verify(context);
135
128
 
136
- if (referenceVerifies) {
137
- context.debug(`...verified the '${referenceString}' reference.`);
129
+ metavariableVerifiesAsReference = referenceVerifies; ///
130
+
131
+ if (metavariableVerifiesAsReference) {
132
+ context.debug(`...verified the '${declarationString}' declaration's '${metavariableString}' metavariable as a reference.`);
138
133
  }
139
134
 
140
- return referenceVerifies;
135
+ return metavariableVerifiesAsReference;
141
136
  }
142
137
 
143
138
  verifyStatement(assignments, stated, context) {
@@ -164,23 +159,21 @@ export default domAssigned(class Declaration {
164
159
  return statementVerifies;
165
160
  }
166
161
 
167
- verifyReferenceAsMetavariable(assignments, stated, context) {
168
- let referenceVerifiesAsMetavariable;
169
-
170
- const referenceString = this.reference.getString();
162
+ verifyAsMetavariable(assignments, stated, context) {
163
+ let verifiesAsMetavariable;
171
164
 
172
- context.trace(`Verifying the '${referenceString}' reference as a metavariable...`);
165
+ const declarationString = this.string, ///
166
+ metavariableString = this.metavariable.getString();
173
167
 
174
- const metavariable = this.reference.getMetavariable(),
175
- metavariableVerifies = metavariable.verify(context);
168
+ context.trace(`Verifying the '${declarationString}' declaration's '${metavariableString}' metavariable...`);
176
169
 
177
- referenceVerifiesAsMetavariable = metavariableVerifies; ///
170
+ verifiesAsMetavariable = this.metavariable.verify(context);
178
171
 
179
- if (referenceVerifiesAsMetavariable) {
180
- context.debug(`...verified the '${referenceString}' reference as a metavariable.`);
172
+ if (verifiesAsMetavariable) {
173
+ context.debug(`...verified the '${declarationString}' declaration's '${metavariableString}' metavariable.`);
181
174
  }
182
175
 
183
- return referenceVerifiesAsMetavariable;
176
+ return verifiesAsMetavariable;
184
177
  }
185
178
 
186
179
  verifyWhenStated(assignments, context) {
@@ -190,12 +183,13 @@ export default domAssigned(class Declaration {
190
183
 
191
184
  context.trace(`Verifying the '${declarationString}' stated declaration...`);
192
185
 
193
- const metavariablePresent = context.isMetavariablePresentByReference(this.reference);
186
+ const reference = referenceFromMetavariable(this.metavariable, context),
187
+ metavariablePresent = context.isMetavariablePresentByReference(reference);
194
188
 
195
189
  if (metavariablePresent) {
196
190
  verifiesWhenStated = true;
197
191
  } else {
198
- const metaLemmaMetatheorems = context.findMetaLemmaMetatheoremsByReference(this.reference),
192
+ const metaLemmaMetatheorems = context.findMetaLemmaMetatheoremsByReference(reference),
199
193
  metaLemmaMetatheoremsUnify = metaLemmaMetatheorems.every((metaLemmaMetatheorem) => {
200
194
  const metaLemmaMetatheoremUnifies = this.unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context);
201
195
 
@@ -221,7 +215,8 @@ export default domAssigned(class Declaration {
221
215
 
222
216
  context.trace(`Verifying the '${declarationString}' derived declaration...`);
223
217
 
224
- const metaLemmaMetatheoremPresent = context.isMetaLemmaMetatheoremPresentByReference(this.reference);
218
+ const reference = referenceFromMetavariable(this.metavariable, context),
219
+ metaLemmaMetatheoremPresent = context.isMetaLemmaMetatheoremPresentByReference(reference);
225
220
 
226
221
  verifiesWhenDerived = metaLemmaMetatheoremPresent; ///
227
222
 
@@ -235,7 +230,9 @@ export default domAssigned(class Declaration {
235
230
  unifyStatement(statement, substitutions, generalContext, specificContext) {
236
231
  let statementUnifies;
237
232
 
238
- if (this.statement === null) {
233
+ const simple = this.isSimple();
234
+
235
+ if (simple) {
239
236
  statementUnifies = false;
240
237
  } else {
241
238
  const context = generalContext, ///
@@ -258,21 +255,22 @@ export default domAssigned(class Declaration {
258
255
  return statementUnifies;
259
256
  }
260
257
 
261
- unifyLabelWithReference(label, substitutions, generalContext, specificContext) {
258
+ unifyLabel(label, substitutions, generalContext, specificContext) {
262
259
  let labelUnifiesWithReference;
263
260
 
264
261
  const context = generalContext, ///
265
262
  labelString = label.getString(),
266
- referenceString = this.reference.getString();
263
+ declarationString = this.string; //;/
267
264
 
268
- context.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
265
+ context.trace(`Unifying the '${labelString}' label with the '${declarationString}' declaration...`);
269
266
 
270
- const labelUnifies = this.reference.unifyLabel(label, substitutions, context);
267
+ const reference = referenceFromMetavariable(this.metavariable, context),
268
+ labelUnifies = reference.unifyLabel(label, substitutions, context);
271
269
 
272
270
  labelUnifiesWithReference = labelUnifies; ///
273
271
 
274
272
  if (labelUnifiesWithReference) {
275
- context.debug(`...unified the '${labelString}' label with the '${referenceString}' reference.`);
273
+ context.debug(`...unified the '${labelString}' label with the '${declarationString}' declaration.`);
276
274
  }
277
275
 
278
276
  return labelUnifiesWithReference;
@@ -294,9 +292,9 @@ export default domAssigned(class Declaration {
294
292
  labelSubstitutions = Substitutions.fromNothing(),
295
293
  label = metaLemmaMetatheorem.getLabel(),
296
294
  substitutions = labelSubstitutions, ///
297
- labelUnifiesWithReference = this.unifyLabelWithReference(label, substitutions, generalContext, specificContext);
295
+ labelUnifies = this.unifyLabel(label, substitutions, generalContext, specificContext);
298
296
 
299
- if (labelUnifiesWithReference) {
297
+ if (labelUnifies) {
300
298
  const statementSubstitutions = Substitutions.fromNothing(),
301
299
  statement = metaLemmaMetatheorem.getStatement(),
302
300
  substitutions = statementSubstitutions, ///
@@ -334,13 +332,21 @@ export default domAssigned(class Declaration {
334
332
  }
335
333
  });
336
334
 
335
+ function referenceFromMetavariable(metavariable, context) {
336
+ const { Reference } = dom,
337
+ metavariableNode = metavariable.getNode(),
338
+ reference = Reference.fromMetavariableNode(metavariableNode, context);
339
+
340
+ return reference;
341
+ }
342
+
337
343
  function declarationFromDeclarationNode(declarationNode, context) {
338
- const { Declaration, Reference, Statement } = dom,
344
+ const { Metavariable, Declaration, Statement } = dom,
339
345
  node = declarationNode, ///
340
346
  string = context.nodeAsString(node),
341
- reference = Reference.fromDeclarationNode(declarationNode, context),
347
+ metavariable = Metavariable.fromDeclarationNode(declarationNode, context),
342
348
  statement = Statement.fromDeclarationNode(declarationNode, context),
343
- declaration = new Declaration(string, node, reference, statement);
349
+ declaration = new Declaration(string, node, metavariable, statement);
344
350
 
345
351
  return declaration;
346
352
  }
@@ -398,6 +398,13 @@ export default domAssigned(class Metavariable {
398
398
  return metavariable;
399
399
  }
400
400
 
401
+ static fromDeclarationNode(declarationNode, context) {
402
+ const metavariableNode = declarationNode.getMetavariableNode(),
403
+ metavariable = metavariableFromMetavariableNode(metavariableNode, context);
404
+
405
+ return metavariable;
406
+ }
407
+
401
408
  static fromMetavariableNode(metavariableNode, context) {
402
409
  let metavariable = null;
403
410
 
@@ -71,7 +71,7 @@ export default domAssigned(class ProcedureCall {
71
71
  }
72
72
 
73
73
  unifyIndependently(substitutions, context) {
74
- let unifiesIndependently;
74
+ let unifiesIndependently = false;
75
75
 
76
76
  const procedureCallString = this.string; ///
77
77
 
@@ -195,13 +195,6 @@ export default domAssigned(class Reference {
195
195
  return reference;
196
196
  }
197
197
 
198
- static fromDeclarationNode(declarationNode, context) {
199
- const metavariableNode = declarationNode.getMetavariableNode(),
200
- reference = referenceFromMetavariableNode(metavariableNode, context);
201
-
202
- return reference;
203
- }
204
-
205
198
  static fromMetavariableNode(metavariableNode, context) {
206
199
  const reference = referenceFromMetavariableNode(metavariableNode, context);
207
200
 
@@ -5,13 +5,6 @@ import NonTerminalNode from "../node/nonTerminal";
5
5
  import { STATEMENT_RULE_NAME, METAVARIABLE_RULE_NAME } from "../ruleNames";
6
6
 
7
7
  export default class DeclarationNode extends NonTerminalNode {
8
- isSimple() {
9
- const statementNode = this.getStatementNode(),
10
- simple = (statementNode === null);
11
-
12
- return simple;
13
- }
14
-
15
8
  getStatementNode() {
16
9
  const ruleName = STATEMENT_RULE_NAME,
17
10
  statementNode = this.getNodeByRuleName(ruleName);
package/src/node/frame.js CHANGED
@@ -19,9 +19,23 @@ export default class FrameNode extends NonTerminalNode {
19
19
  return metavariableNodes;
20
20
  }
21
21
 
22
+ getSingularDeclarationNode() {
23
+ const ruleName = DECLARATION_RULE_NAME,
24
+ singularDeclarationNode = this.getSingularTNodeByRuleName(ruleName);
25
+
26
+ return singularDeclarationNode;
27
+ }
28
+
22
29
  getSingularMetavariableNode() {
23
- const ruleName = METAVARIABLE_RULE_NAME,
24
- singularMetavariableNode = this.getSingularTNodeByRuleName(ruleName);
30
+ let singularMetavariableNode = null;
31
+
32
+ const singularDeclarationNode = this.getSingularDeclarationNode();
33
+
34
+ if (singularDeclarationNode !== null) {
35
+ const metavariableNode = singularDeclarationNode.getMetavariableNode();
36
+
37
+ singularMetavariableNode = metavariableNode; ///
38
+ }
25
39
 
26
40
  return singularMetavariableNode;
27
41
  }
@@ -122,13 +122,6 @@ export default class StatementNode extends NonTerminalNode {
122
122
  return satisfiedAssertionNode;
123
123
  }
124
124
 
125
- getSingularMetavariableNode() {
126
- const ruleName = METAVARIABLE_RULE_NAME,
127
- singularMetavariableNode = this.getSingularTNodeByRuleName(ruleName);
128
-
129
- return singularMetavariableNode;
130
- }
131
-
132
125
  getSingularMetaArgumentNode() {
133
126
  const ruleName = META_ARGUMENT_RULE_NAME,
134
127
  singularMetaArgumentNode = this.getNodeByRuleName(ruleName);
@@ -9,8 +9,8 @@ const termNodeQuery = nodeQuery("/term"),
9
9
  frameNodeQuery = nodeQuery("/frame"),
10
10
  statementNodeQuery = nodeQuery("/statement"),
11
11
  termVariableNodeQuery = nodeQuery("/term/variable!"),
12
- frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
13
- declarationMetavariableNodeQuery = nodeQuery("/declaration/metavariable!");
12
+ statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
13
+ frameDeclarationMetavariableNodeQuery = nodeQuery("/frame/declaration!/metavariable!");
14
14
 
15
15
  class MetaLevelUnifier extends Unifier {
16
16
  unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
@@ -25,83 +25,50 @@ class MetaLevelUnifier extends Unifier {
25
25
 
26
26
  static maps = [
27
27
  {
28
- generalNodeQuery: statementNodeQuery,
28
+ generalNodeQuery: statementMetavariableNodeQuery,
29
29
  specificNodeQuery: statementNodeQuery,
30
- unify: (generalStatementNode, specificStatementNode, substitutions, generalContext, specificContext) => {
30
+ unify: (generalStatementMetavariableNode, specificStatementNode, substitutions, generalContext, specificContext) => {
31
31
  let statementUnifies;
32
32
 
33
- const statementNode = generalStatementNode, ///
34
- singularMetavariableNode = statementNode.getSingularMetavariableNode();
33
+ const { Metavariable, Statement } = dom; ///
35
34
 
36
- if (singularMetavariableNode !== null) {
37
- const { Metavariable, Statement } = dom; ///
35
+ let context,
36
+ statementNode;
38
37
 
39
- let context,
40
- statementNode;
38
+ context = generalContext; ///
41
39
 
42
- context = generalContext; ///
40
+ const metavariableNode = generalStatementMetavariableNode, ///
41
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, context);
43
42
 
44
- statementNode = generalStatementNode; ///
43
+ const metavariableNodeParentNode = metavariableNode.getParentNode();
45
44
 
46
- const { TermSubstitution, FrameSubstitution } = dom,
47
- frameSubstitution = FrameSubstitution.fromStatementNode(statementNode, context),
48
- termSubstitution = TermSubstitution.fromStatementNode(statementNode, context),
49
- metavariable = Metavariable.fromStatementNode(statementNode, context),
50
- substitution = (frameSubstitution || termSubstitution);
45
+ statementNode = metavariableNodeParentNode; ///
51
46
 
52
- context = specificContext; ///
47
+ const { TermSubstitution, FrameSubstitution } = dom,
48
+ frameSubstitution = FrameSubstitution.fromStatementNode(statementNode, context),
49
+ termSubstitution = TermSubstitution.fromStatementNode(statementNode, context),
50
+ substitution = (frameSubstitution || termSubstitution);
53
51
 
54
- statementNode = specificStatementNode; ///
52
+ context = specificContext; ///
55
53
 
56
- const statement = Statement.fromStatementNode(statementNode, context);
54
+ statementNode = specificStatementNode; ///
57
55
 
58
- statementUnifies = metavariable.unifyStatement(statement, substitution, substitutions, generalContext, specificContext);
59
- } else {
60
- const childNodesUnify = unifyChildNodes(generalStatementNode, specificStatementNode, substitutions, generalContext, specificContext);
56
+ const statement = Statement.fromStatementNode(statementNode, context);
61
57
 
62
- statementUnifies = childNodesUnify; ///
63
- }
58
+ statementUnifies = metavariable.unifyStatement(statement, substitution, substitutions, generalContext, specificContext);
64
59
 
65
60
  return statementUnifies;
66
61
  }
67
62
  },
68
63
  {
69
- generalNodeQuery: declarationMetavariableNodeQuery,
70
- specificNodeQuery: declarationMetavariableNodeQuery,
71
- unify: (generalDeclarationMetavariableNode, specificDeclarationMetavariableNode, substitutions, generalContext, specificContext) => {
72
- let referenceUnifies;
73
-
74
- const { Frame, Metavariable } = dom;
75
-
76
- let context,
77
- metavariableNode;
78
-
79
- context = generalContext; ///
80
-
81
- metavariableNode = generalDeclarationMetavariableNode; ///
82
-
83
- const metavariable = Metavariable.fromMetavariableNode(metavariableNode, context);
84
-
85
- context = specificContext; ///
86
-
87
- metavariableNode = specificDeclarationMetavariableNode; ///
88
-
89
- const frame = Frame.fromMetavariableNode(metavariableNode, context);
90
-
91
- referenceUnifies = metavariable.unifyFrame(frame, substitutions, generalContext, specificContext);
92
-
93
- return referenceUnifies;
94
- }
95
- },
96
- {
97
- generalNodeQuery: frameMetavariableNodeQuery,
64
+ generalNodeQuery: frameDeclarationMetavariableNodeQuery,
98
65
  specificNodeQuery: frameNodeQuery,
99
- unify: (generalFrameMetavariableNode, specificFrameNode, substitutions, generalContext, specificContext) => {
66
+ unify: (generalFrameDeclarationMetavariableNode, specificFrameNode, substitutions, generalContext, specificContext) => {
100
67
  let frameUnifies;
101
68
 
102
69
  const { Frame, Metavariable } = dom,
103
70
  frameNode = specificFrameNode, ///
104
- metavariableNode = generalFrameMetavariableNode; ///
71
+ metavariableNode = generalFrameDeclarationMetavariableNode; ///
105
72
 
106
73
  let context;
107
74
 
@@ -149,15 +116,3 @@ class MetaLevelUnifier extends Unifier {
149
116
  const metaLevelUnifier = new MetaLevelUnifier();
150
117
 
151
118
  export default metaLevelUnifier;
152
-
153
- function unifyChildNodes(generalStatementNode, specificStatementNode, substitutions, generalContext, specificContext) {
154
- const generalNonTerminalNode = generalStatementNode, ///
155
- specificNonTerminalNode = specificStatementNode, ///
156
- generalNonTerminalNodeChildNodes = generalNonTerminalNode.getChildNodes(),
157
- specificNonTerminalNodeChildNodes = specificNonTerminalNode.getChildNodes(),
158
- generalChildNodes = generalNonTerminalNodeChildNodes, ///
159
- specificChildNodes = specificNonTerminalNodeChildNodes, ///
160
- childNodesUnify = metaLevelUnifier.unifyChildNodes(generalChildNodes, specificChildNodes, substitutions, generalContext, specificContext);
161
-
162
- return childNodesUnify;
163
- }