occam-verify-cli 0.0.1033 → 0.0.1035

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/src/equality.js CHANGED
@@ -121,14 +121,14 @@ export default class Equality {
121
121
 
122
122
  const equalityString = this.string; ///
123
123
 
124
- localContext.trace(`Verifying the '${equalityString}' equality when stated...`);
124
+ localContext.trace(`Verifying the stated '${equalityString}' equality...`);
125
125
 
126
126
  const termsVerified = this.verifyTerms(localContext);
127
127
 
128
128
  verifiedWhenStated = termsVerified; ///
129
129
 
130
130
  if (verifiedWhenStated) {
131
- localContext.debug(`...verified the '${equalityString}' equality when stated.`);
131
+ localContext.debug(`...verified the stated '${equalityString}' equality.`);
132
132
  }
133
133
 
134
134
  return verifiedWhenStated;
@@ -139,7 +139,7 @@ export default class Equality {
139
139
 
140
140
  const equalityString = this.string; ///
141
141
 
142
- localContext.trace(`Verifying the '${equalityString}' equality when derived...`);
142
+ localContext.trace(`Verifying the derived '${equalityString}' equality...`);
143
143
 
144
144
  const termsVerified = this.verifyTerms(localContext);
145
145
 
@@ -150,7 +150,7 @@ export default class Equality {
150
150
  }
151
151
 
152
152
  if (verifiedWhenDerived) {
153
- localContext.debug(`...verified the '${equalityString}' equality when derived.`);
153
+ localContext.debug(`...verified the derived '${equalityString}' equality.`);
154
154
  }
155
155
 
156
156
  return verifiedWhenDerived;
package/src/premise.js CHANGED
@@ -12,8 +12,9 @@ import { assignAssignments } from "./utilities/assignments";
12
12
  const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
13
13
 
14
14
  export default class Premise {
15
- constructor(fileContext, unqualifiedStatement) {
15
+ constructor(fileContext, subproofAssertion, unqualifiedStatement) {
16
16
  this.fileContext = fileContext;
17
+ this.subproofAssertion = subproofAssertion;
17
18
  this.unqualifiedStatement = unqualifiedStatement;
18
19
  }
19
20
 
@@ -21,6 +22,10 @@ export default class Premise {
21
22
  return this.fileContext;
22
23
  }
23
24
 
25
+ getSubproofAssertion() {
26
+ return this.subproofAssertion;
27
+ }
28
+
24
29
  getUnqualifiedStatement() {
25
30
  return this.unqualifiedStatement;
26
31
  }
@@ -90,12 +95,8 @@ export default class Premise {
90
95
 
91
96
  localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
92
97
 
93
- const statement = this.unqualifiedStatement.getStatement(),
94
- statementNode = statement.getNode(),
95
- subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, this.fileContext);
96
-
97
- if (subproofAssertion !== null) {
98
- subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, localContext);
98
+ if (this.subproofAssertion !== null) {
99
+ subproofUnified = this.subproofAssertion.unifySubproof(subproof, substitutions, localContext);
99
100
  }
100
101
 
101
102
  if (subproofUnified) {
@@ -142,30 +143,42 @@ export default class Premise {
142
143
 
143
144
  toJSON() {
144
145
  const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
145
- unqualifiedStatement = unqualifiedStatementJSON, ///
146
- json = {
147
- unqualifiedStatement
148
- };
146
+ subproofAssertionJSON = (this.subproofAssertion !== null) ?
147
+ this.subproofAssertion.toJSON() :
148
+ null,
149
+ unqualifiedStatement = unqualifiedStatementJSON, ///
150
+ subproofAssertion = subproofAssertionJSON, ///
151
+ json = {
152
+ unqualifiedStatement,
153
+ subproofAssertion
154
+ };
149
155
 
150
156
  return json;
151
157
  }
152
158
 
153
159
  static fromJSON(json, fileContext) {
154
- let { unqualifiedStatement } = json;
160
+ let { subproofAssertion, unqualifiedStatement } = json;
155
161
 
156
162
  json = unqualifiedStatement; ///
157
163
 
158
164
  unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
159
165
 
160
- const premise = new Premise(fileContext, unqualifiedStatement);
166
+ json = subproofAssertion; ///
167
+
168
+ subproofAssertion = (json !== null) ?
169
+ SubproofAssertion.fromJSON(json, fileContext) :
170
+ null;
171
+
172
+ const premise = new Premise(fileContext, subproofAssertion, unqualifiedStatement);
161
173
 
162
174
  return premise;
163
175
  }
164
176
 
165
- static fromPremiseNode(premiseNode, fileContext) {
166
- const unqualifiedStatementNode = unqualifiedStatementNodeQuery(premiseNode),
177
+ static fromSuppositionNode(suppositionNode, fileContext) {
178
+ const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
167
179
  unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
168
- premise = new Premise(fileContext, unqualifiedStatement);
180
+ subproofAssertion = SubproofAssertion.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
181
+ premise = new Premise(fileContext, subproofAssertion, unqualifiedStatement);
169
182
 
170
183
  return premise
171
184
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ import shim from "../shim";
3
4
  import Substitution from "../substitution";
4
5
 
5
6
  import { nodeQuery } from "../utilities/query";
@@ -25,12 +26,6 @@ export default class TermForVariableSubstitution extends Substitution {
25
26
  return this.variableNode;
26
27
  }
27
28
 
28
- getNode() {
29
- const node = this.termNode; ///
30
-
31
- return node;
32
- }
33
-
34
29
  transformed(substitutions) {
35
30
  let transformedSubstitution = null;
36
31
 
@@ -88,6 +83,22 @@ export default class TermForVariableSubstitution extends Substitution {
88
83
  return unifiedWithEquivalence;
89
84
  }
90
85
 
86
+ static fromTernAndVariable(term, variable, localContext) {
87
+ let termNode = term.getNode();
88
+
89
+ termNode = stripBracketsFromTerm(termNode); ///
90
+
91
+ const { Term } = shim;
92
+
93
+ term = Term.fromTermNode(termNode, localContext)
94
+
95
+ const string = stringFromTermAndVariable(term, variable),
96
+ variableNode = variable.getNode(),
97
+ termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode);
98
+
99
+ return termForVariableSubstitution;
100
+ }
101
+
91
102
  static fromSubstitutionNode(substitutionNode) {
92
103
  let termForVariableSubstitution = null;
93
104
 
@@ -106,15 +117,6 @@ export default class TermForVariableSubstitution extends Substitution {
106
117
 
107
118
  return termForVariableSubstitution;
108
119
  }
109
-
110
- static fromTernNodeAndVariableNode(termNode, variableNode, localContextA, localContextB) {
111
- termNode = stripBracketsFromTerm(termNode); ///
112
-
113
- const string = stringFromTermNodeAndVariableNode(termNode, variableNode, localContextA, localContextB),
114
- termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode);
115
-
116
- return termForVariableSubstitution;
117
- }
118
120
  }
119
121
 
120
122
  function transformTermNode(termNode, substitutions) {
@@ -162,12 +164,10 @@ function transformVariableNode(variableNode, substitutions) {
162
164
  return transformedVariableNode;
163
165
  }
164
166
 
165
- function stringFromTermNodeAndVariableNode(termNode, variableNode, localContextA, localContextB) {
166
- const termNodeB = termNode, ///
167
- termStringB = localContextB.nodeAsString(termNodeB),
168
- variableNodeA = variableNode, ///
169
- variableStringA = localContextA.nodeAsString(variableNodeA),
170
- string = `[${termStringB} for ${variableStringA}]`;
167
+ function stringFromTermAndVariable(term, variable) {
168
+ const termString = term.getString(),
169
+ variableString = variable.getString(),
170
+ string = `[${termString} for ${variableString}]`;
171
171
 
172
172
  return string;
173
173
  }
@@ -12,8 +12,9 @@ import { assignAssignments } from "./utilities/assignments";
12
12
  const unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement");
13
13
 
14
14
  export default class Supposition {
15
- constructor(fileContext, unqualifiedStatement) {
15
+ constructor(fileContext, subproofAssertion, unqualifiedStatement) {
16
16
  this.fileContext = fileContext;
17
+ this.subproofAssertion = subproofAssertion;
17
18
  this.unqualifiedStatement = unqualifiedStatement;
18
19
  }
19
20
 
@@ -21,6 +22,10 @@ export default class Supposition {
21
22
  return this.fileContext;
22
23
  }
23
24
 
25
+ getSubproofAssertion() {
26
+ return this.subproofAssertion;
27
+ }
28
+
24
29
  getUnqualifiedStatement() {
25
30
  return this.unqualifiedStatement;
26
31
  }
@@ -90,12 +95,8 @@ export default class Supposition {
90
95
 
91
96
  localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
92
97
 
93
- const statement = this.unqualifiedStatement.getStatement(),
94
- statementNode = statement.getNode(),
95
- subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, this.fileContext);
96
-
97
- if (subproofAssertion !== null) {
98
- subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, localContext);
98
+ if (this.subproofAssertion !== null) {
99
+ subproofUnified = this.subproofAssertion.unifySubproof(subproof, substitutions, localContext);
99
100
  }
100
101
 
101
102
  if (subproofUnified) {
@@ -142,22 +143,33 @@ export default class Supposition {
142
143
 
143
144
  toJSON() {
144
145
  const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
146
+ subproofAssertionJSON = (this.subproofAssertion !== null) ?
147
+ this.subproofAssertion.toJSON() :
148
+ null,
145
149
  unqualifiedStatement = unqualifiedStatementJSON, ///
150
+ subproofAssertion = subproofAssertionJSON, ///
146
151
  json = {
147
- unqualifiedStatement
152
+ unqualifiedStatement,
153
+ subproofAssertion
148
154
  };
149
155
 
150
156
  return json;
151
157
  }
152
158
 
153
159
  static fromJSON(json, fileContext) {
154
- let { unqualifiedStatement } = json;
160
+ let { subproofAssertion, unqualifiedStatement } = json;
155
161
 
156
162
  json = unqualifiedStatement; ///
157
163
 
158
164
  unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
159
165
 
160
- const supposition = new Supposition(fileContext, unqualifiedStatement);
166
+ json = subproofAssertion; ///
167
+
168
+ subproofAssertion = (json !== null) ?
169
+ SubproofAssertion.fromJSON(json, fileContext) :
170
+ null;
171
+
172
+ const supposition = new Supposition(fileContext, subproofAssertion, unqualifiedStatement);
161
173
 
162
174
  return supposition;
163
175
  }
@@ -165,7 +177,8 @@ export default class Supposition {
165
177
  static fromSuppositionNode(suppositionNode, fileContext) {
166
178
  const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
167
179
  unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
168
- supposition = new Supposition(fileContext, unqualifiedStatement);
180
+ subproofAssertion = SubproofAssertion.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
181
+ supposition = new Supposition(fileContext, subproofAssertion, unqualifiedStatement);
169
182
 
170
183
  return supposition
171
184
  }
package/src/term.js CHANGED
@@ -248,9 +248,9 @@ class Term {
248
248
  return term;
249
249
  }
250
250
 
251
- static fromTermNodeAndType(termNode, type, fileContext) {
251
+ static fromTermNodeAndType(termNode, type, localContext) {
252
252
  const node = termNode, ///
253
- string = fileContext.nodeAsString(node),
253
+ string = localContext.nodeAsString(node),
254
254
  term = new Term(string, node, type);
255
255
 
256
256
  return term;
package/src/theorem.js CHANGED
@@ -1,7 +1,93 @@
1
1
  "use strict";
2
2
 
3
+ import Label from "./label";
4
+ import Proof from "./proof";
5
+ import Consequent from "./consequent";
6
+ import Supposition from "./supposition";
7
+ import LocalContext from "./context/local";
8
+ import Substitutions from "./substitutions";
3
9
  import TopLevelAssertion from "./topLevelAssertion";
4
10
 
11
+ import { nodeQuery, nodesQuery } from "./utilities/query";
12
+ import { labelsStringFromLabels } from "./topLevelAssertion";
13
+
14
+ const proofNodeQuery = nodeQuery("/theorem/proof"),
15
+ labelNodesQuery = nodesQuery("/theorem/label"),
16
+ consequentNodeQuery = nodeQuery("/theorem/consequent"),
17
+ suppositionNodesQuery = nodesQuery("/theorem/supposition");
18
+
5
19
  export default class Theorem extends TopLevelAssertion {
6
- static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return TopLevelAssertion.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Theorem, labels, suppositions, consequent, substitutions, fileContext); }
20
+ verify() {
21
+ let verified = false;
22
+
23
+ const labelsString = labelsStringFromLabels(this.labels);
24
+
25
+ this.fileContext.trace(`Verifying the '${labelsString}' theorem...`);
26
+
27
+ const labelsVerifiedAtTopLevel = this.labels.every((label) => {
28
+ const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
29
+
30
+ if (labelVVerifiedAtTopLevel) {
31
+ return true;
32
+ }
33
+ });
34
+
35
+ if (labelsVerifiedAtTopLevel) {
36
+ const localContext = LocalContext.fromFileContext(this.fileContext),
37
+ suppositionsVerified = this.suppositions.every((supposition) => {
38
+ const suppositionVerified = supposition.verify(localContext);
39
+
40
+ if (suppositionVerified) {
41
+ return true;
42
+ }
43
+ });
44
+
45
+ if (suppositionsVerified) {
46
+ const consequentVerified = this.consequent.verify(localContext);
47
+
48
+ if (consequentVerified) {
49
+ const substitutions = Substitutions.fromNothing(),
50
+ proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
51
+
52
+ if (proofVerified) {
53
+ const theorem = this; ///
54
+
55
+ this.fileContext.addTheorem(theorem);
56
+
57
+ verified = true;
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ if (verified) {
64
+ this.fileContext.debug(`...verified the '${labelsString}' theorem.`);
65
+ }
66
+
67
+ return verified;
68
+ }
69
+
70
+ static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
71
+
72
+ static fromTheoremNode(theoremNode, fileContext) {
73
+ const proofNode = proofNodeQuery(theoremNode),
74
+ labelNodes = labelNodesQuery(theoremNode),
75
+ consequentNode = consequentNodeQuery(theoremNode),
76
+ suppositionNodes = suppositionNodesQuery(theoremNode),
77
+ labels = labelNodes.map((labelNode) => {
78
+ const label = Label.fromLabelNode(labelNode, fileContext);
79
+
80
+ return label;
81
+ }),
82
+ suppositions = suppositionNodes.map((suppositionNode) => {
83
+ const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
84
+
85
+ return supposition;
86
+ }),
87
+ consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
88
+ proof = Proof.fromProofNode(proofNode, fileContext),
89
+ theorem = new Theorem(fileContext, labels, suppositions, consequent, proof);
90
+
91
+ return theorem;
92
+ }
7
93
  }
@@ -2,9 +2,9 @@
2
2
 
3
3
  import shim from "../shim";
4
4
  import Unifier from "../unifier";
5
- import unifyVariableWithTerm from "../unify/variableWithTerm";
6
5
 
7
6
  import { nodeQuery } from "../utilities/query";
7
+ import { variableNameFromVariableNode } from "../utilities/name";
8
8
 
9
9
  const termNodeQuery = nodeQuery("/term!"),
10
10
  termVariableNodeQuery = nodeQuery("/term/variable!");
@@ -27,10 +27,23 @@ class IntrinsicLevelUnifier extends Unifier {
27
27
  nodeQueryA: termVariableNodeQuery,
28
28
  nodeQueryB: termNodeQuery,
29
29
  unify: (termVariableNodeA, termNodeB, substitutions, localContextA, localContextB) => {
30
+ let termUnified = false;
31
+
30
32
  const variableNodeA = termVariableNodeA, ///
31
- variableUnifiedWithTerm = unifyVariableWithTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB);
33
+ variableNameA = variableNameFromVariableNode(variableNodeA),
34
+ variableA = localContextA.findVariableByVariableName(variableNameA);
35
+
36
+ if (variableA !== null) {
37
+ const { Term } = shim,
38
+ termB = Term.fromTermNode(termNodeB, localContextB),
39
+ localContext = localContextB, ///
40
+ variable = variableA, ///
41
+ term = termB; ///
42
+
43
+ termUnified = variable.unifyTerm(term, substitutions, localContext);
44
+ }
32
45
 
33
- return variableUnifiedWithTerm;
46
+ return termUnified;
34
47
  }
35
48
  }
36
49
  ];
@@ -2,12 +2,12 @@
2
2
 
3
3
  import shim from "../shim";
4
4
  import Unifier from "../unifier";
5
- import unifyVariableWithTerm from "../unify/variableWithTerm";
6
5
  import unifyMetavariableWithFrame from "../unify/metavariableWithFrame";
7
6
  import unifyMetavariableWithStatement from "../unify/metavariableWithStatement";
8
7
  import unifyMetavariableWithStatementGivenSubstitution from "../unify/metavariableWithStatementGivenSubstitution";
9
8
 
10
9
  import { nodeQuery } from "../utilities/query";
10
+ import { variableNameFromVariableNode } from "../utilities/name";
11
11
 
12
12
  const termNodeQuery = nodeQuery("/term!"),
13
13
  frameNodeQuery = nodeQuery("/frame!"),
@@ -70,6 +70,8 @@ class MetaLevelUnifier extends Unifier {
70
70
  nodeQueryA: frameMetavariableNodeQuery,
71
71
  nodeQueryB: frameNodeQuery,
72
72
  unify: (frameMetavariableNodeA, frameNodeB, substitutions, localContextA, localContextB) => {
73
+ debugger
74
+
73
75
  const metavariableNodeA = frameMetavariableNodeA, ///
74
76
  metavariableUnifiedWithFrame = unifyMetavariableWithFrame(metavariableNodeA, frameNodeB, substitutions, localContextA, localContextB);
75
77
 
@@ -80,10 +82,23 @@ class MetaLevelUnifier extends Unifier {
80
82
  nodeQueryA: termVariableNodeQuery,
81
83
  nodeQueryB: termNodeQuery,
82
84
  unify: (termVariableNodeA, termNodeB, substitutions, localContextA, localContextB) => {
85
+ let termUnified = false;
86
+
83
87
  const variableNodeA = termVariableNodeA, ///
84
- variableUnifiedWithTerm = unifyVariableWithTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB);
88
+ variableNameA = variableNameFromVariableNode(variableNodeA),
89
+ variableA = localContextA.findVariableByVariableName(variableNameA);
90
+
91
+ if (variableA !== null) {
92
+ const { Term } = shim,
93
+ termB = Term.fromTermNode(termNodeB, localContextB),
94
+ localContext = localContextB, ///
95
+ variable = variableA, ///
96
+ term = termB; ///
97
+
98
+ termUnified = variable.unifyTerm(term, substitutions, localContext);
99
+ }
85
100
 
86
- return variableUnifiedWithTerm;
101
+ return termUnified;
87
102
  }
88
103
  }
89
104
  ];
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- export const { first, last, extract, tail, push, find, clear, match, prune, filter, compress, separate } = arrayUtilities;
5
+ export const { first, last, front, tail, push, find, match, clear, prune, extract, filter, compress, separate } = arrayUtilities;
6
6
 
7
7
  export function reverse(array) {
8
8
  array = [ ///
@@ -3,24 +3,9 @@
3
3
  import { nodeQuery } from "../utilities/query";
4
4
  import { metavariableNameFromMetavariableNode} from "../utilities/name";
5
5
 
6
- const termVariableNodeQuery = nodeQuery("/term/variable"),
7
- frameMetavariableNodeQuery = nodeQuery("/frame/metavariable"),
6
+ const frameMetavariableNodeQuery = nodeQuery("/frame/metavariable"),
8
7
  statementMetavariableNodeQuery = nodeQuery("/statement/metavariable");
9
8
 
10
- export function variableFromTermNode(termNode, localContext) {
11
- let variable = null;
12
-
13
- const termVariableNode = termVariableNodeQuery(termNode);
14
-
15
- if (termVariableNode !== null) {
16
- const variableNode = termVariableNode; ///
17
-
18
- variable = localContext.findVariableByVariableNode(variableNode);
19
- }
20
-
21
- return variable;
22
- }
23
-
24
9
  export function metavariableFromFrameNode(frameNode, localContext) {
25
10
  let metavariable = null;
26
11
 
package/src/variable.js CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  import shim from "./shim";
4
4
  import LocalContext from "./context/local";
5
+ import TermForVariableSubstitution from "./substitution/termForVariable";
5
6
 
6
7
  import { nodeQuery } from "./utilities/query";
8
+ import { objectType } from "./type";
7
9
  import { variableNameFromVariableNode} from "./utilities/name";
8
10
  import { variableNodeFromVariableString } from "./utilities/node";
9
- import {objectType} from "./type";
10
11
 
11
12
  const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
12
- variableNodeQuery = nodeQuery("/variableDeclaration/variable");
13
+ variableNodeQuery = nodeQuery("/variableDeclaration/variable"),
14
+ termVariableNodeQuery = nodeQuery("/term/variable");
13
15
 
14
16
  export default class Variable {
15
17
  constructor(string, node, name, type) {
@@ -133,6 +135,47 @@ export default class Variable {
133
135
  return verifiedAtTopLevel;
134
136
  }
135
137
 
138
+ unifyTerm(term, substitutions, localContext) {
139
+ let termUnified = false;
140
+
141
+ const termString = term.getString(),
142
+ variableString = this.string; ///
143
+
144
+ localContext.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
145
+
146
+ const termNode = term.getNode(),
147
+ variableNode = this.node, ///
148
+ substitution = substitutions.findSubstitutionByVariableNode(variableNode);
149
+
150
+ if (substitution !== null) {
151
+ const termNodeMatches = substitution.matchTermNode(termNode);
152
+
153
+ if (termNodeMatches) {
154
+ termUnified = true;
155
+ }
156
+ } else {
157
+ const variable = this, ///
158
+ termVariable = termVariableFromTermNode(termNode, localContext);
159
+
160
+ if (termVariable === variable) {
161
+ termUnified = true;
162
+ } else {
163
+ const termForVariableSubstitution = TermForVariableSubstitution.fromTernAndVariable(term, variable, localContext),
164
+ substitution = termForVariableSubstitution; ///
165
+
166
+ substitutions.addSubstitution(substitution, localContext);
167
+
168
+ termUnified = true;
169
+ }
170
+ }
171
+
172
+ if (termUnified) {
173
+ localContext.trace(`...unified the '${termString}' term with the '${variableString}' variable.`);
174
+ }
175
+
176
+ return termUnified;
177
+ }
178
+
136
179
  toJSON() {
137
180
  const typeJSON = this.type.toJSON(),
138
181
  string = this.string,
@@ -213,3 +256,17 @@ function typeFromJSON(json, fileContext) {
213
256
 
214
257
  return type;
215
258
  }
259
+
260
+ function termVariableFromTermNode(termNode, localContext) {
261
+ let termVariable = null;
262
+
263
+ const termVariableNode = termVariableNodeQuery(termNode);
264
+
265
+ if (termVariableNode !== null) {
266
+ const termVariableName = variableNameFromVariableNode(termVariableNode);
267
+
268
+ termVariable = localContext.findVariableByVariableName(termVariableName);
269
+ }
270
+
271
+ return termVariable;
272
+ }
@@ -4,6 +4,7 @@ import Rule from "../rule";
4
4
  import Error from "../error";
5
5
  import Axiom from "../axiom";
6
6
  import Lemma from "../lemma";
7
+ import Theorem from "../theorem";
7
8
  import TypeDeclaration from "../declaration/type";
8
9
  import VariableDeclaration from "../declaration/variable";
9
10
  import CombinatorDeclaration from "../declaration/combinator";
@@ -11,7 +12,6 @@ import ConstructorDeclaration from "../declaration/constructor";
11
12
  import MetavariableDeclaration from "../declaration/metavariable";
12
13
 
13
14
  import Verifier from "../verifier";
14
- import verifyTheorem from "../verify/theorem";
15
15
  import verifyMetaLemma from "../verify/metaLemma";
16
16
  import verifyConjecture from "../verify/conjecture";
17
17
  import verifyMetatheorem from "../verify/metatheorem";
@@ -84,7 +84,8 @@ class TopLevelVerifier extends Verifier {
84
84
  {
85
85
  nodeQuery: theoremNodeQuery,
86
86
  verify: (theoremNode, fileContext) => {
87
- const theoremVerified = verifyTheorem(theoremNode, fileContext);
87
+ const theorem = Theorem.fromTheoremNode(theoremNode, fileContext),
88
+ theoremVerified = theorem.verify();
88
89
 
89
90
  return theoremVerified;
90
91
  }
@@ -1,39 +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 unifyVariableWithTerm;
9
- }
10
- });
11
- var _termForVariable = /*#__PURE__*/ _interop_require_default(require("../substitution/termForVariable"));
12
- var _unify = require("../utilities/unify");
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- function unifyVariableWithTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB) {
19
- var variableUnifiedWithTerm = false;
20
- var substitution = substitutions.findSubstitutionByVariableNode(variableNodeA);
21
- if (substitution !== null) {
22
- var termNodeMatches = substitution.matchTermNode(termNodeB);
23
- if (termNodeMatches) {
24
- variableUnifiedWithTerm = true;
25
- }
26
- } else {
27
- var variableA = localContextA.findVariableByVariableNode(variableNodeA), variableB = (0, _unify.variableFromTermNode)(termNodeB, localContextB);
28
- if (variableA === variableB) {
29
- variableUnifiedWithTerm = true;
30
- } else {
31
- var termNode = termNodeB, variableNode = variableNodeA, termForVariableSubstitution = _termForVariable.default.fromTernNodeAndVariableNode(termNode, variableNode, localContextA, localContextB), substitution1 = termForVariableSubstitution; ///
32
- substitutions.addSubstitution(substitution1, localContextA, localContextB);
33
- variableUnifiedWithTerm = true;
34
- }
35
- }
36
- return variableUnifiedWithTerm;
37
- }
38
-
39
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91bmlmeS92YXJpYWJsZVdpdGhUZXJtLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuXG5pbXBvcnQgVGVybUZvclZhcmlhYmxlU3Vic3RpdHV0aW9uIGZyb20gXCIuLi9zdWJ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