occam-verify-cli 0.0.489 → 0.0.491

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.
@@ -18,8 +18,6 @@ export default function verifyMetaDerivation(metaDerivationNode, metaproofContex
18
18
 
19
19
  metaproofContext.begin(metaDerivationNode);
20
20
 
21
- metaproofContext.setDerived();
22
-
23
21
  const childNodes = childNodesQuery(metaDerivationNode);
24
22
 
25
23
  metaDerivationVerified = childNodes.every((childNode) => { ///
@@ -30,8 +28,6 @@ export default function verifyMetaDerivation(metaDerivationNode, metaproofContex
30
28
  }
31
29
  });
32
30
 
33
- metaproofContext.resetDerived();
34
-
35
31
  metaDerivationVerified ?
36
32
  metaproofContext.complete(metaDerivationNode) :
37
33
  metaproofContext.halt(metaDerivationNode);
@@ -44,8 +40,6 @@ function verifyMetaSubDerivation(metaSubDerivationNode, metaproofContext) {
44
40
 
45
41
  metaproofContext.begin(metaSubDerivationNode);
46
42
 
47
- metaproofContext.setDerived();
48
-
49
43
  const childNodes = childNodesQuery(metaSubDerivationNode);
50
44
 
51
45
  metaDerivationVerified = childNodes.every((childNode) => { ///
@@ -56,8 +50,6 @@ function verifyMetaSubDerivation(metaSubDerivationNode, metaproofContext) {
56
50
  }
57
51
  });
58
52
 
59
- metaproofContext.resetDerived();
60
-
61
53
  metaDerivationVerified ?
62
54
  metaproofContext.complete(metaSubDerivationNode) :
63
55
  metaproofContext.halt(metaSubDerivationNode);
@@ -72,17 +64,17 @@ function verifyMetaSubproof(metaSubproofNode, metaproofContext) {
72
64
 
73
65
  const unqualifiedMetastatementNodes = unqualifiedMetastatementNodesQuery(metaSubproofNode),
74
66
  unqualifiedMetastatementsVerified = unqualifiedMetastatementNodes.every((unqualifiedMetastatementNode) => {
75
- const unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, metaproofContext);
67
+ const unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, metaproofContext);
76
68
 
77
- if (unqualifiedMetastatementVerified) {
78
- return true;
79
- }
80
- });
69
+ if (unqualifiedMetastatementVerified) {
70
+ return true;
71
+ }
72
+ });
81
73
 
82
74
  if (unqualifiedMetastatementsVerified) {
83
75
  unqualifiedMetastatementNodes.forEach((unqualifiedMetastatementNode) => {
84
76
  const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
85
- metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
77
+ metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
86
78
 
87
79
  metaproofContext.addMetaproofStep(metaproofStep);
88
80
  });
@@ -27,12 +27,8 @@ export default function verifyMetaproof(metaproofNode, conclusion, metaproofCont
27
27
  }
28
28
 
29
29
  if (qualifiedMetastatementNode !== null) {
30
- metaproofContext.setDerived();
31
-
32
30
  qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, metaproofContext);
33
31
 
34
- metaproofContext.resetDerived();
35
-
36
32
  if (qualifiedMetastatementVerified) {
37
33
  const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode),
38
34
  metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
@@ -17,15 +17,9 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
17
17
 
18
18
  metaproofContext.debug(`Verifying the ${metastatementString} unqualified metastatement...`);
19
19
 
20
- const derived = metaproofContext.isDerived();
20
+ const metaAssertionMatches = metaproofContext.matchMetastatement(metastatementNode);
21
21
 
22
- if (derived) {
23
- const metaAssertionMatches = metaproofContext.matchMetastatement(metastatementNode);
24
-
25
- unqualifiedMetastatementVerified = metaAssertionMatches; ///
26
- } else {
27
- unqualifiedMetastatementVerified = true;
28
- }
22
+ unqualifiedMetastatementVerified = metaAssertionMatches; ///
29
23
  }
30
24
 
31
25
  unqualifiedMetastatementVerified ?
@@ -6,7 +6,7 @@ import MetaproofStep from "../step/metaproof";
6
6
  import { nodeQuery } from "../utilities/query";
7
7
  import { nodeAsString } from "../utilities/string";
8
8
 
9
- const metastatementNodeQuery = nodeQuery("/premise/unqualifiedStatement!/metastatement!");
9
+ const metastatementNodeQuery = nodeQuery("/premise/unqualifiedMetastatement!/metastatement!");
10
10
 
11
11
  export default function verifyPremise(premiseNode, premises, metaproofContext) {
12
12
  let premiseVerified;
@@ -27,12 +27,8 @@ export default function verifyProof(proofNode, conclusion, proofContext) {
27
27
  }
28
28
 
29
29
  if (qualifiedStatementNode !== null) {
30
- proofContext.setDerived();
31
-
32
30
  qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, proofContext);
33
31
 
34
- proofContext.resetDerived();
35
-
36
32
  if (qualifiedStatementVerified) {
37
33
  const statementNode = statementNodeQuery(qualifiedStatementNode),
38
34
  proofStep = ProofStep.fromStatementNode(statementNode);
@@ -23,7 +23,8 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, proofCo
23
23
  const referenceNode = referenceNodeQuery(qualifiedStatementNode);
24
24
 
25
25
  if (referenceNode === null) {
26
- const statementVerified = verifyStatement(statementNode, proofContext);
26
+ const qualified = true,
27
+ statementVerified = verifyStatement(statementNode, qualified, proofContext);
27
28
 
28
29
  qualifiedStatementVerified = statementVerified; ///
29
30
  } else {
@@ -17,15 +17,9 @@ export default function verifyUnqualifiedStatement(unqualifiedStatementNode, pro
17
17
 
18
18
  proofContext.debug(`Verifying the ${statementString} unqualified statement...`);
19
19
 
20
- const derived = proofContext.isDerived();
20
+ const assertionMatches = proofContext.matchStatement(statementNode);
21
21
 
22
- if (derived) {
23
- const assertionMatches = proofContext.matchStatement(statementNode);
24
-
25
- unqualifiedStatementVerified = assertionMatches; ///
26
- } else {
27
- unqualifiedStatementVerified = true;
28
- }
22
+ unqualifiedStatementVerified = assertionMatches; ///
29
23
  }
30
24
 
31
25
  unqualifiedStatementVerified ?
@@ -3,19 +3,19 @@
3
3
  import verifyStatementAsEquality from "../verify/statementAsEquality";
4
4
  import verifyStatementTypeAssertion from "../verify/statementTypeAssertion";
5
5
 
6
- export default function verifyStatement(statementNode, proofContext) {
6
+ export default function verifyStatement(statementNode, qualified, proofContext) {
7
7
  let statementVerified = false;
8
8
 
9
9
  proofContext.begin(statementNode);
10
10
 
11
11
  if (!statementVerified) {
12
- const equalityVerifiedAsEquality = verifyStatementAsEquality(statementNode, proofContext);
12
+ const equalityVerifiedAsEquality = verifyStatementAsEquality(statementNode, qualified, proofContext);
13
13
 
14
14
  statementVerified = equalityVerifiedAsEquality; ///
15
15
  }
16
16
 
17
17
  if (!statementVerified) {
18
- const statementTypeAssertionVerified = verifyStatementTypeAssertion(statementNode, proofContext);
18
+ const statementTypeAssertionVerified = verifyStatementTypeAssertion(statementNode, qualified, proofContext);
19
19
 
20
20
  statementVerified = statementTypeAssertionVerified; ///
21
21
  }
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  import Equality from "../equality";
4
- import Variable from "../variable";
5
4
  import verifyTerm from "../verify/term";
6
5
 
7
6
  import { nodeQuery } from "../utilities/query";
8
7
  import { nodeAsString } from "../utilities/string";
9
8
  import { first, second } from "../utilities/array";
10
- import { verifyTermAsVariable } from "../verify/term";
11
9
  import { EQUALS_CHARACTER, MAXIMUM_INDEXES_LENGTH } from "../constants";
12
10
 
13
11
  const specialNodeQuery = nodeQuery("/statement/@special!"),
14
12
  leftTermNodeQuery = nodeQuery("/statement/term[0]"),
15
13
  rightTermNodeQuery = nodeQuery("/statement/term[1]");
16
14
 
17
- export default function verifyStatementAsEquality(statementNode, proofContext) {
15
+ export default function verifyStatementAsEquality(statementNode, qualified, proofContext) {
18
16
  let statementVerifiedAsEquality = false;
19
17
 
20
18
  proofContext.begin(statementNode);
@@ -48,38 +46,16 @@ export default function verifyStatementAsEquality(statementNode, proofContext) {
48
46
  if ((leftType === null) && (rightType === null)) {
49
47
  proofContext.error(`The types of the '${leftTermString}' and '${rightTermString}' terms are both undefined and therefore the terms cannot be equated.`);
50
48
  } else if (rightType === null) {
51
- const type = leftType, ///
52
- termNode = rightTermNode, ///
53
- variable = addVariable(type, termNode, proofContext);
54
-
55
- if (variable !== null) {
56
- const leftTypeName = leftType.getName();
57
-
58
- proofContext.info(`The '${rightTermString}' variable has been given the '${leftTypeName}' type.`);
59
-
60
- statementVerifiedAsEquality = true;
61
- }
49
+ proofContext.info(`The type of the right '${rightTermString}' term is undefined and therefore the types cannot be equated.`);
62
50
  } else if (leftType === null) {
63
- const type = rightType, ///
64
- termNode = leftType, ///
65
- variable = addVariable(type, termNode, proofContext);
66
-
67
- if (variable !== null) {
68
- const rightTypeName = rightType.getName();
69
-
70
- proofContext.info(`The '${rightTermString}' variable has been given the '${rightTypeName}' type.`);
71
-
72
- statementVerifiedAsEquality = true;
73
- }
51
+ proofContext.info(`The type of the left '${leftTermString}' term is undefined and therefore the types cannot be equated.`);
74
52
  } else {
75
53
  const leftTypeMatchesRightType = leftType.match(rightType);
76
54
 
77
55
  if (!leftTypeMatchesRightType) {
78
56
  proofContext.error(`The types of the '${leftTermString}' and '${rightTermString}' terms do not match and therefore the terms cannot be equated.`);
79
57
  } else {
80
- const derived = proofContext.isDerived();
81
-
82
- if (!derived) {
58
+ if (!qualified) {
83
59
  statementVerifiedAsEquality = true;
84
60
  } else {
85
61
  const equality = Equality.fromLeftTermNodeAndRightTermNode(leftTermNode, rightTermNode),
@@ -123,24 +99,3 @@ function equalitiesFromProofSteps(proofSteps) {
123
99
 
124
100
  return equalities;
125
101
  }
126
-
127
- function addVariable(type, termNode, proofContext) {
128
- let variable = null;
129
-
130
- const variables = [],
131
- termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, proofContext);
132
-
133
- if (termVerifiedAsVariable) {
134
- const firstVariable = first(variables);
135
-
136
- variable = firstVariable; ///
137
-
138
- const name = variable.getName();
139
-
140
- variable = Variable.fromTypeAndName(type, name); ///
141
-
142
- proofContext.addVariable(variable);
143
- }
144
-
145
- return variable;
146
- }
@@ -11,7 +11,7 @@ const termNodeQuery = nodeQuery("/typeAssertion/term"),
11
11
  typeNodeQuery = nodeQuery("/typeAssertion/type"),
12
12
  typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
13
13
 
14
- export default function verifyStatementTypeAssertion(statementNode, proofContext) {
14
+ export default function verifyStatementTypeAssertion(statementNode, qualified, proofContext) {
15
15
  let statementTypeAssertionVerified = false;
16
16
 
17
17
  proofContext.begin(statementNode);
@@ -30,17 +30,14 @@ export default function verifyStatementTypeAssertion(statementNode, proofContext
30
30
  if (!typePresent) {
31
31
  proofContext.error(`The ${typeName} type is not present.`);
32
32
  } else {
33
- const context = proofContext, ///
34
- termNode = termNodeQuery(typeAssertionNode),
35
- variables = [],
36
- termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
37
-
38
- if (termVerifiedAsVariable) {
39
- const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, proofContext);
33
+ if (!statementTypeAssertionVerified) {
34
+ const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, qualified, proofContext);
40
35
 
41
36
  statementTypeAssertionVerified = variableTypeAssertionVerified; ///
42
- } else {
43
- const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, proofContext);
37
+ }
38
+
39
+ if (!statementTypeAssertionVerified) {
40
+ const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, qualified, proofContext);
44
41
 
45
42
  statementTypeAssertionVerified = termTypeAssertionVerified; ///
46
43
  }
@@ -58,7 +55,47 @@ export default function verifyStatementTypeAssertion(statementNode, proofContext
58
55
  return statementTypeAssertionVerified;
59
56
  }
60
57
 
61
- function verifyTermTypeAssertion(typeAssertionNode, proofContext) {
58
+ function verifyVariableTypeAssertion(typeAssertionNode, qualified, proofContext) {
59
+ let variableTypeAssertionVerified = false;
60
+
61
+ const context = proofContext, ///
62
+ variables = [],
63
+ termNode = termNodeQuery(typeAssertionNode),
64
+ termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
65
+
66
+ if (termVerifiedAsVariable) {
67
+ const typeNode = typeNodeQuery(typeAssertionNode),
68
+ typeName = typeNameFromTypeNode(typeNode),
69
+ assertedTypeName = typeName, ///
70
+ assertedType = proofContext.findTypeByTypeName(assertedTypeName),
71
+ firstVariable = first(variables),
72
+ variable = firstVariable, ///
73
+ variableName = variable.getName(),
74
+ variableType = variable.getType();
75
+
76
+ const assertedTypeEqualToOrSubTypeOfVariableType = (variableType === null) ?
77
+ true : ///
78
+ assertedType.isEqualToOrSubTypeOf(variableType);
79
+
80
+ if (!assertedTypeEqualToOrSubTypeOfVariableType) {
81
+ proofContext.error(`The asserted type is not equal to or a sub-type of the '${variableName}' variable type.`);
82
+ } else {
83
+ if (!qualified) {
84
+ const type = assertedType, ///
85
+ name = variableName, ///
86
+ variable = Variable.fromTypeAndName(type, name);
87
+
88
+ proofContext.addVariable(variable);
89
+ }
90
+
91
+ variableTypeAssertionVerified = true;
92
+ }
93
+ }
94
+
95
+ return variableTypeAssertionVerified;
96
+ }
97
+
98
+ function verifyTermTypeAssertion(typeAssertionNode, qualified, proofContext) {
62
99
  let termTypeAssertionVerified = false;
63
100
 
64
101
  const types = [],
@@ -73,13 +110,18 @@ function verifyTermTypeAssertion(typeAssertionNode, proofContext) {
73
110
  assertedType = proofContext.findTypeByTypeName(assertedTypeName),
74
111
  firstType = first(types),
75
112
  termType = firstType,
76
- assertedTypeEqualToOrSubTypeOfTermType = assertedType.isEqualToOrSubTypeOf(termType);
113
+ termString = nodeAsString(termNode),
114
+ assertedTypeEqualToOrSubTypeOfTermType = (termType === null) ?
115
+ true : ///
116
+ assertedType.isEqualToOrSubTypeOf(termType);
77
117
 
78
118
  if (!assertedTypeEqualToOrSubTypeOfTermType) {
79
- const termString = nodeAsString(termNode);
80
-
81
119
  proofContext.error(`The asserted type is not equal to or a sub-type of the '${termString}' term type.`);
82
120
  } else {
121
+ if (!qualified) {
122
+ debugger
123
+ }
124
+
83
125
  termTypeAssertionVerified = true;
84
126
  }
85
127
  }
@@ -87,43 +129,3 @@ function verifyTermTypeAssertion(typeAssertionNode, proofContext) {
87
129
  return termTypeAssertionVerified;
88
130
  }
89
131
 
90
- function verifyVariableTypeAssertion(typeAssertionNode, proofContext) {
91
- let variableTypeAssertionVerified = false;
92
-
93
- const context = proofContext, ///
94
- variables = [],
95
- termNode = termNodeQuery(typeAssertionNode);
96
-
97
- verifyTermAsVariable(termNode, variables, context);
98
-
99
- const typeNode = typeNodeQuery(typeAssertionNode),
100
- typeName = typeNameFromTypeNode(typeNode),
101
- assertedTypeName = typeName, ///
102
- assertedType = proofContext.findTypeByTypeName(assertedTypeName),
103
- firstVariable = first(variables),
104
- variable = firstVariable, ///
105
- variableName = variable.getName(),
106
- variableType = variable.getType();
107
-
108
- const assertedTypeEqualToOrSubTypeOfVariableType = (variableType === null) ?
109
- true : ///
110
- assertedType.isEqualToOrSubTypeOf(variableType);
111
-
112
- if (!assertedTypeEqualToOrSubTypeOfVariableType) {
113
- proofContext.error(`The asserted type is not equal to or a sub-type of the '${variableName}' variable type.`);
114
- } else {
115
- const derived = proofContext.isDerived();
116
-
117
- if (!derived) {
118
- const type = assertedType, ///
119
- name = variableName, ///
120
- variable = Variable.fromTypeAndName(type, name);
121
-
122
- proofContext.addVariable(variable);
123
- }
124
-
125
- variableTypeAssertionVerified = true;
126
- }
127
-
128
- return variableTypeAssertionVerified;
129
- }