occam-verify-cli 0.0.262

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 (72) hide show
  1. package/README.md +7 -0
  2. package/bin/abbreviations.js +11 -0
  3. package/bin/antecedent.js +19 -0
  4. package/bin/axiom.js +52 -0
  5. package/bin/combinator.js +27 -0
  6. package/bin/conclusion.js +19 -0
  7. package/bin/consequent.js +19 -0
  8. package/bin/constants.js +9 -0
  9. package/bin/constructor.js +43 -0
  10. package/bin/context/file.js +257 -0
  11. package/bin/context/metaproof.js +90 -0
  12. package/bin/context/package/fileSystem.js +111 -0
  13. package/bin/context/package.js +221 -0
  14. package/bin/context/proof.js +93 -0
  15. package/bin/fileNames.js +17 -0
  16. package/bin/loadPackageContexts.js +53 -0
  17. package/bin/main.js +25 -0
  18. package/bin/metaAntecedent.js +19 -0
  19. package/bin/metaConsequent.js +19 -0
  20. package/bin/metaSubstitution.js +24 -0
  21. package/bin/options.js +9 -0
  22. package/bin/premise.js +19 -0
  23. package/bin/rule.js +64 -0
  24. package/bin/ruleNames.js +19 -0
  25. package/bin/type.js +120 -0
  26. package/bin/utilities/array.js +97 -0
  27. package/bin/utilities/fileSystem.js +97 -0
  28. package/bin/utilities/query.js +92 -0
  29. package/bin/utilities/rule.js +279 -0
  30. package/bin/utilities/string.js +51 -0
  31. package/bin/variable.js +54 -0
  32. package/bin/verify/antecedent.js +35 -0
  33. package/bin/verify/axiom/IndicativeConditional.js +54 -0
  34. package/bin/verify/axiom/unqualifiedStatement.js +40 -0
  35. package/bin/verify/axiom.js +37 -0
  36. package/bin/verify/conclusion.js +32 -0
  37. package/bin/verify/consequent.js +32 -0
  38. package/bin/verify/declaration/combinator.js +17 -0
  39. package/bin/verify/declaration/constructor.js +19 -0
  40. package/bin/verify/declaration/topLevel.js +61 -0
  41. package/bin/verify/declaration/type.js +21 -0
  42. package/bin/verify/declaration/variable.js +19 -0
  43. package/bin/verify/equality.js +52 -0
  44. package/bin/verify/file.js +43 -0
  45. package/bin/verify/files.js +46 -0
  46. package/bin/verify/label.js +27 -0
  47. package/bin/verify/labels.js +17 -0
  48. package/bin/verify/metaAntecedent.js +35 -0
  49. package/bin/verify/metaConsequent.js +32 -0
  50. package/bin/verify/metaDerivation.js +105 -0
  51. package/bin/verify/metaproof.js +46 -0
  52. package/bin/verify/metastatement/qualified.js +43 -0
  53. package/bin/verify/metastatement/unqualified.js +40 -0
  54. package/bin/verify/package.js +81 -0
  55. package/bin/verify/premise.js +35 -0
  56. package/bin/verify/rule/inferenceConditional.js +54 -0
  57. package/bin/verify/rule/unqualifiedMetastatement.js +40 -0
  58. package/bin/verify/rule.js +61 -0
  59. package/bin/verify/statement/qualified.js +17 -0
  60. package/bin/verify/statement/unqualified.js +27 -0
  61. package/bin/verify/statement.js +47 -0
  62. package/bin/verify/statementAsCombinator.js +140 -0
  63. package/bin/verify/term.js +183 -0
  64. package/bin/verify/termAsConstructor.js +173 -0
  65. package/bin/verify/termAsVariable.js +41 -0
  66. package/bin/verify/type.js +53 -0
  67. package/bin/verify/typeAssertion.js +69 -0
  68. package/bin/verify/variable.js +55 -0
  69. package/index.js +9 -0
  70. package/license.txt +48 -0
  71. package/package.json +24 -0
  72. package/verify.js +13 -0
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ const { COMMA, EMPTY_STRING } = require("../constants");
4
+
5
+ function nodeAsString(node, string = EMPTY_STRING) {
6
+ const nodeTerminalNode = node.isTerminalNode();
7
+
8
+ if (nodeTerminalNode) {
9
+ const terminalNode = node,
10
+ content = terminalNode.getContent();
11
+
12
+ string = `${string}${content}`;
13
+ } else {
14
+ const nonTerminalNode = node, ///
15
+ childNodes = nonTerminalNode.getChildNodes();
16
+
17
+ childNodes.forEach((childNode) => {
18
+ string = nodeAsString(childNode, string);
19
+ });
20
+ }
21
+
22
+ return string;
23
+ }
24
+
25
+ function nodesAsString(nodes) {
26
+ const string = nodes.reduce((string, node) => {
27
+ const nodeString = nodeAsString(node);
28
+
29
+ if (string === null) {
30
+ string = nodeString; ///
31
+ } else {
32
+ string = `${string}${COMMA}${nodeString}`;
33
+ }
34
+
35
+ return string;
36
+ }, null);
37
+
38
+ return string;
39
+ }
40
+
41
+ function labelsAsString(labels) {
42
+ const labelsString = labels.join(COMMA);
43
+
44
+ return labelsString;
45
+ }
46
+
47
+ module.exports = {
48
+ nodeAsString,
49
+ nodesAsString,
50
+ labelsAsString
51
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ class Variable {
4
+ constructor(type, name, value) {
5
+ this.type = type;
6
+ this.name = name;
7
+ this.value = value;
8
+ }
9
+
10
+ getType() {
11
+ return this.type;
12
+ }
13
+
14
+ getName() {
15
+ return this.name;
16
+ }
17
+
18
+ getValue() {
19
+ return this.value;
20
+ }
21
+
22
+ setValue(value) {
23
+ this.value = value;
24
+ }
25
+
26
+ matchName(name) {
27
+ const matchesName = (this.name === name);
28
+
29
+ return matchesName;
30
+ }
31
+
32
+ asString() {
33
+ let string;
34
+
35
+ if (this.type === null) {
36
+ string = this.name;
37
+ } else {
38
+ const typeName = this.type.getName();
39
+
40
+ string = `${this.name}:${typeName}`;
41
+ }
42
+
43
+ return string;
44
+ }
45
+
46
+ static fromTypeAndName(type, name) {
47
+ const value = undefined,
48
+ variable = new Variable(type, name, value);
49
+
50
+ return variable;
51
+ }
52
+ }
53
+
54
+ module.exports = Variable;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ const Antecedent = require("../antecedent"),
4
+ verifyUnqualifiedStatement = require("../verify/statement/unqualified");
5
+
6
+ const { nodeQuery, nodesQuery } = require("../utilities/query");
7
+
8
+ const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
9
+ unqualifiedStatementNodesQuery = nodesQuery("/antecedent/unqualifiedStatement");
10
+
11
+ function verifyAntecedent(antecedentNode, antecedents, context) {
12
+ const unqualifiedStatementNodes = unqualifiedStatementNodesQuery(antecedentNode),
13
+ antecedentVerified = unqualifiedStatementNodes.every((unqualifiedStatementNode) => {
14
+ const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, context);
15
+
16
+ if (unqualifiedStatementVerified) {
17
+ return true;
18
+ }
19
+ });
20
+
21
+ if (antecedentVerified) {
22
+ const statementNodes = unqualifiedStatementNodes.map((unqualifiedStatementNode) => {
23
+ const statementNode = statementNodeQuery(unqualifiedStatementNode);
24
+
25
+ return statementNode;
26
+ }),
27
+ antecedent = Antecedent.fromStatementNodes(statementNodes);
28
+
29
+ antecedents.push(antecedent);
30
+ }
31
+
32
+ return antecedentVerified;
33
+ }
34
+
35
+ module.exports = verifyAntecedent;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ const Axiom = require("../../axiom"),
4
+ verifyLabels = require("../../verify/labels"),
5
+ verifyAntecedent = require("../../verify/antecedent"),
6
+ verifyConsequent = require("../../verify/consequent");
7
+
8
+ const { first } = require("../../utilities/array"),
9
+ { nodeQuery, nodesQuery } = require("../../utilities/query");
10
+
11
+ const labelNodesQuery = nodesQuery("/axiom/label"),
12
+ antecedentNodeQuery = nodeQuery("/indicativeConditional/antecedent!"),
13
+ consequentNodeQuery = nodeQuery("/indicativeConditional/consequent!"),
14
+ indicativeConditionalNodeQuery = nodeQuery("/axiom/indicativeConditional!");
15
+
16
+ function verifyIndicativeConditionalAxiom(axiomNode, context) {
17
+ let indicativeConditionalAxiomVerified = false;
18
+
19
+ const indicativeConditionalNode = indicativeConditionalNodeQuery(axiomNode);
20
+
21
+ if (indicativeConditionalNode !== null) {
22
+ const labels = [],
23
+ labelNodes = labelNodesQuery(axiomNode),
24
+ labelsVerified = verifyLabels(labelNodes, labels, context);
25
+
26
+ if (labelsVerified) {
27
+ const antecedents = [],
28
+ antecedentNode = antecedentNodeQuery(indicativeConditionalNode),
29
+ antecedentVerified = verifyAntecedent(antecedentNode, antecedents, context);
30
+
31
+ if (antecedentVerified) {
32
+ const consequents = [],
33
+ consequentNode = consequentNodeQuery(indicativeConditionalNode),
34
+ consequentVerified = verifyConsequent(consequentNode, consequents, context);
35
+
36
+ if (consequentVerified) {
37
+ const firstAntecedent = first(antecedents),
38
+ firstConsequent = first(consequents),
39
+ antecedent = firstAntecedent, ///
40
+ consequent = firstConsequent, ///
41
+ axiom = Axiom.fromAntecedentConsequentAndLabels(antecedent, consequent, labels);
42
+
43
+ context.addAxiom(axiom);
44
+
45
+ indicativeConditionalAxiomVerified = true;
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ return indicativeConditionalAxiomVerified;
52
+ }
53
+
54
+ module.exports = verifyIndicativeConditionalAxiom;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ const Axiom = require("../../axiom"),
4
+ verifyLabels = require("../../verify/labels"),
5
+ verifyUnqualifiedStatement = require("../../verify/statement/unqualified");
6
+
7
+ const { nodeQuery, nodesQuery } = require("../../utilities/query");
8
+
9
+ const labelNodesQuery = nodesQuery("/axiom/label"),
10
+ statementNodeQuery = nodeQuery("/*/statement"),
11
+ unqualifiedStatementNodeQuery = nodeQuery("/axiom/unqualifiedStatement!");
12
+
13
+ function verifyUnqualifiedStatementAxiom(axiomNode, context) {
14
+ let unqualifiedStatementAxiomVerified = false;
15
+
16
+ const unqualifiedStatementNode = unqualifiedStatementNodeQuery(axiomNode);
17
+
18
+ if (unqualifiedStatementNode !== null) {
19
+ const labels = [],
20
+ labelNodes = labelNodesQuery(axiomNode),
21
+ labelsVerified = verifyLabels(labelNodes, labels, context);
22
+
23
+ if (labelsVerified) {
24
+ const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, context);
25
+
26
+ if (unqualifiedStatementVerified) {
27
+ const statementNode = statementNodeQuery(unqualifiedStatementNode),
28
+ axiom = Axiom.fromStatementNodeAndLabels(statementNode, labels);
29
+
30
+ context.addAxiom(axiom);
31
+
32
+ unqualifiedStatementAxiomVerified = true;
33
+ }
34
+ }
35
+ }
36
+
37
+ return unqualifiedStatementAxiomVerified;
38
+ }
39
+
40
+ module.exports = verifyUnqualifiedStatementAxiom;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ const { loggingUtilities } = require("necessary");
4
+
5
+ const ProofContext = require("../context/proof"),
6
+ verifyUnqualifiedStatementAxiom = require("../verify/axiom/unqualifiedStatement"),
7
+ verifyIndicativeConditionalAxiom = require("../verify/axiom/indicativeConditional");
8
+
9
+ const { nodesQuery } = require("../utilities/query"),
10
+ { nodesAsString } = require("../utilities/string");
11
+
12
+ const { log } = loggingUtilities;
13
+
14
+ const labelNodesQuery = nodesQuery("/axiom/label");
15
+
16
+ function verifyAxiom(axiomNode, context) {
17
+ const labelNodes = labelNodesQuery(axiomNode),
18
+ labelsString = nodesAsString(labelNodes);
19
+
20
+ log.debug(`Verifying the '${labelsString}' axiom...`);
21
+
22
+ const proofContext = ProofContext.fromContext(context);
23
+
24
+ context = proofContext; ///
25
+
26
+ const unqualifiedStatementAxiomVerified = verifyUnqualifiedStatementAxiom(axiomNode, context),
27
+ indicativeConditionalAxiomVerified = verifyIndicativeConditionalAxiom(axiomNode, context),
28
+ axiomVerified = (unqualifiedStatementAxiomVerified || indicativeConditionalAxiomVerified);
29
+
30
+ if (axiomVerified) {
31
+ log.info(`Verified the '${labelsString}' axiom.`);
32
+ }
33
+
34
+ return axiomVerified;
35
+ }
36
+
37
+ module.exports = verifyAxiom;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ const Conclusion = require("../conclusion"),
4
+ verifyUnqualifiedMetastatement = require("../verify/metastatement/unqualified");
5
+
6
+ const { nodeQuery } = require("../utilities/query");
7
+
8
+ const metastatementNodeQuery = nodeQuery("/*/metastatement!"),
9
+ unqualifiedMetastatementNodeQuery = nodeQuery("/conclusion/unqualifiedMetastatement!");
10
+
11
+ function verifyConclusion(conclusionNode, conclusions, context) {
12
+ let conclusionVerified = false;
13
+
14
+ const unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(conclusionNode);
15
+
16
+ if (unqualifiedMetastatementNode !== null) {
17
+ const unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, context);
18
+
19
+ if (unqualifiedMetastatementVerified) {
20
+ const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
21
+ conclusion = Conclusion.fromMetastatementNode(metastatementNode);
22
+
23
+ conclusions.push(conclusion);
24
+
25
+ conclusionVerified = true;
26
+ }
27
+ }
28
+
29
+ return conclusionVerified;
30
+ }
31
+
32
+ module.exports = verifyConclusion;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ const Consequent = require("../consequent"),
4
+ verifyUnqualifiedStatement = require("../verify/statement/unqualified");
5
+
6
+ const { nodeQuery } = require("../utilities/query");
7
+
8
+ const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
9
+ unqualifiedStatementNodeQuery = nodeQuery("/consequent/unqualifiedStatement!");
10
+
11
+ function verifyConsequent(consequentNode, consequents, context) {
12
+ let consequentVerified = false;
13
+
14
+ const unqualifiedStatementNode = unqualifiedStatementNodeQuery(consequentNode);
15
+
16
+ if (unqualifiedStatementNode !== null) {
17
+ const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, context);
18
+
19
+ if (unqualifiedStatementVerified) {
20
+ const statementNode = statementNodeQuery(unqualifiedStatementNode),
21
+ consequent = Consequent.fromStatementNode(statementNode);
22
+
23
+ consequents.push(consequent);
24
+
25
+ consequentVerified = true;
26
+ }
27
+ }
28
+
29
+ return consequentVerified;
30
+ }
31
+
32
+ module.exports = verifyConsequent;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ const verifyStatementAsCombinator = require("../../verify/statementAsCombinator");
4
+
5
+ const { nodeQuery } = require("../../utilities/query");
6
+
7
+ const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
8
+
9
+ function verifyCombinatorDeclaration(combinatorDeclarationNode, context) {
10
+ const statementNode = statementNodeQuery(combinatorDeclarationNode),
11
+ statementVerifiedAsCombinator = verifyStatementAsCombinator(statementNode, context),
12
+ combinatorDeclarationVerified = statementVerifiedAsCombinator; ///
13
+
14
+ return combinatorDeclarationVerified;
15
+ }
16
+
17
+ module.exports = verifyCombinatorDeclaration;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ const verifyTermAsConstructor = require("../../verify/termAsConstructor");
4
+
5
+ const { nodeQuery } = require("../../utilities/query");
6
+
7
+ const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
8
+ typeNodeQuery = nodeQuery("/constructorDeclaration/type");
9
+
10
+ function verifyConstructorDeclaration(constructorDeclarationNode, context) {
11
+ const termNode = termNodeQuery(constructorDeclarationNode),
12
+ typeNode = typeNodeQuery(constructorDeclarationNode),
13
+ termVerifiedAsConstructor = verifyTermAsConstructor(termNode, typeNode, context),
14
+ constructorDeclarationVerified = termVerifiedAsConstructor; ///
15
+
16
+ return constructorDeclarationVerified;
17
+ }
18
+
19
+ module.exports = verifyConstructorDeclaration;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ const { nodeQuery } = require("../../utilities/query");
4
+
5
+ const verifyRule = require("../../verify/rule"),
6
+ verifyAxiom = require("../../verify/axiom"),
7
+ verifyTypeDeclaration = require("../../verify/declaration/type"),
8
+ verifyVariableDeclaration = require("../../verify/declaration/variable"),
9
+ verifyCombinatorDeclaration = require("../../verify/declaration/combinator"),
10
+ verifyConstructorDeclaration = require("../../verify/declaration/constructor");
11
+
12
+ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
13
+ axiomNodeQuery = nodeQuery("/topLevelDeclaration/axiom!"),
14
+ typeDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/typeDeclaration!"),
15
+ variableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/variableDeclaration!"),
16
+ combinatorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/combinatorDeclaration!"),
17
+ constructorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/constructorDeclaration!");
18
+
19
+ function verifyTopLevelDeclaration(topLevelDeclarationNode, context) {
20
+ let topLevelDeclarationVerified = false;
21
+
22
+ const node = topLevelDeclarationNode, ///
23
+ ruleNode = ruleNodeQuery(node),
24
+ axiomNode = axiomNodeQuery(node),
25
+ typeDeclarationNode = typeDeclarationNodeQuery(node),
26
+ variableDeclarationNode = variableDeclarationNodeQuery(node),
27
+ combinatorDeclarationNode = combinatorDeclarationNodeQuery(node),
28
+ constructorDeclarationNode = constructorDeclarationNodeQuery(node);
29
+
30
+ if (false) {
31
+ ///
32
+ } else if (ruleNode !== null) {
33
+ const ruleVerified = verifyRule(ruleNode, context);
34
+
35
+ topLevelDeclarationVerified = ruleVerified; ///
36
+ } else if (axiomNode !== null) {
37
+ const axiomVerified = verifyAxiom(axiomNode, context);
38
+
39
+ topLevelDeclarationVerified = axiomVerified; ///
40
+ } else if (typeDeclarationNode !== null) {
41
+ const typeDeclarationVerified = verifyTypeDeclaration(typeDeclarationNode, context);
42
+
43
+ topLevelDeclarationVerified = typeDeclarationVerified; ///
44
+ } else if (variableDeclarationNode !== null) {
45
+ const variableDeclarationVerified = verifyVariableDeclaration(variableDeclarationNode, context);
46
+
47
+ topLevelDeclarationVerified = variableDeclarationVerified; ///
48
+ } else if (combinatorDeclarationNode !== null) {
49
+ const combinatorDeclarationVerified = verifyCombinatorDeclaration(combinatorDeclarationNode, context);
50
+
51
+ topLevelDeclarationVerified = combinatorDeclarationVerified; ///
52
+ } else if (constructorDeclarationNode !== null) {
53
+ const constructorDeclarationVerified = verifyConstructorDeclaration(constructorDeclarationNode, context);
54
+
55
+ topLevelDeclarationVerified = constructorDeclarationVerified; ///
56
+ }
57
+
58
+ return topLevelDeclarationVerified;
59
+ }
60
+
61
+ module.exports = verifyTopLevelDeclaration;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ const verifyType = require("../../verify/type");
4
+
5
+ const { nodeQuery } = require("../../utilities/query");
6
+
7
+ const firstTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
8
+ secondTypeNodeQuery = nodeQuery("/typeDeclaration/type[1]");
9
+
10
+ function verifyTypeDeclaration(typeDeclarationNode, context) {
11
+ const firstTypeNode = firstTypeNodeQuery(typeDeclarationNode),
12
+ secondTypeNode = secondTypeNodeQuery(typeDeclarationNode),
13
+ typeNode = firstTypeNode, ///
14
+ superTypeNode = secondTypeNode, ///
15
+ typeVerified = verifyType(typeNode, superTypeNode, context),
16
+ typeDeclarationVerified = typeVerified; ///
17
+
18
+ return typeDeclarationVerified;
19
+ }
20
+
21
+ module.exports = verifyTypeDeclaration;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ const verifyVariable = require("../../verify/variable");
4
+
5
+ const { nodeQuery } = require("../../utilities/query");
6
+
7
+ const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
8
+ variableNodeQuery = nodeQuery("/variableDeclaration/variable");
9
+
10
+ function verifyVariableDeclaration(variableDeclarationNode, context) {
11
+ const typeNode = typeNodeQuery(variableDeclarationNode),
12
+ variableNode = variableNodeQuery(variableDeclarationNode),
13
+ variableVVerified = verifyVariable(variableNode, typeNode, context),
14
+ variableDeclarationVerified = variableVVerified; ///
15
+
16
+ return variableDeclarationVerified;
17
+ }
18
+
19
+ module.exports = verifyVariableDeclaration;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ const verifyTerm = require("../verify/term");
4
+
5
+ const { nodeQuery } = require("../utilities/query"),
6
+ { first, second } = require("../utilities/array");
7
+
8
+ const firstTermNodeQuery = nodeQuery("/equality/term[0]"),
9
+ secondTermNodeQuery = nodeQuery("/equality/term[1]");
10
+
11
+ function verifyEquality(equalityNode, context) {
12
+ let equalityVerified = false;
13
+
14
+ const types = [],
15
+ values = [],
16
+ firstTermNode = firstTermNodeQuery(equalityNode),
17
+ secondTermNode = secondTermNodeQuery(equalityNode),
18
+ firstTermVerified = verifyTerm(firstTermNode, types, values, context),
19
+ secondTermVerified = verifyTerm(secondTermNode, types, values, context);
20
+
21
+ if (firstTermVerified && secondTermVerified) {
22
+ const firstType = first(types),
23
+ secondType = second(types),
24
+ firstTypeEqualToSubTypeOfOrSuperTypeOfSecondType = firstType.isEqualToSubTypeOfOrSuperTypeOf(secondType);
25
+
26
+ if (firstTypeEqualToSubTypeOfOrSuperTypeOfSecondType) {
27
+ const derived = context.isDerived();
28
+
29
+ if (derived) {
30
+ const termsEqual = equateTerms(firstTermNode, secondTermNode, context);
31
+
32
+ if (termsEqual) {
33
+ equalityVerified = true;
34
+ }
35
+ } else {
36
+ equalityVerified = true;
37
+ }
38
+ }
39
+ }
40
+
41
+ return equalityVerified;
42
+ }
43
+
44
+ module.exports = verifyEquality;
45
+
46
+ function equateTerms(firstTermNode, secondTermNode, context) {
47
+ let termsEqual = true; ///
48
+
49
+ debugger
50
+
51
+ return termsEqual;
52
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ const { loggingUtilities } = require("necessary");
4
+
5
+ const FileContext = require("../context/file"),
6
+ PackageContext = require("../context/package"),
7
+ verifyTopLevelDeclaration = require("../verify/declaration/topLevel");
8
+
9
+ const { nodesQuery } = require("../utilities/query");
10
+
11
+ const { log } = loggingUtilities;
12
+
13
+ const topLevelDeclarationNodesQuery = nodesQuery("/document/topLevelDeclaration");
14
+
15
+ function verifyFile(filePath, packageContext = PackageContext.fromNothing()) {
16
+ let fileVerified = false;
17
+
18
+ log.debug(`Verifying the '${filePath}' file...`);
19
+
20
+ const fileContext = FileContext.fromPackageContextAndFilePath(packageContext, filePath),
21
+ context = fileContext, ///
22
+ node = fileContext.getNode(),
23
+ topLevelDeclarationNodes = topLevelDeclarationNodesQuery(node),
24
+ topLevelDeclarationsVerified = topLevelDeclarationNodes.every((topLevelDeclarationNode) => {
25
+ const topLevelDeclarationVerified = verifyTopLevelDeclaration(topLevelDeclarationNode, context);
26
+
27
+ if (topLevelDeclarationVerified) {
28
+ return true;
29
+ }
30
+ })
31
+
32
+ if (topLevelDeclarationsVerified) {
33
+ packageContext.addFileContext(fileContext);
34
+
35
+ fileVerified = true;
36
+
37
+ log.info(`Verified the '${filePath}' file.`);
38
+ }
39
+
40
+ return fileVerified;
41
+ }
42
+
43
+ module.exports = verifyFile;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ const verifyFile = require("../verify/file");
4
+
5
+ const { leftDifference } = require("../utilities/array");
6
+
7
+ function verifyFiles(packageContext) {
8
+ let filesVerified = false;
9
+
10
+ const filePaths = packageContext.getFilePaths();
11
+
12
+ for (;;) {
13
+ const filePathsLength = filePaths.length;
14
+
15
+ if (filePathsLength === 0) {
16
+ filesVerified = true;
17
+
18
+ break;
19
+ }
20
+
21
+ const verifiedFilePaths = [];
22
+
23
+ filePaths.forEach((filePath) => {
24
+ const fileVerified = verifyFile(filePath, packageContext);
25
+
26
+ if (fileVerified) {
27
+ const verifiedFilePath = filePath; ///
28
+
29
+ verifiedFilePaths.push(verifiedFilePath);
30
+ }
31
+ });
32
+
33
+ const verifiedFilePathsLength = verifiedFilePaths.length,
34
+ fileVerified = (verifiedFilePathsLength > 0);
35
+
36
+ if (!fileVerified) {
37
+ break;
38
+ }
39
+
40
+ leftDifference(filePaths, verifiedFilePaths);
41
+ }
42
+
43
+ return filesVerified;
44
+ }
45
+
46
+ module.exports = verifyFiles;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ const { loggingUtilities } = require("necessary");
4
+
5
+ const { labelNameFromLabelNode } = require("../utilities/query");
6
+
7
+ const { log } = loggingUtilities;
8
+
9
+ function verifyLabel(labelNode, labels, context) {
10
+ let labelVerified = false;
11
+
12
+ const labelName = labelNameFromLabelNode(labelNode),
13
+ label = labelName, ///
14
+ labelPresent = context.isLabelPresent(label);
15
+
16
+ if (labelPresent) {
17
+ log.error(`The label ${label} is already present`);
18
+ } else {
19
+ labels.push(label);
20
+
21
+ labelVerified = true;
22
+ }
23
+
24
+ return labelVerified;
25
+ }
26
+
27
+ module.exports = verifyLabel;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ const verifyLabel = require("../verify/label");
4
+
5
+ function verifyLabels(labelNodes, labels, context) {
6
+ const labelsVerified = labelNodes.every((labelNode) => {
7
+ const labelVerified = verifyLabel(labelNode, labels, context);
8
+
9
+ if (labelVerified) {
10
+ return true;
11
+ }
12
+ });
13
+
14
+ return labelsVerified;
15
+ }
16
+
17
+ module.exports = verifyLabels;