occam-verify-cli 0.0.537 → 0.0.539
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/bin/action/verify.js +3 -24
- package/bin/actions.js +20 -6
- package/lib/axiom.js +4 -4
- package/lib/axiomLemmaTheoremConjecture.js +28 -25
- package/lib/conclusion.js +5 -5
- package/lib/conjecture.js +4 -4
- package/lib/consequence.js +3 -3
- package/lib/context/file.js +90 -28
- package/lib/equality.js +3 -3
- package/lib/kinds.js +5 -1
- package/lib/lemma.js +4 -4
- package/lib/metaType.js +201 -0
- package/lib/metavariable.js +75 -0
- package/lib/premise.js +9 -9
- package/lib/rule.js +36 -29
- package/lib/supposition.js +5 -5
- package/lib/theorem.js +4 -4
- package/lib/utilities/query.js +13 -2
- package/lib/variable.js +12 -12
- package/lib/verifier/metastatementForMetavariable.js +8 -8
- package/lib/verifier/statementForMetavariable.js +9 -9
- package/lib/verifier/termForVariable.js +22 -11
- package/lib/verify/assertion/type.js +2 -2
- package/lib/verify/axiom.js +2 -2
- package/lib/verify/conjecture.js +2 -2
- package/lib/verify/declaration/metavariable.js +26 -0
- package/lib/verify/declaration/topLevel.js +7 -3
- package/lib/verify/lemma.js +2 -2
- package/lib/verify/metastatement/qualified.js +6 -19
- package/lib/verify/metastatement/unqualified.js +5 -5
- package/lib/verify/metavariable.js +34 -0
- package/lib/verify/rule.js +2 -2
- package/lib/verify/statement/qualified.js +32 -44
- package/lib/verify/statement/unqualified.js +4 -4
- package/lib/verify/statement.js +5 -5
- package/lib/verify/theorem.js +2 -2
- package/lib/verify/variable.js +4 -4
- package/package.json +3 -3
- package/src/axiom.js +1 -1
- package/src/axiomLemmaTheoremConjecture.js +27 -28
- package/src/conclusion.js +8 -4
- package/src/conjecture.js +1 -1
- package/src/consequence.js +2 -2
- package/src/context/file.js +97 -28
- package/src/equality.js +2 -2
- package/src/kinds.js +1 -0
- package/src/lemma.js +1 -1
- package/src/metaType.js +81 -0
- package/src/metavariable.js +35 -0
- package/src/premise.js +16 -8
- package/src/rule.js +32 -27
- package/src/supposition.js +8 -4
- package/src/theorem.js +1 -1
- package/src/utilities/query.js +14 -0
- package/src/variable.js +8 -8
- package/src/verifier/metastatementForMetavariable.js +7 -7
- package/src/verifier/statementForMetavariable.js +8 -8
- package/src/verifier/termForVariable.js +33 -13
- package/src/verify/assertion/type.js +3 -3
- package/src/verify/axiom.js +1 -1
- package/src/verify/conjecture.js +2 -1
- package/src/verify/declaration/metavariable.js +20 -0
- package/src/verify/declaration/topLevel.js +9 -2
- package/src/verify/lemma.js +1 -1
- package/src/verify/metastatement/qualified.js +8 -18
- package/src/verify/metastatement/unqualified.js +5 -5
- package/src/verify/metavariable.js +32 -0
- package/src/verify/rule.js +1 -1
- package/src/verify/statement/qualified.js +33 -42
- package/src/verify/statement/unqualified.js +4 -4
- package/src/verify/statement.js +12 -12
- package/src/verify/theorem.js +2 -1
- package/src/verify/variable.js +4 -4
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyMetastatement from "../../verify/metastatement";
|
|
4
|
-
|
|
5
3
|
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
6
4
|
|
|
7
5
|
const referenceNodeQuery = nodeQuery("/qualifiedMetastatement/qualification!/reference!"),
|
|
@@ -13,27 +11,19 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
13
11
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode);
|
|
14
12
|
|
|
15
13
|
if (metastatementNode !== null) {
|
|
16
|
-
const metastatementString = metaproofContext.nodeAsString(metastatementNode)
|
|
14
|
+
const metastatementString = metaproofContext.nodeAsString(metastatementNode),
|
|
15
|
+
metastatementMetaproofContext = metaproofContext; ///
|
|
17
16
|
|
|
18
17
|
metaproofContext.debug(`Verifying the '${metastatementString}' qualified metastatement...`, qualifiedMetastatementNode);
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (referenceNode !== null) {
|
|
25
|
-
const referenceName = referenceNameFromReferenceNode(referenceNode),
|
|
26
|
-
rule = metaproofContext.findRuleByReferenceName(referenceName);
|
|
27
|
-
|
|
28
|
-
if (rule !== null) {
|
|
29
|
-
ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metaproofContext);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
19
|
+
const referenceNode = referenceNodeQuery(qualifiedMetastatementNode),
|
|
20
|
+
referenceName = referenceNameFromReferenceNode(referenceNode),
|
|
21
|
+
rule = metaproofContext.findRuleByReferenceName(referenceName);
|
|
32
22
|
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
23
|
+
if (rule !== null) {
|
|
24
|
+
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metastatementMetaproofContext);
|
|
35
25
|
|
|
36
|
-
qualifiedMetastatementVerified =
|
|
26
|
+
qualifiedMetastatementVerified = ruleMatchesMetastatement; ///
|
|
37
27
|
}
|
|
38
28
|
}
|
|
39
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyMetastatement from "
|
|
3
|
+
import verifyMetastatement from "../../verify/metastatement";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../../utilities/query";
|
|
6
6
|
|
|
@@ -16,13 +16,13 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
|
|
|
16
16
|
|
|
17
17
|
metaproofContext.debug(`Verifying the '${metastatementString}' unqualified metastatement...`, unqualifiedMetastatementNode);
|
|
18
18
|
|
|
19
|
-
let metastatementMatches = true;
|
|
20
|
-
|
|
21
19
|
if (derived) {
|
|
22
|
-
metastatementMatches = metaproofContext.matchMetastatement(metastatementNode);
|
|
20
|
+
const metastatementMatches = metaproofContext.matchMetastatement(metastatementNode);
|
|
21
|
+
|
|
22
|
+
unqualifiedMetastatementVerified = metastatementMatches; ///
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (
|
|
25
|
+
if (!unqualifiedMetastatementVerified) {
|
|
26
26
|
const metastatementVerified = verifyMetastatement(metastatementNode, assignments, derived, metaproofContext);
|
|
27
27
|
|
|
28
28
|
unqualifiedMetastatementVerified = metastatementVerified; ///
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Metavariable from "../metavariable";
|
|
4
|
+
|
|
5
|
+
import { metaTypeNameFromMetaTypeNode, metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
6
|
+
|
|
7
|
+
export default function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
8
|
+
let metavariableVerified = false;
|
|
9
|
+
|
|
10
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
11
|
+
metavariableString = fileContext.nodeAsString(metavariableNode),
|
|
12
|
+
metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
13
|
+
|
|
14
|
+
if (metavariablePresent) {
|
|
15
|
+
fileContext.error(`The metavariable '${metavariableName}' is already present.`, metavariableNode);
|
|
16
|
+
} else {
|
|
17
|
+
const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
|
|
18
|
+
metaType = fileContext.findMetaTypeByMetaTypeName(metaTypeName),
|
|
19
|
+
name = metavariableName, ///
|
|
20
|
+
metavariable = Metavariable.fromNameAndMetaType(name, metaType);
|
|
21
|
+
|
|
22
|
+
fileContext.addMetavariable(metavariable);
|
|
23
|
+
|
|
24
|
+
metavariableVerified = true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (metavariableVerified) {
|
|
28
|
+
fileContext.info(`Verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return metavariableVerified;
|
|
32
|
+
}
|
package/src/verify/rule.js
CHANGED
|
@@ -55,7 +55,7 @@ export default function verifyRule(ruleNode, fileContext) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (ruleProofVerified) {
|
|
58
|
-
const rule = Rule.
|
|
58
|
+
const rule = Rule.fromLabelsPremisesConclusionAndFileContext(labels, premises, conclusion, fileContext);
|
|
59
59
|
|
|
60
60
|
fileContext.addRule(rule);
|
|
61
61
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyStatement from "../../verify/statement";
|
|
4
|
-
|
|
5
3
|
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
6
4
|
|
|
7
5
|
const referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
|
|
@@ -13,68 +11,61 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
13
11
|
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
14
12
|
|
|
15
13
|
if (statementNode !== null) {
|
|
16
|
-
const statementString = proofContext.nodeAsString(statementNode)
|
|
14
|
+
const statementString = proofContext.nodeAsString(statementNode),
|
|
15
|
+
statementProofContext = proofContext; ///
|
|
17
16
|
|
|
18
17
|
proofContext.debug(`Verifying the '${statementString}' qualified statement...`, qualifiedStatementNode);
|
|
19
18
|
|
|
20
|
-
const referenceNode = referenceNodeQuery(qualifiedStatementNode)
|
|
21
|
-
|
|
22
|
-
if (referenceNode === null) {
|
|
23
|
-
const context = proofContext,
|
|
24
|
-
statementVerified = verifyStatement(statementNode, assignments, derived, context);
|
|
25
|
-
|
|
26
|
-
qualifiedStatementVerified = statementVerified; ///
|
|
27
|
-
} else {
|
|
28
|
-
const referenceName = referenceNameFromReferenceNode(referenceNode);
|
|
19
|
+
const referenceNode = referenceNodeQuery(qualifiedStatementNode),
|
|
20
|
+
referenceName = referenceNameFromReferenceNode(referenceNode);
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
if (!qualifiedStatementVerified) {
|
|
23
|
+
const rule = proofContext.findRuleByReferenceName(referenceName);
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
if (rule !== null) {
|
|
26
|
+
const ruleMatchesStatement = rule.matchStatement(statementNode, statementProofContext);
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
}
|
|
28
|
+
qualifiedStatementVerified = ruleMatchesStatement; ///
|
|
38
29
|
}
|
|
30
|
+
}
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
if (!qualifiedStatementVerified) {
|
|
33
|
+
const axiom = proofContext.findAxiomByReferenceName(referenceName);
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
if (axiom !== null) {
|
|
36
|
+
const axiomMatchesStatement = axiom.matchStatement(statementNode, statementProofContext);
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
}
|
|
38
|
+
qualifiedStatementVerified = axiomMatchesStatement; ///
|
|
48
39
|
}
|
|
40
|
+
}
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
if (!qualifiedStatementVerified) {
|
|
43
|
+
const lemma = proofContext.findLemmaByReferenceName(referenceName);
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
if (lemma !== null) {
|
|
46
|
+
const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementProofContext);
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
}
|
|
48
|
+
qualifiedStatementVerified = lemmaMatchesStatement; ///
|
|
58
49
|
}
|
|
50
|
+
}
|
|
59
51
|
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
if (!qualifiedStatementVerified) {
|
|
53
|
+
const theorem = proofContext.findTheoremByReferenceName(referenceName);
|
|
62
54
|
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
if (theorem !== null) {
|
|
56
|
+
const theoremMatchesStatement = theorem.matchStatement(statementNode, statementProofContext);
|
|
65
57
|
|
|
66
|
-
|
|
67
|
-
}
|
|
58
|
+
qualifiedStatementVerified = theoremMatchesStatement; ///
|
|
68
59
|
}
|
|
60
|
+
}
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
if (!qualifiedStatementVerified) {
|
|
63
|
+
const conjecture = proofContext.findConjectureByReferenceName(referenceName);
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
if (conjecture !== null) {
|
|
66
|
+
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementProofContext);
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
}
|
|
68
|
+
qualifiedStatementVerified = conjectureMatchesStatement; ///
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
71
|
}
|
|
@@ -16,13 +16,13 @@ export default function verifyUnqualifiedStatement(unqualifiedStatementNode, ass
|
|
|
16
16
|
|
|
17
17
|
proofContext.debug(`Verifying the '${statementString}' unqualified statement...`, unqualifiedStatementNode);
|
|
18
18
|
|
|
19
|
-
let statementMatches = true;
|
|
20
|
-
|
|
21
19
|
if (derived) {
|
|
22
|
-
statementMatches = proofContext.matchStatement(statementNode);
|
|
20
|
+
const statementMatches = proofContext.matchStatement(statementNode);
|
|
21
|
+
|
|
22
|
+
unqualifiedStatementVerified = statementMatches; ///
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (
|
|
25
|
+
if (!unqualifiedStatementVerified) {
|
|
26
26
|
const context = proofContext, ///
|
|
27
27
|
statementVerified = verifyStatement(statementNode, assignments, derived, context);
|
|
28
28
|
|
package/src/verify/statement.js
CHANGED
|
@@ -254,18 +254,18 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
|
|
|
254
254
|
rightVariableTypeSuperTypeOfLeftVariableType = rightVariableType.isSuperTypeOf(leftVariableType);
|
|
255
255
|
|
|
256
256
|
if (leftVariableTypeSuperTypeOfRightVariableType) {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
variable = Variable.
|
|
257
|
+
const name = leftVariableName, ///
|
|
258
|
+
type = rightVariableType, ///
|
|
259
|
+
variable = Variable.fromNameAndType(name, type),
|
|
260
260
|
assignment = Assignment.fromVariable(variable);
|
|
261
261
|
|
|
262
262
|
assignments.push(assignment);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
if (rightVariableTypeSuperTypeOfLeftVariableType) {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
variable = Variable.
|
|
266
|
+
const name = rightVariableName, ///
|
|
267
|
+
type = leftVariableType, ///
|
|
268
|
+
variable = Variable.fromNameAndType(name, type),
|
|
269
269
|
assignment = Assignment.fromVariable(variable);
|
|
270
270
|
|
|
271
271
|
assignments.push(assignment);
|
|
@@ -293,9 +293,9 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
|
|
|
293
293
|
|
|
294
294
|
context.error(`The left '${leftVariableName}' variable's '${leftVariableTypeName}' type is not equal to or a super-type of the right '${rightTermString}' term's '${rightTermTypeName}' type.`, statementNode);
|
|
295
295
|
} else {
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
variable = Variable.
|
|
296
|
+
const name = leftVariableName, ///
|
|
297
|
+
type = rightTermType, ///
|
|
298
|
+
variable = Variable.fromNameAndType(name, type),
|
|
299
299
|
assignment = Assignment.fromVariable(variable);
|
|
300
300
|
|
|
301
301
|
assignments.push(assignment);
|
|
@@ -322,9 +322,9 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
|
|
|
322
322
|
|
|
323
323
|
context.error(`The right '${rightVariableName}' variable's '${rightVariableTypeName}' type is not equal to or a super-type of the left '${leftTermString}' term's '${leftTermTypeName}' type.`, statementNode);
|
|
324
324
|
} else {
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
variable = Variable.
|
|
325
|
+
const name = rightVariableName, ///
|
|
326
|
+
type = leftTermType, ///
|
|
327
|
+
variable = Variable.fromNameAndType(name, type),
|
|
328
328
|
assignment = Assignment.fromVariable(variable);
|
|
329
329
|
|
|
330
330
|
assignments.push(assignment);
|
package/src/verify/theorem.js
CHANGED
|
@@ -9,6 +9,7 @@ import verifyConsequence from "./consequence";
|
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
|
+
import proof from "../context/proof";
|
|
12
13
|
|
|
13
14
|
const proofNodeQuery = nodeQuery("/theorem/proof!"),
|
|
14
15
|
labelNodesQuery = nodesQuery("/theorem/label"),
|
|
@@ -50,7 +51,7 @@ export default function verifyTheorem(theoremNode, fileContext) {
|
|
|
50
51
|
proofVerified = verifyProof(proofNode, consequence, proofContext);
|
|
51
52
|
|
|
52
53
|
if (proofVerified) {
|
|
53
|
-
const theorem = Theorem.
|
|
54
|
+
const theorem = Theorem.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
|
|
54
55
|
|
|
55
56
|
fileContext.addTheorem(theorem);
|
|
56
57
|
|
package/src/verify/variable.js
CHANGED
|
@@ -20,10 +20,10 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
|
|
|
20
20
|
const typeName = typeNameFromTypeNode(typeNode);
|
|
21
21
|
|
|
22
22
|
if (typeName === null) {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const name = variableName, ///
|
|
24
|
+
type = objectType;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
variable = Variable.fromNameAndType(name, type);
|
|
27
27
|
} else {
|
|
28
28
|
const type = fileContext.findTypeByTypeName(typeName);
|
|
29
29
|
|
|
@@ -32,7 +32,7 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
|
|
|
32
32
|
} else {
|
|
33
33
|
const name = variableName; ///
|
|
34
34
|
|
|
35
|
-
variable = Variable.
|
|
35
|
+
variable = Variable.fromNameAndType(name, type);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|