occam-verify-cli 0.0.1107 → 0.0.1109

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.
@@ -59,6 +59,12 @@ class Metavariable {
59
59
  return metavariableNameMatches;
60
60
  }
61
61
 
62
+ matchMetavariableNode(metavariableNode) {
63
+ const metavariableNodeMatches = metavariableNode.match(this.node);
64
+
65
+ return metavariableNodeMatches;
66
+ }
67
+
62
68
  isEqualTo(metavariable) {
63
69
  let equalTo = false;
64
70
 
@@ -2,24 +2,12 @@
2
2
 
3
3
  import BracketedCombinator from "../../combinator/bracketed";
4
4
 
5
- import { unifyStatementWithCombinator } from "../../utilities/unification";
6
-
7
5
  function unifyWithBracketedCombinator(statement, assignments, stated, context) {
8
6
  let unifiedWithBracketedCombinator;
9
7
 
10
- const statementString = statement.getString();
11
-
12
- context.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
13
-
14
- const bracketedCombinator = BracketedCombinator.fromNothing(),
15
- combinator = bracketedCombinator, ///
16
- statementUnifiedWithCombinator = unifyStatementWithCombinator(statement, combinator, assignments, stated, context);
8
+ const bracketedCombinator = BracketedCombinator.fromNothing();
17
9
 
18
- unifiedWithBracketedCombinator = statementUnifiedWithCombinator;
19
-
20
- if (unifiedWithBracketedCombinator) {
21
- context.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
22
- }
10
+ unifiedWithBracketedCombinator = bracketedCombinator.unifyStatement(statement, assignments, stated, context);
23
11
 
24
12
  return unifiedWithBracketedCombinator;
25
13
  }
@@ -34,7 +22,7 @@ function unifyWithCombinators(statement, assignments, stated, context) {
34
22
  assignments = null; ///
35
23
 
36
24
  unifiedWithCombinators = combinators.some((combinator) => {
37
- const unifiedWithCombinator = unifyWithCombinator(statement, combinator, assignments, stated, context);
25
+ const unifiedWithCombinator = combinator.unifyStatement(statement, assignments, stated, context);
38
26
 
39
27
  if (unifiedWithCombinator) {
40
28
  return true;
@@ -51,22 +39,3 @@ const unifyMixins = [
51
39
  ];
52
40
 
53
41
  export default unifyMixins;
54
-
55
- function unifyWithCombinator(statement, combinator, assignments, stated, context) {
56
- let unifiedWithCombinator;
57
-
58
- const statementString = statement.getString(),
59
- combinatorString = combinator.getString();
60
-
61
- context.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
62
-
63
- const statementUnifiedWithCombinator = unifyStatementWithCombinator(statement, combinator, assignments, stated, context);
64
-
65
- unifiedWithCombinator = statementUnifiedWithCombinator; ///
66
-
67
- if (unifiedWithCombinator) {
68
- context.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
69
- }
70
-
71
- return unifiedWithCombinator;
72
- }
@@ -1,54 +1,13 @@
1
1
  "use strict";
2
2
 
3
- import shim from "../../shim";
4
3
  import BracketedConstructor from "../../constructor/bracketed";
5
4
 
6
- import { nodeQuery } from "../../utilities/query";
7
- import { unifyTermWithConstructor } from "../../utilities/unification";
8
-
9
- const termNodeQuery = nodeQuery("/term/argument/term");
10
-
11
5
  function unifyWithBracketedConstructor(term, context, verifyAhead) {
12
6
  let unifiedWithBracketedConstructor;
13
7
 
14
- const termString = term.getString();
15
-
16
- context.trace(`Unifying the '${termString}' term with the bracketed constructor...`, term);
17
-
18
8
  const bracketedConstructor = BracketedConstructor.fromNothing();
19
9
 
20
- unifiedWithBracketedConstructor = unifyWithConstructor(term, bracketedConstructor, context, () => {
21
- let verifiedAhead = false;
22
-
23
- const { Term } = shim,
24
- bracketedTerm = term, ///
25
- bracketedTermNode = bracketedTerm.getNode(),
26
- termNode = termNodeQuery(bracketedTermNode); ///
27
-
28
- term = Term.fromTermNode(termNode, context);
29
-
30
- if (term !== null) {
31
- const termVVerified = term.verify(context, () => {
32
- let verifiedAhead;
33
-
34
- const type = term.getType();
35
-
36
- bracketedTerm.setType(type);
37
-
38
- verifiedAhead = verifyAhead();
39
-
40
- return verifiedAhead;
41
- });
42
-
43
- verifiedAhead = termVVerified; ///
44
- }
45
-
46
- return verifiedAhead;
47
- });
48
-
49
- if (unifiedWithBracketedConstructor) {
50
- context.debug(`...unified the '${termString}' term with the bracketed constructor.`, term);
51
- }
10
+ unifiedWithBracketedConstructor = bracketedConstructor.unifyTerm(term, context, verifyAhead);
52
11
 
53
12
  return unifiedWithBracketedConstructor;
54
13
  }
@@ -59,7 +18,7 @@ function unifyWithConstructors(term, context, verifyAhead) {
59
18
  const constructors = context.getConstructors();
60
19
 
61
20
  unifiedWithConstructors = constructors.some((constructor) => {
62
- const unifiedWithConstructor = unifyWithConstructor(term, constructor, context, verifyAhead);
21
+ const unifiedWithConstructor = constructor.unifyTerm(term, context, verifyAhead);
63
22
 
64
23
  if (unifiedWithConstructor) {
65
24
  return true;
@@ -75,32 +34,3 @@ const unifyMixins = [
75
34
  ];
76
35
 
77
36
  export default unifyMixins;
78
-
79
- function unifyWithConstructor(term, constructor, context, verifyAhead) {
80
- let unifiedWithConstructor = false;
81
-
82
- const termString = term.getString(),
83
- constructorString = constructor.getString();
84
-
85
- context.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, term);
86
-
87
- const termUnifiedWithConstructor = unifyTermWithConstructor(term, constructor, context);
88
-
89
- if (termUnifiedWithConstructor) {
90
- let verifiedAhead;
91
-
92
- const type = constructor.getType();
93
-
94
- term.setType(type);
95
-
96
- verifiedAhead = verifyAhead();
97
-
98
- unifiedWithConstructor = verifiedAhead; ///
99
- }
100
-
101
- if (unifiedWithConstructor) {
102
- context.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, term);
103
- }
104
-
105
- return unifiedWithConstructor;
106
- }
package/src/reference.js CHANGED
@@ -27,8 +27,16 @@ export default class Reference {
27
27
  return metavariableName;
28
28
  }
29
29
 
30
+ getMetavariableNode() {
31
+ const metavariableNode = this.metavariable.getNode();
32
+
33
+ return metavariableNode;
34
+ }
35
+
30
36
  matchMetavariableName(metavariableName) { return this.metavariable.matchMetavariableName(metavariableName); }
31
37
 
38
+ matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
39
+
32
40
  unifyLabel(label, substitutions, generalContext, specificContext) {
33
41
  let labelUnified;
34
42
 
package/src/rule.js CHANGED
@@ -148,15 +148,9 @@ class Rule {
148
148
 
149
149
  this.fileContext.trace(`Verifying the '${ruleString}' rule...`);
150
150
 
151
- const labelsVerifiedWhenDeclared = this.labels.every((label) => {
152
- const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
151
+ const labelsVerified = this.verifyLabels();
153
152
 
154
- if (labelVVerifiedWhenDeclared) {
155
- return true;
156
- }
157
- });
158
-
159
- if (labelsVerifiedWhenDeclared) {
153
+ if (labelsVerified) {
160
154
  const context = LocalContext.fromFileContext(this.fileContext),
161
155
  premisesVerified = this.premises.every((premise) => {
162
156
  const premiseVerified = premise.verify(context);
@@ -197,6 +191,19 @@ class Rule {
197
191
  return verified;
198
192
  }
199
193
 
194
+ verifyLabels() {
195
+ const labelsVerified = this.labels.every((label) => {
196
+ const nameOnly = true,
197
+ labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext, nameOnly);
198
+
199
+ if (labelVVerifiedWhenDeclared) {
200
+ return true;
201
+ }
202
+ });
203
+
204
+ return labelsVerified;
205
+ }
206
+
200
207
  toJSON() {
201
208
  const labelsJSON = labelsToLabelsJSON(this.labels),
202
209
  premisesJSON = premisesToPremisesJSON(this.premises),
@@ -215,15 +215,9 @@ export default class TopLevelAssertion {
215
215
  verify() {
216
216
  let verified = false;
217
217
 
218
- const labelsVerifiedWhenDeclared = this.labels.every((label) => {
219
- const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
218
+ const labelsVerified = this.verifyLabels();
220
219
 
221
- if (labelVVerifiedWhenDeclared) {
222
- return true;
223
- }
224
- });
225
-
226
- if (labelsVerifiedWhenDeclared) {
220
+ if (labelsVerified) {
227
221
  const localContext = LocalContext.fromFileContext(this.fileContext),
228
222
  context = localContext, ///
229
223
  suppositionsVerified = this.suppositions.every((supposition) => {
@@ -252,6 +246,19 @@ export default class TopLevelAssertion {
252
246
  return verified;
253
247
  }
254
248
 
249
+ verifyLabels() {
250
+ const labelsVerified = this.labels.every((label) => {
251
+ const nameOnly = true,
252
+ labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext, nameOnly);
253
+
254
+ if (labelVVerifiedWhenDeclared) {
255
+ return true;
256
+ }
257
+ });
258
+
259
+ return labelsVerified;
260
+ }
261
+
255
262
  toJSON() {
256
263
  const labelsJSON = labelsToLabelsJSON(this.labels),
257
264
  consequentJSON = consequentToConsequentJSON(this.consequent),