occam-verify-cli 1.0.207 → 1.0.211
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/lib/constants.js +1 -5
- package/lib/dom/assertion/satisfies.js +36 -54
- package/lib/dom/axiom.js +49 -25
- package/lib/dom/metavariable.js +4 -7
- package/lib/dom/signature.js +197 -0
- package/lib/dom/substitution/frame.js +216 -0
- package/lib/dom/substitution/reference.js +203 -0
- package/lib/dom/substitution/statement.js +297 -0
- package/lib/dom/substitution/term.js +237 -0
- package/lib/dom/substitution.js +214 -0
- package/lib/dom/topLevelAssertion.js +21 -10
- package/lib/dom/topLevelMetaAssertion.js +4 -4
- package/lib/dom/variable.js +9 -10
- package/lib/index.js +6 -1
- package/lib/mixins/step/unify.js +3 -4
- package/lib/node/assertion/satisfies.js +5 -5
- package/lib/node/signature.js +116 -0
- package/lib/node/topLevelAssertion.js +8 -18
- package/lib/nonTerminalNodeMap.js +3 -2
- package/lib/ruleNames.js +5 -1
- package/lib/substitutions.js +2 -14
- package/lib/unifier/metaLevel.js +2 -4
- package/lib/utilities/json.js +49 -12
- package/lib/utilities/node.js +36 -1
- package/lib/utilities/substitutions.js +2 -4
- package/package.json +1 -1
- package/src/constants.js +0 -1
- package/src/dom/assertion/satisfies.js +45 -72
- package/src/dom/axiom.js +59 -31
- package/src/dom/metavariable.js +6 -6
- package/src/dom/signature.js +145 -0
- package/src/{substitution → dom/substitution}/frame.js +6 -4
- package/src/{substitution → dom/substitution}/reference.js +6 -4
- package/src/{substitution → dom/substitution}/statement.js +8 -7
- package/src/{substitution → dom/substitution}/term.js +7 -6
- package/src/dom/topLevelAssertion.js +26 -11
- package/src/dom/topLevelMetaAssertion.js +2 -2
- package/src/dom/variable.js +8 -10
- package/src/index.js +5 -0
- package/src/mixins/step/unify.js +4 -3
- package/src/node/assertion/satisfies.js +5 -5
- package/src/node/signature.js +16 -0
- package/src/node/topLevelAssertion.js +8 -21
- package/src/nonTerminalNodeMap.js +4 -1
- package/src/ruleNames.js +1 -0
- package/src/substitutions.js +3 -15
- package/src/unifier/metaLevel.js +2 -3
- package/src/utilities/json.js +60 -13
- package/src/utilities/node.js +45 -0
- package/src/utilities/substitutions.js +2 -3
- package/lib/substitution/frame.js +0 -175
- package/lib/substitution/reference.js +0 -162
- package/lib/substitution/statement.js +0 -296
- package/lib/substitution/term.js +0 -196
- package/lib/substitution.js +0 -214
- /package/src/{substitution.js → dom/substitution.js} +0 -0
package/src/dom/axiom.js
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import LocalContext from "../context/local";
|
|
5
6
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
6
7
|
|
|
7
8
|
import { domAssigned } from "../dom";
|
|
8
|
-
import { satisfiesAssertionFromStatement } from "../utilities/context";
|
|
9
9
|
|
|
10
|
-
const { match
|
|
10
|
+
const { match } = arrayUtilities;
|
|
11
11
|
|
|
12
12
|
export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
13
|
+
isSatisfiable() {
|
|
14
|
+
const signature = this.getSignature(),
|
|
15
|
+
satisfiable = (signature !== null);
|
|
16
|
+
|
|
17
|
+
return satisfiable;
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
verify() {
|
|
14
21
|
let verified;
|
|
15
22
|
|
|
@@ -19,7 +26,11 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
19
26
|
|
|
20
27
|
fileContext.trace(`Verifying the '${axiomString}' axiom...`);
|
|
21
28
|
|
|
22
|
-
|
|
29
|
+
const signatureVerified = this.verifySignature();
|
|
30
|
+
|
|
31
|
+
if (signatureVerified) {
|
|
32
|
+
verified = super.verify();
|
|
33
|
+
}
|
|
23
34
|
|
|
24
35
|
if (verified) {
|
|
25
36
|
const axiom = this; ///
|
|
@@ -32,10 +43,43 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
32
43
|
return verified;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
verifySignature() {
|
|
47
|
+
let signatureVerified = true;
|
|
48
|
+
|
|
49
|
+
const satisfiable = this.isSatisfiable();
|
|
50
|
+
|
|
51
|
+
if (satisfiable) {
|
|
52
|
+
const signature = this.getSignature(),
|
|
53
|
+
fileContext = this.getFileContext(),
|
|
54
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
55
|
+
context = localContext; ///
|
|
56
|
+
|
|
57
|
+
signatureVerified = signature.verify(context);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return signatureVerified;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
matchSignature(signature, substitutions, generalContext, specificContext) {
|
|
64
|
+
let signatureMatches = false;
|
|
65
|
+
|
|
66
|
+
const satisfiable = this.isSatisfiable();
|
|
67
|
+
|
|
68
|
+
if (satisfiable) {
|
|
69
|
+
const signatureA = signature; ///
|
|
70
|
+
|
|
71
|
+
signature = this.getSignature()
|
|
72
|
+
|
|
73
|
+
const signatureB = signature; ///
|
|
74
|
+
|
|
75
|
+
signatureMatches = signatureA.match(signatureB, substitutions, generalContext, specificContext);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return signatureMatches;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
36
82
|
const deduction = this.getDeduction(),
|
|
37
|
-
generalContext = context, ///
|
|
38
|
-
specificContext = context, ///
|
|
39
83
|
statementUnified = deduction.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
40
84
|
|
|
41
85
|
return statementUnified;
|
|
@@ -145,34 +189,18 @@ export default domAssigned(class Axiom extends TopLevelAssertion {
|
|
|
145
189
|
}
|
|
146
190
|
|
|
147
191
|
unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context) {
|
|
148
|
-
let statementAndStepsOrSubproofsUnified;
|
|
149
|
-
|
|
150
|
-
statementAndStepsOrSubproofsUnified = super.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context);
|
|
151
|
-
|
|
152
|
-
if (statementAndStepsOrSubproofsUnified) {
|
|
153
|
-
const satisfiable = this.isSatisfiable();
|
|
192
|
+
let statementAndStepsOrSubproofsUnified = false;
|
|
154
193
|
|
|
155
|
-
|
|
156
|
-
const substitutionsMatch = backwardsSome(stepsOrSubproofs, (stepOrSubproof) => {
|
|
157
|
-
const stepSubstep = stepOrSubproof.isStep();
|
|
194
|
+
const satisfiable = this.isSatisfiable();
|
|
158
195
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
196
|
+
if (satisfiable) {
|
|
197
|
+
const string = this.getString(),
|
|
198
|
+
axiomString = string, ///
|
|
199
|
+
statementString = statement.getString();
|
|
163
200
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (substitutionsMatch) {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
statementAndStepsOrSubproofsUnified = substitutionsMatch; ///
|
|
175
|
-
}
|
|
201
|
+
context.debug(`The '${statementString}' statement cannot be unified with the '${axiomString}' axiom because the latter is satisfiable.`);
|
|
202
|
+
} else {
|
|
203
|
+
statementAndStepsOrSubproofsUnified = super.unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, substitutions, context);
|
|
176
204
|
}
|
|
177
205
|
|
|
178
206
|
return statementAndStepsOrSubproofsUnified;
|
package/src/dom/metavariable.js
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import dom from "../dom";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
|
-
import FrameSubstitution from "../substitution/frame";
|
|
6
|
-
import ReferenceSubstitution from "../substitution/reference";
|
|
7
|
-
import StatementSubstitution from "../substitution/statement";
|
|
8
5
|
import MetavariablePartialContext from "../context/partial/metavariable";
|
|
9
6
|
|
|
10
7
|
import { domAssigned } from "../dom";
|
|
@@ -189,7 +186,8 @@ export default domAssigned(class Metavariable {
|
|
|
189
186
|
frameUnified = true;
|
|
190
187
|
}
|
|
191
188
|
} else {
|
|
192
|
-
const
|
|
189
|
+
const { FrameSubstitution } = dom,
|
|
190
|
+
context = specificContext, ///
|
|
193
191
|
metavariable = this, ///
|
|
194
192
|
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
|
|
195
193
|
substitution = frameSubstitution; ///
|
|
@@ -232,7 +230,8 @@ export default domAssigned(class Metavariable {
|
|
|
232
230
|
referenceUnified = true;
|
|
233
231
|
}
|
|
234
232
|
} else {
|
|
235
|
-
const
|
|
233
|
+
const { ReferenceSubstitution } = dom,
|
|
234
|
+
context = specificContext, ///
|
|
236
235
|
metavariable = this, ///
|
|
237
236
|
referenceSubstitution = ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, context),
|
|
238
237
|
substitution = referenceSubstitution; ///
|
|
@@ -279,7 +278,8 @@ export default domAssigned(class Metavariable {
|
|
|
279
278
|
statementUnified = true;
|
|
280
279
|
}
|
|
281
280
|
} else {
|
|
282
|
-
const
|
|
281
|
+
const { StatementSubstitution } = dom,
|
|
282
|
+
metavariable = this,
|
|
283
283
|
statementSubstitution = StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context);
|
|
284
284
|
|
|
285
285
|
substitution = statementSubstitution; ///
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import dom from "../dom";
|
|
6
|
+
|
|
7
|
+
import { domAssigned } from "../dom";
|
|
8
|
+
import { termsFromJSON, termsToTermsJSON } from "../utilities/json";
|
|
9
|
+
import { stringFromTerms, variableFromTerm, termsFromTermNodes } from "../utilities/node";
|
|
10
|
+
|
|
11
|
+
const { match, correlate } = arrayUtilities;
|
|
12
|
+
|
|
13
|
+
export default domAssigned(class Signature {
|
|
14
|
+
constructor(string, terms) {
|
|
15
|
+
this.string = string;
|
|
16
|
+
this.terms = terms;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getTerms() {
|
|
24
|
+
return this.terms;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
verify(context) {
|
|
28
|
+
let verified;
|
|
29
|
+
|
|
30
|
+
const signatureString = this.string;
|
|
31
|
+
|
|
32
|
+
context.trace(`Verifying the ${signatureString} signature...`);
|
|
33
|
+
|
|
34
|
+
verified = this.terms.every((term) => {
|
|
35
|
+
const termVerified = term.verify(context, () => {
|
|
36
|
+
const verifiedAhead = true;
|
|
37
|
+
|
|
38
|
+
return verifiedAhead;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (termVerified) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (verified) {
|
|
47
|
+
context.debug(`...verified the ${signatureString} signature.`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return verified;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
match(signature, substitutions, generalContext, specificContext) {
|
|
54
|
+
const terms = signature.getTerms(),
|
|
55
|
+
termsA = this.terms, ///
|
|
56
|
+
termsB = terms, ///
|
|
57
|
+
matches = match(termsA, termsB, (termA, termB) => {
|
|
58
|
+
const termAType = termA.getType(),
|
|
59
|
+
termBType = termB.getType(),
|
|
60
|
+
termATypeEqualToOrSubTypeOfTermB = termAType.isEqualToOrSubTypeOf(termBType);
|
|
61
|
+
|
|
62
|
+
if (termATypeEqualToOrSubTypeOfTermB) {
|
|
63
|
+
let context,
|
|
64
|
+
term;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
context = generalContext; ///
|
|
68
|
+
|
|
69
|
+
term = termB; ///
|
|
70
|
+
|
|
71
|
+
const variable = variableFromTerm(term, context);
|
|
72
|
+
|
|
73
|
+
context = specificContext; ///
|
|
74
|
+
|
|
75
|
+
term = termA; ///
|
|
76
|
+
|
|
77
|
+
const { TermSubstitution } = dom,
|
|
78
|
+
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
79
|
+
substitution = termSubstitution; ///
|
|
80
|
+
|
|
81
|
+
substitutions.addSubstitution(substitution, specificContext);
|
|
82
|
+
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return matches;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
matchSubstitutions(substitutions, context) {
|
|
91
|
+
let substitutionsMatch;
|
|
92
|
+
|
|
93
|
+
const signatureString = this.string,
|
|
94
|
+
substitutionsString = substitutions.asString();
|
|
95
|
+
|
|
96
|
+
context.trace(`Matching the '${substitutionsString}' substitutions against the ${signatureString} signature...`);
|
|
97
|
+
|
|
98
|
+
const array = substitutions.getArray(),
|
|
99
|
+
correlates = correlate(this.terms, array, (term, substitution) => {
|
|
100
|
+
const substitutionTerm = substitution.getTerm(),
|
|
101
|
+
substitutionTermEqualToTerm = substitutionTerm.isEqualTo(term);
|
|
102
|
+
|
|
103
|
+
if (substitutionTermEqualToTerm) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
substitutionsMatch = correlates; ///
|
|
109
|
+
|
|
110
|
+
if (substitutionsMatch) {
|
|
111
|
+
context.debug(`...matched the '${substitutionsString}' substitutions against the ${signatureString} signature.`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return substitutionsMatch;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
toJSON() {
|
|
118
|
+
const termsJSON = termsToTermsJSON(this.terms),
|
|
119
|
+
terms = termsJSON, ///
|
|
120
|
+
json = {
|
|
121
|
+
terms
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return json;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static name = "Signature";
|
|
128
|
+
|
|
129
|
+
static fromJSON(json, fileContext) {
|
|
130
|
+
const terms = termsFromJSON(json, fileContext),
|
|
131
|
+
string = stringFromTerms(terms),
|
|
132
|
+
signature = new Signature(string, terms);
|
|
133
|
+
|
|
134
|
+
return signature;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static fromSignatureNode(signatureNode, fileContext) {
|
|
138
|
+
const termNodes = signatureNode.getTermNodes(),
|
|
139
|
+
terms = termsFromTermNodes(termNodes, fileContext),
|
|
140
|
+
string = stringFromTerms(terms),
|
|
141
|
+
signature = new Signature(string, terms);
|
|
142
|
+
|
|
143
|
+
return signature;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import dom from "
|
|
3
|
+
import dom from "../../dom";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import FrameSubstitutionPartialContext from "
|
|
5
|
+
import FrameSubstitutionPartialContext from "../../context/partial/substitution/frame";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
|
|
9
|
+
export default domAssigned(class FrameSubstitution extends Substitution {
|
|
8
10
|
constructor(string, node, tokens, frame, metavariable) {
|
|
9
11
|
super(string, node, tokens);
|
|
10
12
|
|
|
@@ -71,7 +73,7 @@ export default class FrameSubstitution extends Substitution {
|
|
|
71
73
|
|
|
72
74
|
return frameSubstitution;
|
|
73
75
|
}
|
|
74
|
-
}
|
|
76
|
+
});
|
|
75
77
|
|
|
76
78
|
function stringFromFrameAndMetavariable(frame, metavariable) {
|
|
77
79
|
const frameString = frame.getString(),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import dom from "
|
|
3
|
+
import dom from "../../dom";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import ReferenceSubstitutionPartialContext from "
|
|
5
|
+
import ReferenceSubstitutionPartialContext from "../../context/partial/substitution/reference";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
|
|
9
|
+
export default domAssigned(class ReferenceSubstitution extends Substitution {
|
|
8
10
|
constructor(string, node, tokens, reference, metavariable) {
|
|
9
11
|
super(string, node, tokens);
|
|
10
12
|
|
|
@@ -62,7 +64,7 @@ export default class ReferenceSubstitution extends Substitution {
|
|
|
62
64
|
|
|
63
65
|
return referenceSubstitution;
|
|
64
66
|
}
|
|
65
|
-
}
|
|
67
|
+
});
|
|
66
68
|
|
|
67
69
|
function stringFromReferenceAndMetavariable(reference, metavariable) {
|
|
68
70
|
const referenceString = reference.getString(),
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
|
-
import Substitutions from "
|
|
5
|
-
import StatementSubstitutionPartialContext from "
|
|
4
|
+
import Substitutions from "../../substitutions";
|
|
5
|
+
import StatementSubstitutionPartialContext from "../../context/partial/substitution/statement";
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
import { unifySubstitution } from "../../utilities/unification";
|
|
9
|
+
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
10
|
+
import { statementFromJSON, statementToStatementJSON, metavariableFromJSON, metavariableToMetavariableJSON } from "../../utilities/json";
|
|
10
11
|
|
|
11
|
-
export default class StatementSubstitution extends Substitution {
|
|
12
|
+
export default domAssigned(class StatementSubstitution extends Substitution {
|
|
12
13
|
constructor(string, node, tokens, resolved, statement, metavariable, substitution) {
|
|
13
14
|
super(string, node, tokens);
|
|
14
15
|
|
|
@@ -216,7 +217,7 @@ export default class StatementSubstitution extends Substitution {
|
|
|
216
217
|
|
|
217
218
|
return statementSubstitution;
|
|
218
219
|
}
|
|
219
|
-
}
|
|
220
|
+
});
|
|
220
221
|
|
|
221
222
|
function stringFromStatementAndMetavariable(statement, metavariable) {
|
|
222
223
|
const statementString = statement.getString(),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import dom from "
|
|
3
|
+
import dom from "../../dom";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import TermSubstitutionPartialContext from "
|
|
5
|
+
import TermSubstitutionPartialContext from "../../context/partial/substitution/term";
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { domAssigned } from "../../dom";
|
|
8
|
+
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
9
|
+
import { stripBracketsFromTermNode } from "../../utilities/brackets";
|
|
9
10
|
|
|
10
|
-
export default class TermSubstitution extends Substitution {
|
|
11
|
+
export default domAssigned(class TermSubstitution extends Substitution {
|
|
11
12
|
constructor(string, node, tokens, term, variable) {
|
|
12
13
|
super(string, node, tokens);
|
|
13
14
|
|
|
@@ -106,7 +107,7 @@ export default class TermSubstitution extends Substitution {
|
|
|
106
107
|
|
|
107
108
|
return termSubstitution;
|
|
108
109
|
}
|
|
109
|
-
}
|
|
110
|
+
});
|
|
110
111
|
|
|
111
112
|
function stringFromTermAndVariable(term, variable) {
|
|
112
113
|
const termString = term.getString(),
|
|
@@ -8,23 +8,24 @@ import Substitutions from "../substitutions";
|
|
|
8
8
|
|
|
9
9
|
import { labelsFromJSON,
|
|
10
10
|
deductionFromJSON,
|
|
11
|
+
signatureFromJSON,
|
|
11
12
|
labelsToLabelsJSON,
|
|
12
|
-
satisfiableFromJSON,
|
|
13
13
|
suppositionsFromJSON,
|
|
14
14
|
deductionToDeductionJSON,
|
|
15
|
+
signatureToSignatureJSON,
|
|
15
16
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
16
17
|
|
|
17
18
|
const { reverse, extract, backwardsEvery } = arrayUtilities;
|
|
18
19
|
|
|
19
20
|
export default class TopLevelAssertion {
|
|
20
|
-
constructor(fileContext, string, labels, suppositions, deduction, proof,
|
|
21
|
+
constructor(fileContext, string, labels, suppositions, deduction, proof, signature) {
|
|
21
22
|
this.fileContext = fileContext;
|
|
22
23
|
this.string = string;
|
|
23
24
|
this.labels = labels;
|
|
24
25
|
this.suppositions = suppositions;
|
|
25
26
|
this.deduction = deduction;
|
|
26
27
|
this.proof = proof;
|
|
27
|
-
this.
|
|
28
|
+
this.signature = signature;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
getFileContext() {
|
|
@@ -51,8 +52,8 @@ export default class TopLevelAssertion {
|
|
|
51
52
|
return this.proof;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
return this.
|
|
55
|
+
getSignature() {
|
|
56
|
+
return this.signature;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
getStatement() { return this.deduction.getStatement(); }
|
|
@@ -220,15 +221,16 @@ export default class TopLevelAssertion {
|
|
|
220
221
|
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
221
222
|
deductionJSON = deductionToDeductionJSON(this.deduction),
|
|
222
223
|
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
224
|
+
signatureJSON = signatureToSignatureJSON(this.signature),
|
|
223
225
|
labels = labelsJSON, ///
|
|
224
226
|
deduction = deductionJSON, ///
|
|
225
227
|
suppositions = suppositionsJSON, ///
|
|
226
|
-
|
|
228
|
+
signature = signatureJSON,
|
|
227
229
|
json = {
|
|
228
230
|
labels,
|
|
229
231
|
deduction,
|
|
230
232
|
suppositions,
|
|
231
|
-
|
|
233
|
+
signature,
|
|
232
234
|
};
|
|
233
235
|
|
|
234
236
|
return json;
|
|
@@ -237,28 +239,29 @@ export default class TopLevelAssertion {
|
|
|
237
239
|
static fromJSON(Class, json, fileContext) {
|
|
238
240
|
const labels = labelsFromJSON(json, fileContext),
|
|
239
241
|
deduction = deductionFromJSON(json, fileContext),
|
|
240
|
-
satisfiable = satisfiableFromJSON(json, fileContext),
|
|
241
242
|
suppositions = suppositionsFromJSON(json, fileContext),
|
|
243
|
+
signature = signatureFromJSON(json, fileContext),
|
|
242
244
|
proof = null,
|
|
243
245
|
string = stringFromLabelsAndDeduction(labels, deduction),
|
|
244
|
-
topLevelAssertion = new Class(fileContext, string, labels, suppositions, deduction, proof,
|
|
246
|
+
topLevelAssertion = new Class(fileContext, string, labels, suppositions, deduction, proof, signature);
|
|
245
247
|
|
|
246
248
|
return topLevelAssertion;
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
static fromNode(Class, node, fileContext) {
|
|
250
252
|
const topLevelAssertionNode = node, ///
|
|
251
|
-
satisfiable = topLevelAssertionNode.isSatisfiable(),
|
|
252
253
|
proofNode = topLevelAssertionNode.getProofNode(),
|
|
253
254
|
labelNodes = topLevelAssertionNode.getLabelNodes(),
|
|
254
255
|
deductionNode = topLevelAssertionNode.getDeductionNode(),
|
|
255
256
|
suppositionNodes = topLevelAssertionNode.getSuppositionNodes(),
|
|
257
|
+
signatureNode = topLevelAssertionNode.getSignatureNode(),
|
|
256
258
|
proof = proofFromProofNode(proofNode, fileContext),
|
|
257
259
|
labels = labelsFromLabelNodes(labelNodes, fileContext),
|
|
258
260
|
deduction = deductionFromDeductionNode(deductionNode, fileContext),
|
|
259
261
|
suppositions = suppositionsFromSuppositionNodes(suppositionNodes, fileContext),
|
|
262
|
+
signature = signatureFromSignatureNode(signatureNode, fileContext),
|
|
260
263
|
string = stringFromLabelsAndDeduction(labels, deduction),
|
|
261
|
-
topLevelAssertion = new Class(fileContext, string, labels, suppositions, deduction, proof,
|
|
264
|
+
topLevelAssertion = new Class(fileContext, string, labels, suppositions, deduction, proof, signature);
|
|
262
265
|
|
|
263
266
|
return topLevelAssertion;
|
|
264
267
|
}
|
|
@@ -282,6 +285,18 @@ export function labelsFromLabelNodes(labelNodes, fileContext) {
|
|
|
282
285
|
return labels;
|
|
283
286
|
}
|
|
284
287
|
|
|
288
|
+
export function signatureFromSignatureNode(signatureNode, fileContext) {
|
|
289
|
+
let signature = null;
|
|
290
|
+
|
|
291
|
+
if (signatureNode !== null) {
|
|
292
|
+
const { Signature } = dom;
|
|
293
|
+
|
|
294
|
+
signature = Signature.fromSignatureNode(signatureNode, fileContext);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return signature;
|
|
298
|
+
}
|
|
299
|
+
|
|
285
300
|
export function deductionFromDeductionNode(deductionNode, fileContext) {
|
|
286
301
|
const { Deduction } = dom,
|
|
287
302
|
deduction = Deduction.fromDeductionNode(deductionNode, fileContext);
|
|
@@ -65,7 +65,7 @@ export default class TopLevelMetaAssertion {
|
|
|
65
65
|
verify() {
|
|
66
66
|
let verified = false;
|
|
67
67
|
|
|
68
|
-
const labelVerified = this.
|
|
68
|
+
const labelVerified = this.verifyLabel();
|
|
69
69
|
|
|
70
70
|
if (labelVerified) {
|
|
71
71
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
@@ -96,7 +96,7 @@ export default class TopLevelMetaAssertion {
|
|
|
96
96
|
return verified;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
verifyLabel() {
|
|
100
100
|
const nameOnly = false,
|
|
101
101
|
labelVerified = this.label.verify(nameOnly);
|
|
102
102
|
|
package/src/dom/variable.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import dom from "../dom";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
|
-
import TermSubstitution from "../substitution/term";
|
|
6
5
|
|
|
7
6
|
import { domAssigned } from "../dom";
|
|
8
7
|
import { EMPTY_STRING } from "../constants";
|
|
@@ -154,7 +153,8 @@ export default domAssigned(class Variable {
|
|
|
154
153
|
termUnified = true;
|
|
155
154
|
}
|
|
156
155
|
} else {
|
|
157
|
-
const
|
|
156
|
+
const { TermSubstitution } = dom,
|
|
157
|
+
context = specificContext, ///
|
|
158
158
|
variable = this, ///
|
|
159
159
|
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
160
160
|
substitution = termSubstitution; ///
|
|
@@ -211,7 +211,7 @@ export default domAssigned(class Variable {
|
|
|
211
211
|
const variableNode = singularVariableNode, ///
|
|
212
212
|
type = null;
|
|
213
213
|
|
|
214
|
-
variable = variableFromVariableNodeAndType(variableNode, type
|
|
214
|
+
variable = variableFromVariableNodeAndType(variableNode, type);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
return variable;
|
|
@@ -223,22 +223,20 @@ export default domAssigned(class Variable {
|
|
|
223
223
|
if (variableNode !== null) {
|
|
224
224
|
const type = null;
|
|
225
225
|
|
|
226
|
-
variable = variableFromVariableNodeAndType(variableNode, type
|
|
226
|
+
variable = variableFromVariableNodeAndType(variableNode, type);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
return variable;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
static fromVariableNodeAndType(variableNode, type, context) {
|
|
233
|
-
const variable = variableFromVariableNodeAndType(variableNode, type
|
|
233
|
+
const variable = variableFromVariableNodeAndType(variableNode, type);
|
|
234
234
|
|
|
235
235
|
return variable;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
|
|
239
239
|
const { Variable } = dom,
|
|
240
|
-
localContext = LocalContext.fromFileContext(fileContext),
|
|
241
|
-
context = localContext,
|
|
242
240
|
provisional = variableDeclarationNode.isProvisional(),
|
|
243
241
|
typeNode = variableDeclarationNode.getTypeNode(),
|
|
244
242
|
type = typeFromTypeNode(typeNode);
|
|
@@ -249,7 +247,7 @@ export default domAssigned(class Variable {
|
|
|
249
247
|
variableName = variableDeclarationNode.getVariableName(),
|
|
250
248
|
node = variableNode, ///
|
|
251
249
|
name = variableName, ///
|
|
252
|
-
string =
|
|
250
|
+
string = name, ///
|
|
253
251
|
propertyRelations = [],
|
|
254
252
|
variable = new Variable(string, node, name, type, propertyRelations);
|
|
255
253
|
|
|
@@ -278,11 +276,11 @@ export default domAssigned(class Variable {
|
|
|
278
276
|
}
|
|
279
277
|
});
|
|
280
278
|
|
|
281
|
-
function variableFromVariableNodeAndType(variableNode, type
|
|
279
|
+
function variableFromVariableNodeAndType(variableNode, type) {
|
|
282
280
|
const { Variable } = dom,
|
|
283
281
|
node = variableNode, ///
|
|
284
282
|
variableName = variableNode.getVariableName(),
|
|
285
|
-
string =
|
|
283
|
+
string = variableName, ///,
|
|
286
284
|
name = variableName, ///
|
|
287
285
|
propertyRelations = [],
|
|
288
286
|
variable = new Variable(string, node, name, type, propertyRelations);
|
package/src/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import Statement from "./dom/statement";
|
|
|
23
23
|
import Judgement from "./dom/judgement";
|
|
24
24
|
import MetaLemma from "./dom/metaLemma";
|
|
25
25
|
import Deduction from "./dom/deduction";
|
|
26
|
+
import Signature from "./dom/signature";
|
|
26
27
|
import Conjecture from "./dom/conjecture";
|
|
27
28
|
import Conclusion from "./dom/conclusion";
|
|
28
29
|
import Derivation from "./dom/derivation";
|
|
@@ -38,6 +39,8 @@ import TypeAssertion from "./dom/assertion/type";
|
|
|
38
39
|
import TypeDeclaration from "./dom/declaration/type";
|
|
39
40
|
import DefinedAssertion from "./dom/assertion/defined";
|
|
40
41
|
import PropertyRelation from "./dom/propertyRelation";
|
|
42
|
+
import TermSubstitution from "./dom/substitution/term";
|
|
43
|
+
import FrameSubstitution from "./dom/substitution/frame";
|
|
41
44
|
import SubproofAssertion from "./dom/assertion/subproof";
|
|
42
45
|
import PropertyAssertion from "./dom/assertion/property";
|
|
43
46
|
import ContainedAssertion from "./dom/assertion/contained";
|
|
@@ -45,6 +48,8 @@ import SatisfiesAssertion from "./dom/assertion/satisfies";
|
|
|
45
48
|
import VariableDeclaration from "./dom/declaration/variable";
|
|
46
49
|
import BracketedCombinator from "./dom/combinator/bracketed";
|
|
47
50
|
import BracketedConstructor from "./dom/constructor/bracketed";
|
|
51
|
+
import ReferenceSubstitution from "./dom/substitution/reference";
|
|
52
|
+
import StatementSubstitution from "./dom/substitution/statement";
|
|
48
53
|
import CombinatorDeclaration from "./dom/declaration/combinator";
|
|
49
54
|
import ConstructorDeclaration from "./dom/declaration/constructor";
|
|
50
55
|
import ComplexTypeDeclaration from "./dom/declaration/complexType";
|