occam-verify-cli 0.0.1094 → 0.0.1096

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.
Files changed (95) hide show
  1. package/lib/assertion/contained.js +21 -5
  2. package/lib/assertion/defined.js +11 -4
  3. package/lib/assertion/subproof.js +16 -10
  4. package/lib/axiom.js +4 -4
  5. package/lib/combinator/bracketed.js +5 -28
  6. package/lib/conclusion.js +7 -1
  7. package/lib/conjecture.js +4 -4
  8. package/lib/consequent.js +7 -1
  9. package/lib/constructor/bracketed.js +5 -28
  10. package/lib/context/bracketed/combinator.js +118 -0
  11. package/lib/context/bracketed/constructor.js +118 -0
  12. package/lib/context/bracketted.js +98 -0
  13. package/lib/context/file.js +44 -40
  14. package/lib/context/local.js +13 -13
  15. package/lib/declaration.js +122 -7
  16. package/lib/frame.js +26 -16
  17. package/lib/judgement.js +8 -23
  18. package/lib/label.js +8 -9
  19. package/lib/lemma.js +4 -4
  20. package/lib/metaLemma.js +41 -7
  21. package/lib/metatheorem.js +37 -2
  22. package/lib/metavariable.js +13 -13
  23. package/lib/mixins/statement/qualified/unify.js +2 -2
  24. package/lib/nodeAndTokens/metavariable.js +5 -6
  25. package/lib/nodeAndTokens/statement.js +7 -20
  26. package/lib/nodeAndTokens/substitution/frame.js +4 -5
  27. package/lib/nodeAndTokens/substitution/statement.js +4 -5
  28. package/lib/nodeAndTokens/substitution/term.js +4 -5
  29. package/lib/nodeAndTokens/term.js +5 -6
  30. package/lib/nodeAndTokens/variable.js +5 -6
  31. package/lib/premise.js +9 -3
  32. package/lib/reference.js +23 -9
  33. package/lib/rule.js +13 -7
  34. package/lib/statement/qualified.js +4 -3
  35. package/lib/statement/unqualified.js +29 -23
  36. package/lib/statement.js +9 -7
  37. package/lib/substitution/frame.js +2 -2
  38. package/lib/substitution/statement.js +4 -4
  39. package/lib/substitution/term.js +2 -2
  40. package/lib/substitutions.js +9 -2
  41. package/lib/topLevelAssertion.js +13 -25
  42. package/lib/unifier/equality.js +5 -5
  43. package/lib/unifier/label.js +146 -0
  44. package/lib/unifier/metaLevel.js +7 -7
  45. package/lib/unifier.js +4 -4
  46. package/lib/variable.js +8 -5
  47. package/package.json +1 -1
  48. package/src/assertion/contained.js +22 -6
  49. package/src/assertion/defined.js +11 -5
  50. package/src/assertion/subproof.js +17 -12
  51. package/src/axiom.js +3 -2
  52. package/src/combinator/bracketed.js +5 -41
  53. package/src/conclusion.js +2 -0
  54. package/src/conjecture.js +3 -2
  55. package/src/consequent.js +2 -0
  56. package/src/constructor/bracketed.js +5 -40
  57. package/src/context/bracketed/combinator.js +23 -0
  58. package/src/context/bracketed/constructor.js +23 -0
  59. package/src/context/bracketted.js +61 -0
  60. package/src/context/file.js +57 -48
  61. package/src/context/local.js +4 -4
  62. package/src/declaration.js +130 -6
  63. package/src/frame.js +30 -15
  64. package/src/judgement.js +7 -35
  65. package/src/label.js +3 -14
  66. package/src/lemma.js +3 -2
  67. package/src/metaLemma.js +60 -12
  68. package/src/metatheorem.js +56 -2
  69. package/src/metavariable.js +19 -13
  70. package/src/mixins/statement/qualified/unify.js +3 -1
  71. package/src/nodeAndTokens/metavariable.js +3 -7
  72. package/src/nodeAndTokens/statement.js +1 -13
  73. package/src/nodeAndTokens/substitution/frame.js +1 -6
  74. package/src/nodeAndTokens/substitution/statement.js +1 -6
  75. package/src/nodeAndTokens/substitution/term.js +1 -6
  76. package/src/nodeAndTokens/term.js +3 -7
  77. package/src/nodeAndTokens/variable.js +3 -7
  78. package/src/premise.js +15 -3
  79. package/src/reference.js +30 -19
  80. package/src/rule.js +7 -5
  81. package/src/statement/qualified.js +3 -3
  82. package/src/statement/unqualified.js +32 -30
  83. package/src/statement.js +9 -9
  84. package/src/substitution/frame.js +1 -2
  85. package/src/substitution/statement.js +3 -6
  86. package/src/substitution/term.js +1 -2
  87. package/src/substitutions.js +7 -1
  88. package/src/topLevelAssertion.js +10 -22
  89. package/src/unifier/equality.js +14 -16
  90. package/src/unifier/label.js +57 -0
  91. package/src/unifier/metaLevel.js +6 -6
  92. package/src/unifier.js +4 -4
  93. package/src/variable.js +13 -7
  94. package/lib/unifier/intrinsicLevel.js +0 -149
  95. package/src/unifier/intrinsicLevel.js +0 -61
package/src/statement.js CHANGED
@@ -106,8 +106,7 @@ class Statement {
106
106
  resolveIndependently(substitutions, generalContext, specificContext) {
107
107
  let resolvedIndependently;
108
108
 
109
- const statement = this, ///
110
- statementString = this.string; ///
109
+ const statementString = this.string; ///
111
110
 
112
111
  specificContext.trace(`Resolving the '${statementString}' statement independently...`);
113
112
 
@@ -117,7 +116,8 @@ class Statement {
117
116
  generalContext = localContext; ///
118
117
 
119
118
  const resolved = resolveMixins.some((resolveMixin) => {
120
- const resolved = resolveMixin(statement, substitutions, generalContext, specificContext);
119
+ const statement = this, ///
120
+ resolved = resolveMixin(statement, substitutions, generalContext, specificContext);
121
121
 
122
122
  if (resolved) {
123
123
  return true;
@@ -166,14 +166,14 @@ class Statement {
166
166
  verify(assignments, stated, context) {
167
167
  let verified = false;
168
168
 
169
- const statement = this, ///
170
- statementString = this.string; ///
169
+ const statementString = this.string; ///
171
170
 
172
171
  context.trace(`Verifying the '${statementString}' statement...`);
173
172
 
174
173
  if (!verified) {
175
174
  verified = verifyMixins.some((verifyMixin) => {
176
- const verified = verifyMixin(statement, assignments, stated, context);
175
+ const statement = this, ///
176
+ verified = verifyMixin(statement, assignments, stated, context);
177
177
 
178
178
  if (verified) {
179
179
  return true;
@@ -183,7 +183,8 @@ class Statement {
183
183
 
184
184
  if (!verified) {
185
185
  const unified = unifyMixins.some((unifyMixin) => {
186
- const unified = unifyMixin(statement, assignments, stated, context);
186
+ const statement = this, ///
187
+ unified = unifyMixin(statement, assignments, stated, context);
187
188
 
188
189
  if (unified) {
189
190
  return true;
@@ -252,8 +253,7 @@ class Statement {
252
253
  static fromJSON(json, fileContext) {
253
254
  const { string } = json,
254
255
  context = fileContext, ///
255
- statementString = string, ///
256
- statementNodeAndTokens = StatementNodeAndTokens.fromStatementString(statementString, context),
256
+ statementNodeAndTokens = StatementNodeAndTokens.fromString(string, context),
257
257
  node = statementNodeAndTokens.getNode(),
258
258
  tokens = statementNodeAndTokens.getTokens(),
259
259
  statement = new Statement(string, node, tokens);
@@ -108,8 +108,7 @@ export default class FrameSubstitution extends Substitution {
108
108
 
109
109
  static fromFrameAndMetavariable(frame, metavariable, context) {
110
110
  const string = stringFromFrameAndMetavariable(frame, metavariable),
111
- frameSubstitutionString = string, ///
112
- frameSubstitutionNodeAndTokens = FrameSubstitutionNodeAndTokens.fromFrameSubstitutionString(frameSubstitutionString, context),
111
+ frameSubstitutionNodeAndTokens = FrameSubstitutionNodeAndTokens.fromString(string, context),
113
112
  node = frameSubstitutionNodeAndTokens.getNode(),
114
113
  tokens = frameSubstitutionNodeAndTokens.getTokens(),
115
114
  frameSubstitution = new FrameSubstitution(string, node, tokens, frame, metavariable);
@@ -209,8 +209,7 @@ class StatementSubstitution extends Substitution {
209
209
  static fromJSON(json, fileContext) {
210
210
  const { string } = json,
211
211
  context = fileContext, ///
212
- statementSubstitutionString = string, ///
213
- statementSubstitutionNodeAndTokens = StatementSubstitutionNodeAndTokens.fromStatementSubstitutionString(statementSubstitutionString, context),
212
+ statementSubstitutionNodeAndTokens = StatementSubstitutionNodeAndTokens.fromString(string, context),
214
213
  node = statementSubstitutionNodeAndTokens.getNode(),
215
214
  tokens = statementSubstitutionNodeAndTokens.getTokens(),
216
215
  resolved = true,
@@ -232,8 +231,7 @@ class StatementSubstitution extends Substitution {
232
231
  statement = Statement.fromStatementNode(statementNode, context);
233
232
 
234
233
  const string = stringFromStatementAndMetavariable(statement, metavariable),
235
- statementSubstitutionString = string, ///
236
- statementSubstitutionNodeAndTokens = StatementSubstitutionNodeAndTokens.fromStatementSubstitutionString(statementSubstitutionString, context),
234
+ statementSubstitutionNodeAndTokens = StatementSubstitutionNodeAndTokens.fromString(string, context),
237
235
  node = statementSubstitutionNodeAndTokens.getNode(),
238
236
  tokens = statementSubstitutionNodeAndTokens.getTokens(),
239
237
  resolved = true,
@@ -253,8 +251,7 @@ class StatementSubstitution extends Substitution {
253
251
  statement = Statement.fromStatementNode(statementNode, context);
254
252
 
255
253
  const string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context),
256
- statementSubstitutionString = string, ///
257
- statementSubstitutionNodeAndTokens = StatementSubstitutionNodeAndTokens.fromStatementSubstitutionString(statementSubstitutionString, context),
254
+ statementSubstitutionNodeAndTokens = StatementSubstitutionNodeAndTokens.fromString(string, context),
258
255
  node = statementSubstitutionNodeAndTokens.getNode(),
259
256
  tokens = statementSubstitutionNodeAndTokens.getTokens(),
260
257
  resolved = false,
@@ -119,8 +119,7 @@ export default class TermSubstitution extends Substitution {
119
119
  term = Term.fromTermNode(termNode, context);
120
120
 
121
121
  const string = stringFromTermAndVariable(term, variable),
122
- termSubstitutionString = string, ///
123
- termSubstitutionNodeAndTokens = TermSubstitutionNodeAndTokens.fromTermSubstitutionString(termSubstitutionString, context),
122
+ termSubstitutionNodeAndTokens = TermSubstitutionNodeAndTokens.fromString(string, context),
124
123
  node = termSubstitutionNodeAndTokens.getNode(),
125
124
  tokens = termSubstitutionNodeAndTokens.getTokens(),
126
125
  termSubstitution = new TermSubstitution(string, node, tokens, term, variable);
@@ -6,7 +6,7 @@ import { arrayUtilities } from "necessary";
6
6
 
7
7
  import { EMPTY_STRING } from "./constants";
8
8
 
9
- const { find, first, prune, filter, compress } = arrayUtilities;
9
+ const { find, first, clear, prune, filter, compress } = arrayUtilities;
10
10
 
11
11
  class Substitutions {
12
12
  constructor(array, savedArray) {
@@ -211,6 +211,12 @@ class Substitutions {
211
211
  return unifiedWithEquivalences;
212
212
  }
213
213
 
214
+ clear() {
215
+ clear(this.array);
216
+
217
+ this.savedArray = null;
218
+ }
219
+
214
220
  resolve(generalContext, specificContext) {
215
221
  const metavariableNodes = this.getMetavariableNodes();
216
222
 
@@ -62,41 +62,29 @@ export default class TopLevelAssertion {
62
62
  return this.proof;
63
63
  }
64
64
 
65
- getStatement() { return this.proof.getStatement(); }
65
+ matchStatementNode(statementNode) { return this.consequent.matchStatementNode(statementNode); }
66
66
 
67
- matchMetavariableNode(metavariableNode) {
68
- const metavariableNodeMatches = this.labels.some((label) => {
69
- const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
67
+ matchMetavariableName(metavariableName) {
68
+ const metavariableNameMatches = this.labels.some((label) => {
69
+ const metavariableNameMatches = label.matchMetavariableName(metavariableName);
70
70
 
71
- if (metavariableNodeMatches) {
71
+ if (metavariableNameMatches) {
72
72
  return true;
73
73
  }
74
74
  });
75
75
 
76
- return metavariableNodeMatches;
77
- }
78
-
79
- unifyReference(reference, generalContext, specificContext) {
80
- const referenceUnified = this.labels.some((label) => {
81
- const referenceUnified = label.unifyReference(reference, generalContext, specificContext);
82
-
83
- if (referenceUnified) {
84
- return true;
85
- }
86
- });
87
-
88
- return referenceUnified;
76
+ return metavariableNameMatches;
89
77
  }
90
78
 
91
79
  unifyStatement(statement, context) {
92
80
  let statementUnified;
93
81
 
94
82
  const { Substitutions } = shim,
95
- substitutions = Substitutions.fromNothing(),
96
- consequentUnified = this.unifyConsequent(statement, substitutions, context);
83
+ substitutions = Substitutions.fromNothing(),
84
+ consequentUnified = this.unifyConsequent(statement, substitutions, context);
97
85
 
98
86
  if (consequentUnified) {
99
- const suppositionsUnified = this.unifySupposition(substitutions, context);
87
+ const suppositionsUnified = this.unifySuppositions(substitutions, context);
100
88
 
101
89
  if (suppositionsUnified) {
102
90
  const substitutionsResolved = substitutions.areResolved();
@@ -126,7 +114,7 @@ export default class TopLevelAssertion {
126
114
  return consequentUnified;
127
115
  }
128
116
 
129
- unifySupposition(substitutions, context) {
117
+ unifySuppositions(substitutions, context) {
130
118
  let proofSteps = context.getProofSteps();
131
119
 
132
120
  proofSteps = reverse(proofSteps); ///
@@ -11,9 +11,9 @@ class EqualityUnifier extends Unifier {
11
11
  unify(leftTermNode, rightTermNode, context) {
12
12
  let equalityUnified;
13
13
 
14
- const nonTerminalNodeA = leftTermNode, ///
15
- nonTerminalNodeB = rightTermNode, ///
16
- nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context);
14
+ const leftNonTerminalNode = leftTermNode, ///
15
+ rightNonTerminalNode = rightTermNode, ///
16
+ nonTerminalNodeUnified = this.unifyNonTerminalNode(leftNonTerminalNode, rightNonTerminalNode, context);
17
17
 
18
18
  equalityUnified = nonTerminalNodeUnified; ///
19
19
 
@@ -22,14 +22,12 @@ class EqualityUnifier extends Unifier {
22
22
 
23
23
  static maps = [
24
24
  {
25
- generalNodeQuery: termNodeQuery,
26
- specificNodeQuery: termNodeQuery,
27
- unify: (termNodeA, termNodeB, context) => {
25
+ generalNodeQuery: termNodeQuery, ///
26
+ specificNodeQuery: termNodeQuery, ///
27
+ unify: (leftTermNode, rightTermNode, context) => {
28
28
  let termUnifiedWithTerm;
29
29
 
30
- const leftTermNode = termNodeA, ///
31
- rightTermNode = termNodeB, ///
32
- leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode);
30
+ const leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode);
33
31
 
34
32
  if (leftTermNodeMatchesRightTermNode) {
35
33
  termUnifiedWithTerm = true;
@@ -45,13 +43,13 @@ class EqualityUnifier extends Unifier {
45
43
  }
46
44
 
47
45
  if (!termUnifiedWithTerm) {
48
- const nonTerminalNodeA = termNodeA, ///
49
- nonTerminalNodeB = termNodeB, ///
50
- nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
51
- nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
52
- childNodesA = nonTerminalNodeAChildNodes, ///
53
- childNodesB = nonTerminalNodeBChildNodes, ///
54
- childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB, context);
46
+ const leftNonTerminalNode = leftTermNode, ///
47
+ rightNonTerminalNode = rightTermNode, ///
48
+ leftNonTerminalNodeChildNodes = leftNonTerminalNode.getChildNodes(),
49
+ rightNonTerminalNodeChildNodes = rightNonTerminalNode.getChildNodes(),
50
+ leftChildNodes = leftNonTerminalNodeChildNodes, ///
51
+ rightChildNodes = rightNonTerminalNodeChildNodes, ///
52
+ childNodesVerified = equalityUnifier.unifyChildNodes(leftChildNodes, rightChildNodes, context);
55
53
 
56
54
  termUnifiedWithTerm = childNodesVerified; ///
57
55
  }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ import shim from "../shim";
4
+ import Unifier from "../unifier";
5
+
6
+ import { nodeQuery } from "../utilities/query";
7
+ import { variableNameFromVariableNode } from "../utilities/name";
8
+
9
+ const termNodeQuery = nodeQuery("/term"),
10
+ termVariableNodeQuery = nodeQuery("/term/variable!");
11
+
12
+ class LabelUnifier extends Unifier {
13
+ unify(labelMetavariableNode, referenceMetavariableNode, substitutions, generalContext, specificContext) {
14
+ let labelUnified;
15
+
16
+ const generalNonTerminalNode = labelMetavariableNode, ///
17
+ specificNonTerminalNode = referenceMetavariableNode, ///
18
+ nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
19
+
20
+ labelUnified = nonTerminalNodeUnified; ///
21
+
22
+ return labelUnified;
23
+ }
24
+
25
+ static maps = [
26
+ {
27
+ generalNodeQuery: termNodeQuery,
28
+ specificNodeQuery: termVariableNodeQuery,
29
+ unify: (generalTermNode, specificTermVariableNode, substitutions, generalContext, specificContext) => {
30
+ let termUnified;
31
+
32
+ let context;
33
+
34
+ const { Term, Variable } = shim,
35
+ termNode = generalTermNode, ///
36
+ variableNode = specificTermVariableNode; ///
37
+
38
+ context = specificContext; ///
39
+
40
+ const variable = Variable.fromVariableNode(variableNode, context);
41
+
42
+ context = generalContext; ///
43
+
44
+ const term = Term.fromTermNode(termNode, context),
45
+ contextsReversed = true;
46
+
47
+ termUnified = variable.unifyTerm(term, substitutions, generalContext, specificContext, contextsReversed);
48
+
49
+ return termUnified;
50
+ }
51
+ }
52
+ ];
53
+ }
54
+
55
+ const labelUnifier = new LabelUnifier();
56
+
57
+ export default labelUnifier;
@@ -64,7 +64,7 @@ class MetaLevelUnifier extends Unifier {
64
64
 
65
65
  const statement = Statement.fromStatementNode(statementNode, context);
66
66
 
67
- statementUnified = metavariable.unifyStatement(statement, substitution, substitutions, generalContext, specificContext);
67
+ statementUnified = metavariable.unifyStatement(statement, substitution, substitutions, context);
68
68
  } else {
69
69
  statementUnified = unifyChildNodes(generalStatementNode, specificStatementNode, substitutions, generalContext, specificContext);
70
70
  }
@@ -80,7 +80,7 @@ class MetaLevelUnifier extends Unifier {
80
80
  let frameUnified = false;
81
81
 
82
82
  const metavariableNode = generalFrameMetavariableNode, ///
83
- metavariablePresent = generalContext.isMetavariablePresentByMetavariableNode(metavariableNode, generalContext, specificContext);
83
+ metavariablePresent = generalContext.isMetavariablePresentByMetavariableNode(metavariableNode, specificContext);
84
84
 
85
85
  if (metavariablePresent) {
86
86
  let context;
@@ -96,7 +96,7 @@ class MetaLevelUnifier extends Unifier {
96
96
 
97
97
  const frame = Frame.fromFrameNode(frameNode, context);
98
98
 
99
- frameUnified = metavariable.unifyFrame(frame, substitutions, generalContext, specificContext);
99
+ frameUnified = metavariable.unifyFrame(frame, substitutions, context);
100
100
  }
101
101
 
102
102
  return frameUnified;
@@ -105,10 +105,10 @@ class MetaLevelUnifier extends Unifier {
105
105
  {
106
106
  generalNodeQuery: termVariableNodeQuery,
107
107
  specificNodeQuery: termNodeQuery,
108
- unify: (termVariableNodeA, termNodeB, substitutions, generalContext, specificContext) => {
108
+ unify: (generalTermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
109
109
  let termUnified = false;
110
110
 
111
- const variableNode = termVariableNodeA, ///
111
+ const variableNode = generalTermVariableNode, ///
112
112
  variableName = variableNameFromVariableNode(variableNode),
113
113
  variablePresent = generalContext.isVariablePresentByVariableName(variableName);
114
114
 
@@ -116,7 +116,7 @@ class MetaLevelUnifier extends Unifier {
116
116
  let context;
117
117
 
118
118
  const { Term, Variable } = shim,
119
- termNode = termNodeB; ///
119
+ termNode = specificTermNode; ///
120
120
 
121
121
  context = generalContext; ///
122
122
 
package/src/unifier.js CHANGED
@@ -114,13 +114,13 @@ export default class Unifier {
114
114
  let nonTerminalNodeUnified;
115
115
 
116
116
  const generalNonTerminalNodeRuleName = generalNonTerminalNode.getRuleName(), ///
117
- specificNonTerminalNodeBRuleNam = specificNonTerminalNode.getRuleName(); ///
117
+ specificNonTerminalNodeRuleName = specificNonTerminalNode.getRuleName(); ///
118
118
 
119
- if (generalNonTerminalNodeRuleName === specificNonTerminalNodeBRuleNam) {
119
+ if (generalNonTerminalNodeRuleName === specificNonTerminalNodeRuleName) {
120
120
  const generalNonTerminalNodeChildNodes = generalNonTerminalNode.getChildNodes(),
121
- specificNonTerminalNodeBChildNode = specificNonTerminalNode.getChildNodes(),
121
+ specificNonTerminalNodeChildNode = specificNonTerminalNode.getChildNodes(),
122
122
  generalChildNodes = generalNonTerminalNodeChildNodes, ///
123
- specificChildNodes = specificNonTerminalNodeBChildNode, ///
123
+ specificChildNodes = specificNonTerminalNodeChildNode, ///
124
124
  childNodesUnified = this.unifyChildNodes(generalChildNodes, specificChildNodes, ...remainingArguments);
125
125
 
126
126
  nonTerminalNodeUnified = childNodesUnified; ///
package/src/variable.js CHANGED
@@ -143,9 +143,13 @@ class Variable {
143
143
  return verifiedAtTopLevel;
144
144
  }
145
145
 
146
- unifyTerm(term, substitutions, generalContext, specificContext) {
146
+ unifyTerm(term, substitutions, generalContext, specificContext, contextsReversed = false) {
147
147
  let termUnified = false;
148
148
 
149
+ let context = contextsReversed ?
150
+ generalContext :
151
+ specificContext;
152
+
149
153
  const termString = term.getString(),
150
154
  variableString = this.string; ///
151
155
 
@@ -163,17 +167,19 @@ class Variable {
163
167
  }
164
168
  } else {
165
169
  const variableNode = this.node, ///
166
- variable = variableFromVariableNode(variableNode, generalContext, specificContext),
167
- termVariable = termVariableFromTermNode(termNode, generalContext, specificContext);
170
+ generalContext = this.context, ///
171
+ variable = variableFromVariableNode(variableNode, generalContext),
172
+ termVariable = termVariableFromTermNode(termNode, generalContext);
168
173
 
169
174
  if ((variable !== null) && (variable === termVariable)) {
170
175
  termUnified = true;
171
176
  } else {
172
- const context = specificContext, ///
173
- variable = this, ///
177
+ const variable = this, ///
174
178
  termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
175
179
  substitution = termSubstitution; ///
176
180
 
181
+ context = specificContext; ///
182
+
177
183
  substitutions.addSubstitution(substitution, context);
178
184
 
179
185
  termUnified = true;
@@ -287,7 +293,7 @@ Object.assign(shim, {
287
293
 
288
294
  export default Variable;
289
295
 
290
- function variableFromVariableNode(variableNode, generalContext, specificContext) {
296
+ function variableFromVariableNode(variableNode, generalContext) {
291
297
  const variableName = variableNameFromVariableNode(variableNode),
292
298
  context = generalContext, ///
293
299
  variable = context.findVariableByVariableName(variableName);
@@ -295,7 +301,7 @@ function variableFromVariableNode(variableNode, generalContext, specificContext)
295
301
  return variable;
296
302
  }
297
303
 
298
- function termVariableFromTermNode(termNode, specificContext, generalContext) {
304
+ function termVariableFromTermNode(termNode, generalContext) {
299
305
  let termVariable = null;
300
306
 
301
307
  const termVariableNode = termVariableNodeQuery(termNode);
@@ -1,149 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
9
- }
10
- });
11
- var _shim = /*#__PURE__*/ _interop_require_default(require("../shim"));
12
- var _unifier = /*#__PURE__*/ _interop_require_default(require("../unifier"));
13
- var _query = require("../utilities/query");
14
- var _name = require("../utilities/name");
15
- function _assert_this_initialized(self) {
16
- if (self === void 0) {
17
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
18
- }
19
- return self;
20
- }
21
- function _call_super(_this, derived, args) {
22
- derived = _get_prototype_of(derived);
23
- return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
24
- }
25
- function _class_call_check(instance, Constructor) {
26
- if (!(instance instanceof Constructor)) {
27
- throw new TypeError("Cannot call a class as a function");
28
- }
29
- }
30
- function _defineProperties(target, props) {
31
- for(var i = 0; i < props.length; i++){
32
- var descriptor = props[i];
33
- descriptor.enumerable = descriptor.enumerable || false;
34
- descriptor.configurable = true;
35
- if ("value" in descriptor) descriptor.writable = true;
36
- Object.defineProperty(target, descriptor.key, descriptor);
37
- }
38
- }
39
- function _create_class(Constructor, protoProps, staticProps) {
40
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
41
- if (staticProps) _defineProperties(Constructor, staticProps);
42
- return Constructor;
43
- }
44
- function _define_property(obj, key, value) {
45
- if (key in obj) {
46
- Object.defineProperty(obj, key, {
47
- value: value,
48
- enumerable: true,
49
- configurable: true,
50
- writable: true
51
- });
52
- } else {
53
- obj[key] = value;
54
- }
55
- return obj;
56
- }
57
- function _get_prototype_of(o) {
58
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
59
- return o.__proto__ || Object.getPrototypeOf(o);
60
- };
61
- return _get_prototype_of(o);
62
- }
63
- function _inherits(subClass, superClass) {
64
- if (typeof superClass !== "function" && superClass !== null) {
65
- throw new TypeError("Super expression must either be null or a function");
66
- }
67
- subClass.prototype = Object.create(superClass && superClass.prototype, {
68
- constructor: {
69
- value: subClass,
70
- writable: true,
71
- configurable: true
72
- }
73
- });
74
- if (superClass) _set_prototype_of(subClass, superClass);
75
- }
76
- function _interop_require_default(obj) {
77
- return obj && obj.__esModule ? obj : {
78
- default: obj
79
- };
80
- }
81
- function _possible_constructor_return(self, call) {
82
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
83
- return call;
84
- }
85
- return _assert_this_initialized(self);
86
- }
87
- function _set_prototype_of(o, p) {
88
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
89
- o.__proto__ = p;
90
- return o;
91
- };
92
- return _set_prototype_of(o, p);
93
- }
94
- function _type_of(obj) {
95
- "@swc/helpers - typeof";
96
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
97
- }
98
- function _is_native_reflect_construct() {
99
- try {
100
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
101
- } catch (_) {}
102
- return (_is_native_reflect_construct = function() {
103
- return !!result;
104
- })();
105
- }
106
- var termNodeQuery = (0, _query.nodeQuery)("/term"), termVariableNodeQuery = (0, _query.nodeQuery)("/term/variable!");
107
- var IntrinsicLevelUnifier = /*#__PURE__*/ function(Unifier) {
108
- _inherits(IntrinsicLevelUnifier, Unifier);
109
- function IntrinsicLevelUnifier() {
110
- _class_call_check(this, IntrinsicLevelUnifier);
111
- return _call_super(this, IntrinsicLevelUnifier, arguments);
112
- }
113
- _create_class(IntrinsicLevelUnifier, [
114
- {
115
- key: "unify",
116
- value: function unify(generalNode, specificNode, substitutions, generalContext, specificContext) {
117
- var unifiedAtMetaLevel;
118
- var generalNonTerminalNode = generalNode, specificNonTerminalNode = specificNode, nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
119
- unifiedAtMetaLevel = nonTerminalNodeUnified; ///
120
- return unifiedAtMetaLevel;
121
- }
122
- }
123
- ]);
124
- return IntrinsicLevelUnifier;
125
- }(_unifier.default);
126
- _define_property(IntrinsicLevelUnifier, "maps", [
127
- {
128
- generalNodeQuery: termVariableNodeQuery,
129
- specificNodeQuery: termNodeQuery,
130
- unify: function(generalVermVariableNode, specificTermNode, substitutions, generalContext, specificContext) {
131
- var termUnified = false;
132
- var variableNode = generalVermVariableNode, variableName = (0, _name.variableNameFromVariableNode)(variableNode), variablePresent = generalContext.isVariablePresentByVariableName(variableName);
133
- if (variablePresent) {
134
- var context;
135
- var Term = _shim.default.Term, Variable = _shim.default.Variable, termNode = specificTermNode; ///
136
- context = generalContext; ///
137
- var variable = Variable.fromVariableNode(variableNode, context);
138
- context = specificContext; ///
139
- var term = Term.fromTermNode(termNode, context);
140
- termUnified = variable.unifyTerm(term, substitutions, generalContext, specificContext);
141
- }
142
- return termUnified;
143
- }
144
- }
145
- ]);
146
- var intrinsicLevelUnifier = new IntrinsicLevelUnifier();
147
- var _default = intrinsicLevelUnifier;
148
-
149
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91bmlmaWVyL2ludHJpbnNpY0xldmVsLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuXG5pbXBvcnQgc2hpbSBmcm9tIFwiLi4vc2hpbVwiO1xuaW1wb3J0IFVuaWZpZXIgZnJvbSBcIi4uL3VuaWZpZXJcIjtcblxuaW1wb3J0IHsgbm9kZVF1ZXJ5IH0gZnJvbSBcIi4uL3V0aWxpdGllcy9xdWVyeVwiO1xuaW1wb3J0IHsgdmFyaWFibGVOYW1lRnJvbVZhcmlhYmxlTm9kZSB9IGZyb20gXCIuLi91dGlsaXRpZXMvbmFtZVwiO1xuXG5jb25zdCB0ZXJtTm9kZVF1ZXJ5ID0gbm9kZVF1ZXJ5KFwiL3Rlcm1cIiksXG4gICAgICB0ZXJtVmFyaWFibGVOb2RlUXVlcnkgPSBub2RlUXVlcnkoXCIvdGVybS92YXJpYWJsZSFcIik7XG5cbmNsYXNzIEludHJpbnNpY0xldmVsVW5pZmllciBleHRlbmRzIFVuaWZpZXIge1xuICB1bmlmeShnZW5lcmFsTm9kZSwgc3BlY2lmaWNOb2RlLCBzdWJzdGl0dXRpb25zLCBnZW5lcmFsQ29udGV4dCwgc3BlY2lmaWNDb250ZXh0KSB7XG4gICAgbGV0IHVuaWZpZWRBdE1ldGFMZXZlbDtcblxuICAgIGNvbnN0IGdlbmVyYWxOb25UZXJtaW5hbE5vZGUgPSBnZW5lcmFsTm9kZSwgLy8vXG4gICAgICAgICAgc3BlY2lmaWN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FDVDtJQUNGO0NBQ0Q7QUFHSCxJQUFNZ0Isd0JBQXdCLElBQUlsQztJQUVsQyxXQUFla0MifQ==
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- import shim from "../shim";
4
- import Unifier from "../unifier";
5
-
6
- import { nodeQuery } from "../utilities/query";
7
- import { variableNameFromVariableNode } from "../utilities/name";
8
-
9
- const termNodeQuery = nodeQuery("/term"),
10
- termVariableNodeQuery = nodeQuery("/term/variable!");
11
-
12
- class IntrinsicLevelUnifier extends Unifier {
13
- unify(generalNode, specificNode, substitutions, generalContext, specificContext) {
14
- let unifiedAtMetaLevel;
15
-
16
- const generalNonTerminalNode = generalNode, ///
17
- specificNonTerminalNode = specificNode, ///
18
- nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
19
-
20
- unifiedAtMetaLevel = nonTerminalNodeUnified; ///
21
-
22
- return unifiedAtMetaLevel;
23
- }
24
-
25
- static maps = [
26
- {
27
- generalNodeQuery: termVariableNodeQuery,
28
- specificNodeQuery: termNodeQuery,
29
- unify: (generalVermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
30
- let termUnified = false;
31
-
32
- const variableNode = generalVermVariableNode, ///
33
- variableName = variableNameFromVariableNode(variableNode),
34
- variablePresent = generalContext.isVariablePresentByVariableName(variableName);
35
-
36
- if (variablePresent) {
37
- let context;
38
-
39
- const { Term, Variable } = shim,
40
- termNode = specificTermNode; ///
41
-
42
- context = generalContext; ///
43
-
44
- const variable = Variable.fromVariableNode(variableNode, context);
45
-
46
- context = specificContext; ///
47
-
48
- const term = Term.fromTermNode(termNode, context);
49
-
50
- termUnified = variable.unifyTerm(term, substitutions, generalContext, specificContext);
51
- }
52
-
53
- return termUnified;
54
- }
55
- }
56
- ];
57
- }
58
-
59
- const intrinsicLevelUnifier = new IntrinsicLevelUnifier();
60
-
61
- export default intrinsicLevelUnifier;