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.
Files changed (67) hide show
  1. package/bin/action/verify.js +3 -24
  2. package/bin/actions.js +20 -6
  3. package/lib/axiom.js +4 -4
  4. package/lib/axiomLemmaTheoremConjecture.js +28 -25
  5. package/lib/conclusion.js +5 -5
  6. package/lib/conjecture.js +4 -4
  7. package/lib/consequence.js +3 -3
  8. package/lib/context/file.js +90 -28
  9. package/lib/kinds.js +5 -1
  10. package/lib/lemma.js +4 -4
  11. package/lib/metaType.js +201 -0
  12. package/lib/metavariable.js +75 -0
  13. package/lib/premise.js +9 -9
  14. package/lib/rule.js +36 -29
  15. package/lib/supposition.js +5 -5
  16. package/lib/theorem.js +4 -4
  17. package/lib/utilities/query.js +13 -2
  18. package/lib/variable.js +12 -12
  19. package/lib/verifier/metastatementForMetavariable.js +8 -8
  20. package/lib/verifier/statementForMetavariable.js +9 -9
  21. package/lib/verifier/termForVariable.js +22 -11
  22. package/lib/verify/assertion/type.js +2 -2
  23. package/lib/verify/axiom.js +2 -2
  24. package/lib/verify/conjecture.js +2 -2
  25. package/lib/verify/declaration/metavariable.js +26 -0
  26. package/lib/verify/declaration/topLevel.js +7 -3
  27. package/lib/verify/lemma.js +2 -2
  28. package/lib/verify/metastatement/qualified.js +3 -3
  29. package/lib/verify/metavariable.js +34 -0
  30. package/lib/verify/rule.js +2 -2
  31. package/lib/verify/statement/qualified.js +7 -7
  32. package/lib/verify/statement.js +5 -5
  33. package/lib/verify/theorem.js +2 -2
  34. package/lib/verify/variable.js +4 -4
  35. package/package.json +3 -3
  36. package/src/axiom.js +1 -1
  37. package/src/axiomLemmaTheoremConjecture.js +27 -28
  38. package/src/conclusion.js +8 -4
  39. package/src/conjecture.js +1 -1
  40. package/src/consequence.js +2 -2
  41. package/src/context/file.js +97 -28
  42. package/src/kinds.js +1 -0
  43. package/src/lemma.js +1 -1
  44. package/src/metaType.js +81 -0
  45. package/src/metavariable.js +35 -0
  46. package/src/premise.js +16 -8
  47. package/src/rule.js +32 -27
  48. package/src/supposition.js +8 -4
  49. package/src/theorem.js +1 -1
  50. package/src/utilities/query.js +14 -0
  51. package/src/variable.js +8 -8
  52. package/src/verifier/metastatementForMetavariable.js +7 -7
  53. package/src/verifier/statementForMetavariable.js +8 -8
  54. package/src/verifier/termForVariable.js +33 -13
  55. package/src/verify/assertion/type.js +3 -3
  56. package/src/verify/axiom.js +1 -1
  57. package/src/verify/conjecture.js +2 -1
  58. package/src/verify/declaration/metavariable.js +20 -0
  59. package/src/verify/declaration/topLevel.js +9 -2
  60. package/src/verify/lemma.js +1 -1
  61. package/src/verify/metastatement/qualified.js +3 -2
  62. package/src/verify/metavariable.js +32 -0
  63. package/src/verify/rule.js +1 -1
  64. package/src/verify/statement/qualified.js +7 -6
  65. package/src/verify/statement.js +12 -12
  66. package/src/verify/theorem.js +2 -1
  67. 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;
@@ -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.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
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, metaproofContext);
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
+ }
@@ -55,7 +55,7 @@ export default function verifyRule(ruleNode, fileContext) {
55
55
  }
56
56
 
57
57
  if (ruleProofVerified) {
58
- const rule = Rule.fromLabelsPremisesAndConclusion(labels, premises, conclusion);
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, proofContext);
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, proofContext);
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, proofContext);
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, proofContext);
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, proofContext);
66
+ const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementProofContext);
66
67
 
67
68
  qualifiedStatementVerified = conjectureMatchesStatement; ///
68
69
  }
@@ -254,18 +254,18 @@ function verifyStatementAsEquality(statementNode, assignments, derived, context)
254
254
  rightVariableTypeSuperTypeOfLeftVariableType = rightVariableType.isSuperTypeOf(leftVariableType);
255
255
 
256
256
  if (leftVariableTypeSuperTypeOfRightVariableType) {
257
- const type = rightVariableType, ///
258
- name = leftVariableName, ///
259
- variable = Variable.fromTypeAndName(type, name),
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 type = leftVariableType, ///
267
- name = rightVariableName, ///
268
- variable = Variable.fromTypeAndName(type, name),
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 type = rightTermType, ///
297
- name = leftVariableName, ///
298
- variable = Variable.fromTypeAndName(type, name),
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 type = leftTermType, ///
326
- name = rightVariableName, ///
327
- variable = Variable.fromTypeAndName(type, name),
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);
@@ -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.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
54
+ const theorem = Theorem.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
54
55
 
55
56
  fileContext.addTheorem(theorem);
56
57
 
@@ -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 type = objectType,
24
- name = variableName; ///
23
+ const name = variableName, ///
24
+ type = objectType;
25
25
 
26
- variable = Variable.fromTypeAndName(type, name);
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.fromTypeAndName(type, name);
35
+ variable = Variable.fromNameAndType(name, type);
36
36
  }
37
37
  }
38
38