occam-verify-cli 0.0.538 → 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/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 +3 -3
- package/lib/verify/metavariable.js +34 -0
- package/lib/verify/rule.js +2 -2
- package/lib/verify/statement/qualified.js +7 -7
- 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/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 +3 -2
- package/src/verify/metavariable.js +32 -0
- package/src/verify/rule.js +1 -1
- package/src/verify/statement/qualified.js +7 -6
- package/src/verify/statement.js +12 -12
- package/src/verify/theorem.js +2 -1
- package/src/verify/variable.js +4 -4
|
@@ -9,6 +9,7 @@ import verifyTypeDeclaration from "../../verify/declaration/type";
|
|
|
9
9
|
import verifyVariableDeclaration from "../../verify/declaration/variable";
|
|
10
10
|
import verifyCombinatorDeclaration from "../../verify/declaration/combinator";
|
|
11
11
|
import verifyConstructorDeclaration from "../../verify/declaration/constructor";
|
|
12
|
+
import verifyMetavariableDeclaration from "../../verify/declaration/metavariable";
|
|
12
13
|
|
|
13
14
|
import { nodeQuery } from "../../utilities/query";
|
|
14
15
|
|
|
@@ -20,7 +21,8 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
|
|
|
20
21
|
typeDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/typeDeclaration!"),
|
|
21
22
|
variableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/variableDeclaration!"),
|
|
22
23
|
combinatorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/combinatorDeclaration!"),
|
|
23
|
-
constructorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/constructorDeclaration!")
|
|
24
|
+
constructorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/constructorDeclaration!"),
|
|
25
|
+
metavariableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/metavariableDeclaration!");
|
|
24
26
|
|
|
25
27
|
export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext) {
|
|
26
28
|
let topLevelDeclarationVerified = false;
|
|
@@ -34,7 +36,8 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
34
36
|
typeDeclarationNode = typeDeclarationNodeQuery(node),
|
|
35
37
|
variableDeclarationNode = variableDeclarationNodeQuery(node),
|
|
36
38
|
combinatorDeclarationNode = combinatorDeclarationNodeQuery(node),
|
|
37
|
-
constructorDeclarationNode = constructorDeclarationNodeQuery(node)
|
|
39
|
+
constructorDeclarationNode = constructorDeclarationNodeQuery(node),
|
|
40
|
+
metavariableDeclarationNode = metavariableDeclarationNodeQuery(node);
|
|
38
41
|
|
|
39
42
|
if (false) {
|
|
40
43
|
///
|
|
@@ -74,6 +77,10 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
74
77
|
const constructorDeclarationVerified = verifyConstructorDeclaration(constructorDeclarationNode, fileContext);
|
|
75
78
|
|
|
76
79
|
topLevelDeclarationVerified = constructorDeclarationVerified; ///
|
|
80
|
+
} else if (metavariableDeclarationNode !== null) {
|
|
81
|
+
const metavariableDeclarationVerified = verifyMetavariableDeclaration(metavariableDeclarationNode, fileContext);
|
|
82
|
+
|
|
83
|
+
topLevelDeclarationVerified = metavariableDeclarationVerified; ///
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
return topLevelDeclarationVerified;
|
package/src/verify/lemma.js
CHANGED
|
@@ -53,7 +53,7 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
53
53
|
proofVerified = verifyProof(proofNode, consequence, proofContext);
|
|
54
54
|
|
|
55
55
|
if (proofVerified) {
|
|
56
|
-
const lemma = Lemma.
|
|
56
|
+
const lemma = Lemma.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
|
|
57
57
|
|
|
58
58
|
fileContext.addLemma(lemma);
|
|
59
59
|
|
|
@@ -11,7 +11,8 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
11
11
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode);
|
|
12
12
|
|
|
13
13
|
if (metastatementNode !== null) {
|
|
14
|
-
const metastatementString = metaproofContext.nodeAsString(metastatementNode)
|
|
14
|
+
const metastatementString = metaproofContext.nodeAsString(metastatementNode),
|
|
15
|
+
metastatementMetaproofContext = metaproofContext; ///
|
|
15
16
|
|
|
16
17
|
metaproofContext.debug(`Verifying the '${metastatementString}' qualified metastatement...`, qualifiedMetastatementNode);
|
|
17
18
|
|
|
@@ -20,7 +21,7 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
20
21
|
rule = metaproofContext.findRuleByReferenceName(referenceName);
|
|
21
22
|
|
|
22
23
|
if (rule !== null) {
|
|
23
|
-
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode,
|
|
24
|
+
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metastatementMetaproofContext);
|
|
24
25
|
|
|
25
26
|
qualifiedMetastatementVerified = ruleMatchesMetastatement; ///
|
|
26
27
|
}
|
|
@@ -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
|
|
|
@@ -11,7 +11,8 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
11
11
|
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
12
12
|
|
|
13
13
|
if (statementNode !== null) {
|
|
14
|
-
const statementString = proofContext.nodeAsString(statementNode)
|
|
14
|
+
const statementString = proofContext.nodeAsString(statementNode),
|
|
15
|
+
statementProofContext = proofContext; ///
|
|
15
16
|
|
|
16
17
|
proofContext.debug(`Verifying the '${statementString}' qualified statement...`, qualifiedStatementNode);
|
|
17
18
|
|
|
@@ -22,7 +23,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
22
23
|
const rule = proofContext.findRuleByReferenceName(referenceName);
|
|
23
24
|
|
|
24
25
|
if (rule !== null) {
|
|
25
|
-
const ruleMatchesStatement = rule.matchStatement(statementNode,
|
|
26
|
+
const ruleMatchesStatement = rule.matchStatement(statementNode, statementProofContext);
|
|
26
27
|
|
|
27
28
|
qualifiedStatementVerified = ruleMatchesStatement; ///
|
|
28
29
|
}
|
|
@@ -32,7 +33,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
32
33
|
const axiom = proofContext.findAxiomByReferenceName(referenceName);
|
|
33
34
|
|
|
34
35
|
if (axiom !== null) {
|
|
35
|
-
const axiomMatchesStatement = axiom.matchStatement(statementNode,
|
|
36
|
+
const axiomMatchesStatement = axiom.matchStatement(statementNode, statementProofContext);
|
|
36
37
|
|
|
37
38
|
qualifiedStatementVerified = axiomMatchesStatement; ///
|
|
38
39
|
}
|
|
@@ -42,7 +43,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
42
43
|
const lemma = proofContext.findLemmaByReferenceName(referenceName);
|
|
43
44
|
|
|
44
45
|
if (lemma !== null) {
|
|
45
|
-
const lemmaMatchesStatement = lemma.matchStatement(statementNode,
|
|
46
|
+
const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementProofContext);
|
|
46
47
|
|
|
47
48
|
qualifiedStatementVerified = lemmaMatchesStatement; ///
|
|
48
49
|
}
|
|
@@ -52,7 +53,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
52
53
|
const theorem = proofContext.findTheoremByReferenceName(referenceName);
|
|
53
54
|
|
|
54
55
|
if (theorem !== null) {
|
|
55
|
-
const theoremMatchesStatement = theorem.matchStatement(statementNode,
|
|
56
|
+
const theoremMatchesStatement = theorem.matchStatement(statementNode, statementProofContext);
|
|
56
57
|
|
|
57
58
|
qualifiedStatementVerified = theoremMatchesStatement; ///
|
|
58
59
|
}
|
|
@@ -62,7 +63,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
62
63
|
const conjecture = proofContext.findConjectureByReferenceName(referenceName);
|
|
63
64
|
|
|
64
65
|
if (conjecture !== null) {
|
|
65
|
-
const conjectureMatchesStatement = conjecture.matchStatement(statementNode,
|
|
66
|
+
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementProofContext);
|
|
66
67
|
|
|
67
68
|
qualifiedStatementVerified = conjectureMatchesStatement; ///
|
|
68
69
|
}
|
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
|
|