occam-verify-cli 0.0.1016 → 0.0.1020

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 (151) hide show
  1. package/lib/argument.js +12 -11
  2. package/lib/assignment/equality.js +3 -3
  3. package/lib/axiom.js +102 -6
  4. package/lib/combinator.js +12 -12
  5. package/lib/conclusion.js +3 -4
  6. package/lib/consequent.js +75 -14
  7. package/lib/constructor/bracketed.js +3 -3
  8. package/lib/constructor.js +68 -18
  9. package/lib/context/file.js +49 -89
  10. package/lib/context/local.js +34 -58
  11. package/lib/declaration/combinator.js +3 -3
  12. package/lib/declaration/metavariable.js +15 -4
  13. package/lib/declaration/type.js +3 -3
  14. package/lib/declaration/variable.js +146 -0
  15. package/lib/equality.js +95 -19
  16. package/lib/index.js +6 -1
  17. package/lib/label.js +9 -9
  18. package/lib/lemma.js +107 -6
  19. package/lib/metavariable.js +14 -21
  20. package/lib/mixins/statement/qualified/unify.js +3 -3
  21. package/lib/mixins/statement/verify.js +4 -5
  22. package/lib/mixins/term/unify.js +82 -0
  23. package/lib/mixins/term/verify.js +44 -0
  24. package/lib/node/term/constructor/bracketed.js +15 -11
  25. package/lib/premise.js +3 -5
  26. package/lib/proofStep.js +2 -2
  27. package/lib/reference.js +9 -9
  28. package/lib/rule.js +5 -5
  29. package/lib/ruleNames.js +5 -5
  30. package/lib/statement/qualified.js +6 -3
  31. package/lib/statement.js +22 -39
  32. package/lib/supposition.js +75 -50
  33. package/lib/term.js +62 -16
  34. package/lib/topLevelAssertion.js +98 -33
  35. package/lib/type.js +22 -31
  36. package/lib/unifier/equality.js +12 -4
  37. package/lib/unifier/intrinsicLevel.js +1 -4
  38. package/lib/unifier/metaLevel.js +1 -4
  39. package/lib/unifier/metavariable.js +10 -7
  40. package/lib/unifier/statementWithCombinator.js +18 -9
  41. package/lib/unifier/termWithConstructor.js +11 -4
  42. package/lib/unify/frameWithMetaType.js +2 -2
  43. package/lib/utilities/name.js +9 -2
  44. package/lib/utilities/node.js +14 -14
  45. package/lib/utilities/tokens.js +7 -7
  46. package/lib/utilities/unify.js +3 -3
  47. package/lib/variable.js +155 -20
  48. package/lib/verifier/statementAsCombinator.js +2 -2
  49. package/lib/verifier/termAsConstructor.js +2 -2
  50. package/lib/verifier/topLevel.js +7 -7
  51. package/lib/verify/assertion/type.js +3 -4
  52. package/lib/verify/conjecture.js +2 -3
  53. package/lib/verify/frame.js +2 -6
  54. package/lib/verify/lemma.js +2 -3
  55. package/lib/verify/metaLemma.js +2 -3
  56. package/lib/verify/metatheorem.js +2 -3
  57. package/lib/verify/metavariableGivenMetaType.js +3 -3
  58. package/lib/verify/theorem.js +2 -3
  59. package/package.json +1 -1
  60. package/src/argument.js +11 -9
  61. package/src/assignment/equality.js +3 -4
  62. package/src/axiom.js +78 -1
  63. package/src/combinator.js +10 -9
  64. package/src/conclusion.js +2 -4
  65. package/src/consequent.js +88 -13
  66. package/src/constructor/bracketed.js +4 -1
  67. package/src/constructor.js +18 -14
  68. package/src/context/file.js +50 -93
  69. package/src/context/local.js +13 -31
  70. package/src/declaration/combinator.js +2 -2
  71. package/src/declaration/metavariable.js +20 -6
  72. package/src/declaration/type.js +2 -2
  73. package/src/declaration/variable.js +78 -0
  74. package/src/equality.js +123 -22
  75. package/src/index.js +6 -0
  76. package/src/label.js +7 -7
  77. package/src/lemma.js +91 -1
  78. package/src/metavariable.js +13 -22
  79. package/src/mixins/statement/qualified/unify.js +2 -2
  80. package/src/mixins/statement/verify.js +5 -5
  81. package/src/mixins/term/unify.js +110 -0
  82. package/src/mixins/term/verify.js +47 -0
  83. package/src/node/term/constructor/bracketed.js +4 -3
  84. package/src/premise.js +2 -5
  85. package/src/proofStep.js +1 -1
  86. package/src/reference.js +7 -7
  87. package/src/rule.js +4 -4
  88. package/src/ruleNames.js +1 -1
  89. package/src/statement/qualified.js +7 -3
  90. package/src/statement.js +28 -60
  91. package/src/supposition.js +106 -53
  92. package/src/term.js +70 -14
  93. package/src/topLevelAssertion.js +120 -33
  94. package/src/type.js +39 -41
  95. package/src/unifier/equality.js +15 -3
  96. package/src/unifier/intrinsicLevel.js +0 -4
  97. package/src/unifier/metaLevel.js +0 -4
  98. package/src/unifier/metavariable.js +16 -8
  99. package/src/unifier/statementWithCombinator.js +33 -11
  100. package/src/unifier/termWithConstructor.js +17 -4
  101. package/src/unify/frameWithMetaType.js +1 -1
  102. package/src/utilities/name.js +9 -1
  103. package/src/utilities/node.js +14 -14
  104. package/src/utilities/tokens.js +4 -4
  105. package/src/utilities/unify.js +2 -2
  106. package/src/variable.js +158 -22
  107. package/src/verifier/statementAsCombinator.js +1 -1
  108. package/src/verifier/termAsConstructor.js +1 -1
  109. package/src/verifier/topLevel.js +9 -6
  110. package/src/verify/assertion/type.js +1 -1
  111. package/src/verify/conjecture.js +1 -1
  112. package/src/verify/frame.js +1 -7
  113. package/src/verify/lemma.js +1 -1
  114. package/src/verify/metaLemma.js +1 -1
  115. package/src/verify/metatheorem.js +1 -1
  116. package/src/verify/metavariableGivenMetaType.js +2 -2
  117. package/src/verify/theorem.js +1 -1
  118. package/lib/tokens/constructorTerm/bracketed.js +0 -17
  119. package/lib/unify/termWithBracketedConstructor.js +0 -39
  120. package/lib/unify/termWithConstructor.js +0 -37
  121. package/lib/unify/termWithConstructors.js +0 -34
  122. package/lib/unify/termWithTerm.js +0 -27
  123. package/lib/unify/termWithType.js +0 -24
  124. package/lib/verify/axiom.js +0 -45
  125. package/lib/verify/consequent.js +0 -38
  126. package/lib/verify/declaration/variable.js +0 -67
  127. package/lib/verify/equality.js +0 -92
  128. package/lib/verify/proofStep.js +0 -28
  129. package/lib/verify/term.js +0 -97
  130. package/lib/verify/termAsConstructor.js +0 -58
  131. package/lib/verify/termGivenType.js +0 -34
  132. package/lib/verify/terms.js +0 -38
  133. package/lib/verify/type.js +0 -23
  134. package/lib/verify/variable.js +0 -25
  135. package/src/tokens/constructorTerm/bracketed.js +0 -10
  136. package/src/unify/termWithBracketedConstructor.js +0 -39
  137. package/src/unify/termWithConstructor.js +0 -39
  138. package/src/unify/termWithConstructors.js +0 -27
  139. package/src/unify/termWithTerm.js +0 -24
  140. package/src/unify/termWithType.js +0 -14
  141. package/src/verify/axiom.js +0 -56
  142. package/src/verify/consequent.js +0 -40
  143. package/src/verify/declaration/variable.js +0 -85
  144. package/src/verify/equality.js +0 -118
  145. package/src/verify/proofStep.js +0 -21
  146. package/src/verify/term.js +0 -123
  147. package/src/verify/termAsConstructor.js +0 -66
  148. package/src/verify/termGivenType.js +0 -32
  149. package/src/verify/terms.js +0 -38
  150. package/src/verify/type.js +0 -19
  151. package/src/verify/variable.js +0 -21
@@ -1,25 +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 verifyVariable;
9
- }
10
- });
11
- function verifyVariable(variableNode, localContext) {
12
- var variableVerified = false;
13
- var variableString = localContext.nodeAsString(variableNode);
14
- localContext.trace("Verifying the '".concat(variableString, "' variable..."), variableNode);
15
- var variablePresent = localContext.isVariablePresentByVariableNode(variableNode);
16
- if (variablePresent) {
17
- variableVerified = true;
18
- }
19
- if (variableVerified) {
20
- localContext.debug("...verified the '".concat(variableString, "' variable."), variableNode);
21
- }
22
- return variableVerified;
23
- }
24
-
25
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZnkvdmFyaWFibGUuanMiXSwic291cmNlc0NvbnRlbnQiOlsiXCJ1c2Ugc3RyaWN0XCI7XG5cbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIHZlcmlmeVZhcmlhYmxlKHZhcmlhYmxlTm9kZSwgbG9jYWxDb250ZXh0KSB7XG4gIGxldCB2YXJpYWJsZVZlcmlmaWVkID0gZmFsc2U7XG5cbiAgY29uc3QgdmFyaWFibGVTdHJpbmcgPSBsb2NhbENvbnRleHQubm9kZUFzU3RyaW5nKHZhcmlhYmxlTm9kZSk7XG5cbiAgbG9jYWxDb250ZXh0LnRyYWNlKGBWZXJpZnlpbmcgdGhlICcke3ZhcmlhYmxlU3RyaW5nfScgdmFyaWFibGUuLi5gLCB2YXJpYWJsZU5vZGUpO1xuXG4gIGNvbnN0IHZhcmlhYmxlUHJlc2VudCA9IGxvY2FsQ29udGV4dC5pc1ZhcmlhYmxlUHJlc2VudEJ5VmFyaWFibGVOb2RlKHZhcmlhYmxlTm9kZSk7XG5cbiAgaWYgKHZhcmlhYmxlUHJlc2VudCkge1xuICAgIHZhcmlhYmxlVmVyaWZpZWQgPSB0cnVlO1xuICB9XG5cbiAgaWYgKHZhcmlhYmxlVmVyaWZpZWQpIHtcbiAgICBsb2NhbENvbnRleHQuZGVidWcoYC4uLnZlcmlmaWVkIHRoZSAnJHt2YXJpYWJsZVN0cmluZ30nIHZhcmlhYmxlLmAsIHZhcmlhYmxlTm9kZSk7XG4gIH1cblxuICByZXR1cm4gdmFyaWFibGVWZXJpZmllZDtcbn1cbiJdLCJuYW1lcyI6WyJ2ZXJpZnlWYXJpYWJsZSIsInZhcmlhYmxlTm9kZSIsImxvY2FsQ29udGV4dCIsInZhcmlhYmxlVmVyaWZpZWQiLCJ2YXJpYWJsZVN0cmluZyIsIm5vZGVBc1N0cmluZyIsInRyYWNlIiwidmFyaWFibGVQcmVzZW50IiwiaXNWYXJpYWJsZVByZXNlbnRCeVZhcmlhYmxlTm9kZSIsImRlYnVnIl0sIm1hcHBpbmdzIjoiQUFBQTs7OzsrQkFFQTs7O2VBQXdCQTs7O0FBQVQsU0FBU0EsZUFBZUMsWUFBWSxFQUFFQyxZQUFZO0lBQy9ELElBQUlDLG1CQUFtQjtJQUV2QixJQUFNQyxpQkFBaUJGLGFBQWFHLFlBQVksQ0FBQ0o7SUFFakRDLGFBQWFJLEtBQUssQ0FBQyxBQUFDLGtCQUFnQyxPQUFmRixnQkFBZSxrQkFBZ0JIO0lBRXBFLElBQU1NLGtCQUFrQkwsYUFBYU0sK0JBQStCLENBQUNQO0lBRXJFLElBQUlNLGlCQUFpQjtRQUNuQkosbUJBQW1CO0lBQ3JCO0lBRUEsSUFBSUEsa0JBQWtCO1FBQ3BCRCxhQUFhTyxLQUFLLENBQUMsQUFBQyxvQkFBa0MsT0FBZkwsZ0JBQWUsZ0JBQWNIO0lBQ3RFO0lBRUEsT0FBT0U7QUFDVCJ9
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- import { OBJECT_TYPE_NAME } from "../../typeNames";
4
- import { termTokensFromTermString } from "../../utilities/tokens";
5
-
6
- const bracketedConstructorTermString = `(${OBJECT_TYPE_NAME})`;
7
-
8
- const bracketedConstructorDeclarationTokens = termTokensFromTermString(bracketedConstructorTermString)
9
-
10
- export default bracketedConstructorDeclarationTokens;
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- import shim from "../shim";
4
- import bracketedConstructor from "../constructor/bracketed";
5
- import unifyTermWithConstructor from "../unify/termWithConstructor";
6
-
7
- import { nodeQuery } from "../utilities/query";
8
-
9
- const termNodeQuery = nodeQuery("/term/argument/term");
10
-
11
- export default function unifyTermWithBracketedConstructor(termNode, terms, localContext, verifyAhead) {
12
- let termUnifiedWithBracketedConstructor;
13
-
14
- const termString = localContext.nodeAsString(termNode),
15
- bracketedTerms = [];
16
-
17
- localContext.trace(`Unifying the '${termString}' term with the bracketed constructor...`, termNode);
18
-
19
- termUnifiedWithBracketedConstructor = unifyTermWithConstructor(termNode, bracketedTerms, bracketedConstructor, localContext, () => {
20
- let verifiedAhead;
21
-
22
- const bracketedTermNode = termNode; ///
23
-
24
- termNode = termNodeQuery(bracketedTermNode); ///
25
-
26
- const { verifyTerm } = shim,
27
- termVVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
28
-
29
- verifiedAhead = termVVerified; ///
30
-
31
- return verifiedAhead;
32
- });
33
-
34
- if (termUnifiedWithBracketedConstructor) {
35
- localContext.debug(`...unified the '${termString}' term with the bracketed constructor.`, termNode);
36
- }
37
-
38
- return termUnifiedWithBracketedConstructor;
39
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- import Term from "../term";
4
- import termWithConstructorUnifier from "../unifier/termWithConstructor";
5
-
6
- export default function unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead) {
7
- let termUnifiedWithConstructor = false;
8
-
9
- const termString = localContext.nodeAsString(termNode),
10
- constructorString = constructor.getString(),
11
- constructorTermNode = constructor.getTermNode();
12
-
13
- localContext.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, termNode);
14
-
15
- const termNodeA = termNode, ///
16
- constructorTermNodeB = constructorTermNode, ///
17
- unified = termWithConstructorUnifier.unify(termNodeA, constructorTermNodeB, localContext);
18
-
19
- if (unified) {
20
- let verifiedAhead;
21
-
22
- const type = constructor.getType(),
23
- term = Term.fromTermNodeAndType(termNode, type);
24
-
25
- terms.push(term);
26
-
27
- verifiedAhead = verifyAhead();
28
-
29
- terms.pop();
30
-
31
- termUnifiedWithConstructor = verifiedAhead; ///
32
- }
33
-
34
- if (termUnifiedWithConstructor) {
35
- localContext.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, termNode);
36
- }
37
-
38
- return termUnifiedWithConstructor;
39
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- import unifyTermWithConstructor from "../unify/termWithConstructor";
4
-
5
- import { nodeQuery } from "../utilities/query";
6
-
7
- const variableNodeQuery = nodeQuery("/term/variable!");
8
-
9
- export default function unifyTermWithConstructors(termNode, terms, localContext, verifyAhead) {
10
- let termUnifiedWithConstructors = false;
11
-
12
- const variableNode = variableNodeQuery(termNode);
13
-
14
- if (variableNode === null) {
15
- const constructors = localContext.getConstructors();
16
-
17
- termUnifiedWithConstructors = constructors.some((constructor) => {
18
- const termUnifiedWithConstructor = unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead);
19
-
20
- if (termUnifiedWithConstructor) {
21
- return true;
22
- }
23
- });
24
- }
25
-
26
- return termUnifiedWithConstructors;
27
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- import { findEquivalenceByTermNodes } from "../utilities/equivalences";
4
-
5
- export default function unifyTermWithTerm(leftTermNode, rightTermNode, localContext) {
6
- let termUnifiedWithTerm;
7
-
8
- const leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode);
9
-
10
- if (leftTermNodeMatchesRightTermNode) {
11
- termUnifiedWithTerm = true;
12
- } else {
13
- const equivalences = localContext.getEquivalences(),
14
- termNodes = [
15
- leftTermNode,
16
- rightTermNode
17
- ],
18
- equivalence = findEquivalenceByTermNodes(equivalences, termNodes);
19
-
20
- termUnifiedWithTerm = (equivalence !== null);
21
- }
22
-
23
- return termUnifiedWithTerm;
24
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- import verifyTermGivenType from "../verify/termGivenType";
4
-
5
- export default function unifyTermWithType(termNode, typeNode, localContext) {
6
- let termUnifiedWithType;
7
-
8
- const type = localContext.findTypeByTypeNode(typeNode),
9
- termVerifiedGivenType = verifyTermGivenType(termNode, type, localContext);
10
-
11
- termUnifiedWithType = termVerifiedGivenType; ///
12
-
13
- return termUnifiedWithType;
14
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- import Axiom from "../axiom";
4
- import LocalContext from "../context/local";
5
- import Substitutions from "../substitutions";
6
- import verifyConsequent from "../verify/consequent";
7
- // import verifySuppositions from "../verify/suppositions";
8
-
9
- import { first } from "../utilities/array";
10
- import { nodeQuery, nodesQuery } from "../utilities/query";
11
-
12
- const labelNodesQuery = nodesQuery("/axiom/label"),
13
- consequentNodeQuery = nodeQuery("/axiom/consequent!"),
14
- suppositionsNodeQuery = nodesQuery("/axiom/supposition");
15
-
16
- export default function verifyAxiom(axiomNode, fileContext) {
17
- let axiomVerified = false;
18
-
19
- const labelNodes = labelNodesQuery(axiomNode),
20
- labelsString = fileContext.nodesAsString(labelNodes);
21
-
22
- fileContext.trace(`Verifying the '${labelsString}' axiom...`, axiomNode);
23
-
24
- const labels = [],
25
- labelsVerified = verifyLabels(labelNodes, labels, fileContext);
26
-
27
- if (labelsVerified) {
28
- const localContext = LocalContext.fromFileContext(fileContext),
29
- suppositions = [],
30
- suppositionNodes = suppositionsNodeQuery(axiomNode),
31
- suppositionsVerified = verifySuppositions(suppositionNodes, suppositions, localContext);
32
-
33
- if (suppositionsVerified) {
34
- const consequents = [],
35
- consequentNode = consequentNodeQuery(axiomNode),
36
- consequentVerified = verifyConsequent(consequentNode, consequents, localContext);
37
-
38
- if (consequentVerified) {
39
- const firstConsequent = first(consequents),
40
- substitutions = Substitutions.fromNothing(),
41
- consequent = firstConsequent, ///
42
- axiom = Axiom.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
43
-
44
- fileContext.addAxiom(axiom);
45
-
46
- axiomVerified = true;
47
- }
48
- }
49
- }
50
-
51
- if (axiomVerified) {
52
- fileContext.debug(`...verified the '${labelsString}' axiom.`, axiomNode);
53
- }
54
-
55
- return axiomVerified;
56
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- import Consequent from "../consequent";
4
- // import verifyStatement from "../verify/statement";
5
-
6
- import { nodeQuery } from "../utilities/query";
7
-
8
- const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
9
- unqualifiedStatementNodeQuery = nodeQuery("/consequent/unqualifiedStatement!");
10
-
11
- export default function verifyConsequent(consequentNode, consequents, localContext) {
12
- let consequentVerified = false;
13
-
14
- const consequentString = localContext.nodeAsString(consequentNode);
15
-
16
- localContext.trace(`Verifying the '${consequentString}' consequent...`, consequentNode);
17
-
18
- const unqualifiedStatementNode = unqualifiedStatementNodeQuery(consequentNode);
19
-
20
- if (unqualifiedStatementNode !== null) {
21
- const stated = true,
22
- assignments = null,
23
- statementNode = statementNodeQuery(unqualifiedStatementNode),
24
- statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
25
-
26
- if (statementVerified) {
27
- const consequent = Consequent.fromStatementNode(statementNode);
28
-
29
- consequents.push(consequent);
30
-
31
- consequentVerified = true;
32
- }
33
- }
34
-
35
- if (consequentVerified) {
36
- localContext.debug(`...verified the '${consequentString}' consequent.`, consequentNode);
37
- }
38
-
39
- return consequentVerified;
40
- }
@@ -1,85 +0,0 @@
1
- "use strict";
2
-
3
- import Variable from "../../variable";
4
- import VariableAssignment from "../../assignment/variable";
5
-
6
- import { nodeQuery } from "../../utilities/query";
7
- import { objectType } from "../../type";
8
- import { EMPTY_STRING } from "../../constants";
9
-
10
- const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
11
- variableNodeQuery = nodeQuery("/variableDeclaration/variable");
12
-
13
- export default function verifyVariableDeclaration(variableDeclarationNode, fileContext) {
14
- let variableDeclarationVerified;
15
-
16
- const typeNode = typeNodeQuery(variableDeclarationNode),
17
- variableNode = variableNodeQuery(variableDeclarationNode),
18
- typeString = (typeNode === null) ?
19
- EMPTY_STRING :
20
- fileContext.nodeAsString(typeNode),
21
- variableString = fileContext.nodeAsString(variableNode);
22
-
23
- (typeString === EMPTY_STRING) ?
24
- fileContext.trace(`Verifying the '${variableString}' variable declaration...`, variableDeclarationNode) :
25
- fileContext.trace(`Verifying the '${variableString}:${typeString}' variable declaration...`, variableDeclarationNode);
26
-
27
- const variableVVerified = verifyVariable(variableNode, typeNode, fileContext);
28
-
29
- variableDeclarationVerified = variableVVerified; ///
30
-
31
- if (variableDeclarationVerified) {
32
- (typeString === EMPTY_STRING) ?
33
- fileContext.debug(`...verified the '${variableString}' variable declaration.`, variableDeclarationNode) :
34
- fileContext.debug(`...verified the '${variableString}:${typeString}' variable declaration.`, variableDeclarationNode);
35
- }
36
-
37
- return variableDeclarationVerified;
38
- }
39
-
40
- function verifyVariable(variableNode, typeNode, fileContext) {
41
- let variableVerified = false;
42
-
43
- const variableString = fileContext.nodeAsString(variableNode);
44
-
45
- fileContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
46
-
47
- const variablePresent = fileContext.isVariablePresentByVariableNode(variableNode);
48
-
49
- if (variablePresent) {
50
- fileContext.debug(`The variable '${variableString}' is already present.`, variableNode);
51
- } else {
52
- let variable;
53
-
54
- if (typeNode === null) {
55
- const type = objectType;
56
-
57
- variable = Variable.fromVariableNodeAndType(variableNode, type);
58
- } else {
59
- const type = fileContext.findTypeByTypeNode(typeNode);
60
-
61
- if (type === null) {
62
- const typeString = fileContext.nodeAsString(typeNode);
63
-
64
- fileContext.debug(`The '${variableString}' variable's '${typeString}' type is not present.`, variableNode);
65
- } else {
66
- variable = Variable.fromVariableNodeAndType(variableNode, type);
67
- }
68
- }
69
-
70
- if (variable !== null) {
71
- const variableAssignment = VariableAssignment.fromVariable(variable),
72
- variableAssigned = variableAssignment.assign(fileContext);
73
-
74
- if (variableAssigned) {
75
- variableVerified = true;
76
- }
77
- }
78
- }
79
-
80
- if (variableVerified) {
81
- fileContext.debug(`...verified the '${variableString}' variable.`, variableNode);
82
- }
83
-
84
- return variableVerified;
85
- }
@@ -1,118 +0,0 @@
1
- "use strict";
2
-
3
- import Equality from "../equality";
4
- import verifyTerms from "../verify/terms";
5
- import EqualityAssignment from "../assignment/equality";
6
-
7
- import { nodesQuery } from "../utilities/query";
8
-
9
- const termNodesQuery = nodesQuery("/equality/term");
10
-
11
- const verifyEqualityFunctions = [
12
- verifyDerivedEquality,
13
- verifyStatedEquality
14
- ];
15
-
16
- export default function verifyEquality(equalityNode, assignments, stated, localContext) {
17
- let equalityVerified;
18
-
19
- const equalityString = localContext.nodeAsString(equalityNode);
20
-
21
- localContext.trace(`Verifying the '${equalityString}' equality...`, equalityNode);
22
-
23
- equalityVerified = verifyEqualityFunctions.some((verifyEqualityFunction) => {
24
- const equalityVerified = verifyEqualityFunction(equalityNode, assignments, stated, localContext);
25
-
26
- if (equalityVerified) {
27
- return true;
28
- }
29
- });
30
-
31
- if (equalityVerified) {
32
- localContext.debug(`...verified the '${equalityString}' equality.`, equalityNode);
33
- }
34
-
35
- return equalityVerified;
36
- }
37
-
38
- function verifyDerivedEquality(equalityNode, assignments, stated, localContext) {
39
- let derivedEqualityVerified = false;
40
-
41
- if (!stated) {
42
- const equalityString = localContext.nodeAsString(equalityNode);
43
-
44
- localContext.trace(`Verifying the '${equalityString}' derived equality...`, equalityNode);
45
-
46
- const terms = [],
47
- termNodes = termNodesQuery(equalityNode),
48
- termsVerified = verifyTerms(termNodes, terms, localContext, () => {
49
- let verifiedAhead = false;
50
-
51
- const equality = Equality.fromTermsAndEqualityNode(terms, equalityNode);
52
-
53
- if (equality !== null) {
54
- const equalityEqual = equality.isEqual(localContext);
55
-
56
- if (equalityEqual) {
57
- if (assignments !== null) {
58
- const equalityAssignment = EqualityAssignment.fromEquality(equality),
59
- assignment = equalityAssignment; ///
60
-
61
- assignments.push(assignment);
62
- }
63
-
64
- verifiedAhead = true;
65
- }
66
- }
67
-
68
- return verifiedAhead;
69
- });
70
-
71
- derivedEqualityVerified = termsVerified; ///
72
-
73
- if (derivedEqualityVerified) {
74
- localContext.debug(`...verified the '${equalityString}' derived equality.`, equalityNode);
75
- }
76
- }
77
-
78
- return derivedEqualityVerified;
79
- }
80
-
81
- function verifyStatedEquality(equalityNode, assignments, stated, localContext) {
82
- let statedEqualityVerified = false;
83
-
84
- if (stated) {
85
- const equalityString = localContext.nodeAsString(equalityNode);
86
-
87
- localContext.trace(`Verifying the '${equalityString}' stated equality...`, equalityNode);
88
-
89
- const terms = [],
90
- termNodes = termNodesQuery(equalityNode),
91
- termsVerified = verifyTerms(termNodes, terms, localContext, () => {
92
- let verifiedAhead = false;
93
-
94
- const equality = Equality.fromTermsAndEqualityNode(terms, equalityNode);
95
-
96
- if (equality !== null) {
97
- if (assignments !== null) {
98
- const equalityAssignment = EqualityAssignment.fromEquality(equality),
99
- assignment = equalityAssignment; ///
100
-
101
- assignments.push(assignment);
102
- }
103
-
104
- verifiedAhead = true;
105
- }
106
-
107
- return verifiedAhead;
108
- });
109
-
110
- statedEqualityVerified = termsVerified; ///
111
-
112
- if (statedEqualityVerified) {
113
- localContext.debug(`...verified the '${equalityString}' stated equality.`, equalityNode);
114
- }
115
- }
116
-
117
- return statedEqualityVerified;
118
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- import shim from "../shim";
4
- import ProofStep from "../proofStep";
5
- import verifySubproof from "../verify/subproof";
6
- import verifyQualifiedStatement from "../verify/statement/qualified";
7
- import verifyUnqualifiedStatement from "../verify/statement/unqualified";
8
-
9
- import { nodeQuery } from "../utilities/query";
10
-
11
- const subproofNodeQuery = nodeQuery("/proofStep|lastProofStep/subproof!"),
12
- statementNodeQuery = nodeQuery("/qualifiedStatement|unqualifiedStatement/statement!"),
13
- qualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/qualifiedStatement!"),
14
- unqualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/unqualifiedStatement!");
15
-
16
- export default function verifyProofStep(proofStepNode, substitutions, localContext) {
17
- }
18
-
19
- Object.assign(shim, {
20
- verifyProofStep
21
- });
@@ -1,123 +0,0 @@
1
- "use strict";
2
-
3
- import shim from "../shim";
4
- import Term from "../term";
5
- import unifyTermWithConstructors from "../unify/termWithConstructors";
6
- import unifyTermWithBracketedConstructor from "../unify/termWithBracketedConstructor";
7
-
8
- import { first } from "../utilities/array";
9
- import { nodeQuery } from "../utilities/query";
10
-
11
- const variableNodeQuery = nodeQuery("/term/variable!");
12
-
13
- const unifyTermFunctions = [
14
- unifyTermWithBracketedConstructor,
15
- unifyTermWithConstructors,
16
- ],
17
- verifyTermFunctions = [
18
- verifyTermAsVariable
19
- ];
20
-
21
- function verifyTerm(termNode, terms, localContext, verifyAhead) {
22
- let termVerified = false;
23
-
24
- const termString = localContext.nodeAsString(termNode);
25
-
26
- localContext.trace(`Verifying the '${termString}' term...`, termNode);
27
-
28
- if (!termVerified) {
29
- const termUnified = unifyTermFunctions.some((unifyTermFunction) => {
30
- const termUnified = unifyTermFunction(termNode, terms, localContext, verifyAhead);
31
-
32
- if (termUnified) {
33
- return true;
34
- }
35
- });
36
-
37
- termVerified = termUnified; ///
38
- }
39
-
40
- if (!termVerified) {
41
- termVerified = verifyTermFunctions.some((verifyTermFunction) => {
42
- const termVerified = verifyTermFunction(termNode, terms, localContext, verifyAhead);
43
-
44
- if (termVerified) {
45
- return true;
46
- }
47
- });
48
- }
49
-
50
- if (termVerified) {
51
- localContext.debug(`...verified the '${termString}' term.`, termNode);
52
- }
53
-
54
- return termVerified;
55
- }
56
-
57
- Object.assign(shim, {
58
- verifyTerm
59
- });
60
-
61
- export default verifyTerm;
62
-
63
- function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
64
- let termVerifiedAsVariable = false;
65
-
66
- const variableNode = variableNodeQuery(termNode);
67
-
68
- if (variableNode !== null) {
69
- const termString = localContext.nodeAsString(termNode);
70
-
71
- localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
72
-
73
- const variables = [],
74
- variableVerified = verifyVariable(variableNode, variables, localContext);
75
-
76
- if (variableVerified) {
77
- let verifiedAhead;
78
-
79
- const firstVariable = first(variables),
80
- variable = firstVariable, ///
81
- type = variable.getType(),
82
- term = Term.fromTermNodeAndType(termNode, type);
83
-
84
- terms.push(term);
85
-
86
- verifiedAhead = verifyAhead();
87
-
88
- terms.pop();
89
-
90
- termVerifiedAsVariable = verifiedAhead; ///
91
- }
92
-
93
- if (termVerifiedAsVariable) {
94
- localContext.debug(`...verified the '${termString}' term as a variable.`, termNode);
95
- }
96
- }
97
-
98
- return termVerifiedAsVariable;
99
- }
100
-
101
- function verifyVariable(variableNode, variables, localContext) {
102
- let variableVerified = false;
103
-
104
- const variableString = localContext.nodeAsString(variableNode);
105
-
106
- localContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
107
-
108
- const variable = localContext.findVariableByVariableNode(variableNode);
109
-
110
- if (variable === null) {
111
- localContext.trace(`The '${variableString}' variable is not present.`, variableNode);
112
- } else {
113
- variables.push(variable);
114
-
115
- variableVerified = true;
116
- }
117
-
118
- if (variableVerified) {
119
- localContext.debug(`...verified the '${variableString}' variable.`, variableNode);
120
- }
121
-
122
- return variableVerified;
123
- }