occam-verify-cli 1.0.814 → 1.0.817

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.
@@ -11,22 +11,14 @@ import { verifyFile } from "../../process/verify";
11
11
  import { baseTypeFromNothing } from "../../utilities/type";
12
12
  import { findMetaTypeByMetaTypeName } from "../../metaTypes";
13
13
  import { typesFromJSON,
14
- rulesFromJSON,
15
- axiomsFromJSON,
14
+ lemmasFromJSON,
16
15
  typesToTypesJSON,
17
- rulesToRulesJSON,
18
- theoremsFromJSON,
19
- lemmasFromNothing,
20
- axiomsToAxiomsJSON,
21
- conjecturesFromJSON,
16
+ metaLemmasFromJSON,
22
17
  combinatorsFromJSON,
23
18
  typePrefixesFromJSON,
24
19
  constructorsFromJSON,
25
20
  metatheoremsFromJSON,
26
- metaLemmasFromNothing,
27
- theoremsToTheoremsJSON,
28
21
  declaredVariablesFromJSON,
29
- conjecturesToConjecturesJSON,
30
22
  combinatorsToCombinatorsJSON,
31
23
  declaredMetavariablesFromJSON,
32
24
  typePrefixesToTypePrefixesJSON,
@@ -811,40 +803,33 @@ export default class NominalFileContext extends FileContext {
811
803
 
812
804
  typesFromJSON(json, this.types, fileContext);
813
805
 
814
- this.lemmas = lemmasFromNothing();
815
- this.metaLemmas = metaLemmasFromNothing();
806
+ this.lemmas = lemmasFromJSON(json, fileContext);
807
+ this.metaLemmas = metaLemmasFromJSON(json, fileContext);
816
808
 
817
809
  this.declaredMetavariables = declaredMetavariablesFromJSON(json, fileContext);
818
810
  this.declaredVariables = declaredVariablesFromJSON(json, fileContext);
819
-
820
- this.rules = rulesFromJSON(json, fileContext);
821
- this.axioms = axiomsFromJSON(json, fileContext);
822
- this.theorems = theoremsFromJSON(json, fileContext);
823
- this.conjectures = conjecturesFromJSON(json, fileContext);
824
- this.combinators = combinatorsFromJSON(json, fileContext);
825
811
  this.typePrefixes = typePrefixesFromJSON(json, fileContext);
812
+ this.combinators = combinatorsFromJSON(json, fileContext);
826
813
  this.constructors = constructorsFromJSON(json, fileContext);
827
814
  this.metatheorems = metatheoremsFromJSON(json, fileContext);
815
+
816
+ // this.rules = rulesFromJSON(json, fileContext);
817
+ // this.axioms = axiomsFromJSON(json, fileContext);
818
+ // this.theorems = theoremsFromJSON(json, fileContext);
819
+ // this.conjectures = conjecturesFromJSON(json, fileContext);
828
820
  }
829
821
 
830
822
  toJSON() {
831
823
  const typesJSON = typesToTypesJSON(this.types),
832
- rulesJSON = rulesToRulesJSON(this.rules),
833
- axiomsJSON = axiomsToAxiomsJSON(this.axioms),
834
- theoremsJSON = theoremsToTheoremsJSON(this.theorems),
835
- conjecturesJSON = conjecturesToConjecturesJSON(this.conjectures),
836
824
  combinatorsJSON = combinatorsToCombinatorsJSON(this.combinators),
837
825
  typePrefixesJSON = typePrefixesToTypePrefixesJSON(this.typePrefixes),
838
826
  constructorsJSON = constructorsToConstructorsJSON(this.constructors),
839
827
  metatheoremsJSON = metatheoremsToMetatheoremsJSON(this.metatheorems),
840
828
  declaredVariablesJSON = declaredVariablesToDeclaredVariablesJSON(this.declaredVariables),
841
829
  declaredMetavariablesJSON = declaredMetavariablesToDeclaredMetavariablesJSON(this.declaredMetavariables),
830
+ fileContent = this.fileContent,
842
831
  filePath = this.filePath,
843
832
  types = typesJSON, ///
844
- rules = rulesJSON, ///
845
- axioms = axiomsJSON, ///
846
- theorems = theoremsJSON, ///
847
- conjectures = conjecturesJSON, ///
848
833
  combinators = combinatorsJSON, ///
849
834
  typePrefixes = typePrefixesJSON, ///
850
835
  constructors = constructorsJSON, ///
@@ -852,12 +837,9 @@ export default class NominalFileContext extends FileContext {
852
837
  declaredVariables = declaredVariablesJSON, ///
853
838
  declaredMetavariables = declaredMetavariablesJSON, ///
854
839
  json = {
840
+ fileContent,
855
841
  filePath,
856
842
  types,
857
- rules,
858
- axioms,
859
- theorems,
860
- conjectures,
861
843
  combinators,
862
844
  typePrefixes,
863
845
  constructors,
@@ -198,9 +198,9 @@ export default class LiminalContext extends Context {
198
198
 
199
199
  findSubstitutionByVariableNode(variableNode) {
200
200
  const substitution = this.findSubstitution((substitution) => {
201
- const substitutionComparesToVariableNode = substitution.compareVariableNode(variableNode);
201
+ const variableNodeMatches = substitution.matchVariableNode(variableNode);
202
202
 
203
- if (substitutionComparesToVariableNode) {
203
+ if (variableNodeMatches) {
204
204
  return true;
205
205
  }
206
206
  }) || null;
package/src/context.js CHANGED
@@ -463,7 +463,7 @@ export default class Context extends ContextBase {
463
463
 
464
464
  isJudgementPresentByMetavariableNode(metavariableNode) {
465
465
  const context = this.getContext(),
466
- judgementPresent = context.isJudgementPresentByMetavariableNode(metavariableNode);
466
+ judgementPresent = context.isJudgementPresentByMetavariableNode(metavariableNode);
467
467
 
468
468
  return judgementPresent;
469
469
  }
@@ -5,6 +5,7 @@ import Assertion from "../assertion";
5
5
  import { define } from "../../elements";
6
6
  import { instantiate } from "../../utilities/context";
7
7
  import { instantiateDefinedAssertion } from "../../process/instantiate";
8
+ import { separateGroundedTermsAndDefinedVariables } from "../../utilities/equivalences";
8
9
  import { termFromTermAndSubstitutions, frameFromFrameAndSubstitutions } from "../../utilities/substitutions";
9
10
  import { termFromJDefinedAssertionNode, frameFromJDefinedAssertionNode, negatedFromJDefinedAssertionNode, definedAssertionFromStatementNode } from "../../utilities/element";
10
11
 
@@ -101,10 +102,10 @@ export default define(class DefinedAssertion extends Assertion {
101
102
  context.debug(`The '${termString}' term is not singular.`);
102
103
  } else {
103
104
  const term = this.term.validate(context, (term) => {
104
- const validatesForwards = true;
105
+ const validatesForwards = true;
105
106
 
106
- return validatesForwards;
107
- });
107
+ return validatesForwards;
108
+ });
108
109
 
109
110
  if (term !== null) {
110
111
  this.term = term; ///
@@ -257,7 +258,7 @@ function validateWhenDerived(term, frame, negated, generalContext, specificConte
257
258
  validatesWhenDerived = true;
258
259
  }
259
260
 
260
- if (negated && !variableDefined) {
261
+ if (negated && !declaredDariableDefined) {
261
262
  validatesWhenDerived = true;
262
263
  }
263
264
  }
@@ -265,13 +266,13 @@ function validateWhenDerived(term, frame, negated, generalContext, specificConte
265
266
  if (frame!== null) {
266
267
  const metavariableName = frame.getMetavariableName(),
267
268
  declaredMetavariable = context.findDeclaredMetavariableByMetavariableName(metavariableName),
268
- metavariableDefined = isMetavariableDefined(declaredMetavariable, context);
269
+ declaredMetavariableDefined = isMetavariableDefined(declaredMetavariable, context);
269
270
 
270
- if (!negated && metavariableDefined) {
271
+ if (!negated && declaredMetavariableDefined) {
271
272
  validatesWhenDerived = true;
272
273
  }
273
274
 
274
- if (negated && !metavariableDefined) {
275
+ if (negated && !declaredMetavariableDefined) {
275
276
  validatesWhenDerived = true;
276
277
  }
277
278
  }
@@ -284,7 +285,7 @@ function isVariableDefined(variable, context) {
284
285
  groundedTerms = [],
285
286
  definedVariables = [];
286
287
 
287
- equivalences.separateGroundedTermsAndDefinedVariables(groundedTerms, definedVariables, context);
288
+ separateGroundedTermsAndDefinedVariables(equivalences, groundedTerms, definedVariables, context);
288
289
 
289
290
  const variableMatchesDefinedVariable = definedVariables.some((definedVariable) => {
290
291
  const definedVariableComparesToVariable = definedVariable.compareVariable(variable);
@@ -6,6 +6,7 @@ import { Element, asynchronousUtilities } from "occam-languages";
6
6
  import { define } from "../elements";
7
7
  import { enclose } from "../utilities/context";
8
8
  import { labelsFromJSON, premisesFromJSON, conclusionFromJSON, labelsToLabelsJSON, premisesToPremisesJSON, conclusionToConclusionJSON } from "../utilities/json";
9
+ import {rulsStringFromLabelsPremisesAndConclusion} from "../utilities/string";
9
10
 
10
11
  const { reverse } = arrayUtilities,
11
12
  { asyncExtract, asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
@@ -343,6 +344,7 @@ export default define(class Rule extends Element {
343
344
  labels = labelsFromJSON(json, context),
344
345
  premises = premisesFromJSON(json, context),
345
346
  conclusion = conclusionFromJSON(json, context),
347
+ ruleString = rulsStringFromLabelsPremisesAndConclusion(labels, premises, conclusion),
346
348
  rule = new Rule(context, string, node, proof, labels, premises, conclusion);
347
349
 
348
350
  return rule;
@@ -169,9 +169,9 @@ export default define(class Signature extends Element {
169
169
  const array = substitutions.getArray(),
170
170
  compares = compare(this.terms, array, (term, substitution) => {
171
171
  const substitutionTerm = substitution.getTerm(),
172
- substitutionTermEqualToTerm = substitutionTerm.isEqualTo(term);
172
+ substitutionTermComparesToTerm = substitutionTerm.compareTerm(term);
173
173
 
174
- if (substitutionTermEqualToTerm) {
174
+ if (substitutionTermComparesToTerm) {
175
175
  return true;
176
176
  }
177
177
  });
@@ -198,9 +198,9 @@ export default define(class Signature extends Element {
198
198
  const array = substitutions.getArray(),
199
199
  correlates = correlate(this.terms, array, (term, substitution) => {
200
200
  const substitutionTerm = substitution.getTerm(),
201
- substitutionTermEqualToTerm = substitutionTerm.isEqualTo(term);
201
+ substitutionTermComparesToTerm = substitutionTerm.compareTerm(term);
202
202
 
203
- if (substitutionTermEqualToTerm) {
203
+ if (substitutionTermComparesToTerm) {
204
204
  return true;
205
205
  }
206
206
  });
@@ -49,8 +49,8 @@ export default define(class TermSubstitution extends Substitution {
49
49
  getVariableNode() { return this.targetTerm.getVariableNode(); }
50
50
 
51
51
  isTrivial() {
52
- const targetTermEqualToReplacementTerm = this.targetTerm.isEqualTo(this.replacementTerm),
53
- trivial = targetTermEqualToReplacementTerm; ///
52
+ const targetTermComparesToReplacementTerm = this.targetTerm.compareTerm(this.replacementTerm),
53
+ trivial = targetTermComparesToReplacementTerm; ///
54
54
 
55
55
  return trivial;
56
56
  }
@@ -60,8 +60,8 @@ export default define(class TermSubstitution extends Substitution {
60
60
  compareTerm(term, context) {
61
61
  term = stripBracketsFromTerm(term, context); ///
62
62
 
63
- const termEqualToReplacementTerm = this.replacementTerm.isEqualTo(term),
64
- comparedToTerm = termEqualToReplacementTerm; ///
63
+ const replacementTermComparesToTerm = this.replacementTerm.compareTerm(term),
64
+ comparedToTerm = replacementTermComparesToTerm; ///
65
65
 
66
66
  return comparedToTerm;
67
67
  }
@@ -100,6 +100,18 @@ export default class Substitution extends Element {
100
100
  return simple;
101
101
  }
102
102
 
103
+ matchVariableNode(variableNode) {
104
+ const variableNodeMatches = false;
105
+
106
+ return variableNodeMatches;
107
+ }
108
+
109
+ matchMetavariableNode(metavariableNode) {
110
+ const metavariableNodeMatches = false;
111
+
112
+ return metavariableNodeMatches;
113
+ }
114
+
103
115
  matchSubstitutionNode(substitutionNode) {
104
116
  const node = substitutionNode, ///
105
117
  nodeMatches = this.matchNode(node),
@@ -108,6 +120,7 @@ export default class Substitution extends Element {
108
120
  return substitutionNodeMatches;
109
121
  }
110
122
 
123
+
111
124
  findValidSubstitution(context) {
112
125
  const substitutionNode = this.getSubstitutionNode(),
113
126
  substitution = context.findSubstitutionBySubstitutionNode(substitutionNode),
@@ -34,6 +34,13 @@ export default define(class Term extends Element {
34
34
  return termNode;
35
35
  }
36
36
 
37
+ getVariableNode() {
38
+ const termNode = this.getTermNode(),
39
+ variableNode = termNode.getVariableNode();
40
+
41
+ return variableNode;
42
+ }
43
+
37
44
  getVariableIdentifier() {
38
45
  const termNode = this.getTermNode(),
39
46
  variableIdentifier = termNode.getVariableIdentifier();
@@ -93,6 +100,27 @@ export default define(class Term extends Element {
93
100
  return termNodeMatches;
94
101
  }
95
102
 
103
+ matchVariableNode(variableNode) {
104
+ let varialbeNodeMatches = false;
105
+
106
+ const singular = this.isSingular();
107
+
108
+ if (singular) {
109
+ const variableNodeA = variableNode; ///
110
+
111
+ variableNode = this.getVariableNode();
112
+
113
+ const variableNodeB = variableNode, ///
114
+ variableNodeAMatchesVariableNodeB = variableNodeA.match(variableNodeB);
115
+
116
+ if (variableNodeAMatchesVariableNodeB) {
117
+ varialbeNodeMatches = true; ///
118
+ }
119
+ }
120
+
121
+ return varialbeNodeMatches;
122
+ }
123
+
96
124
  compareTerm(term) {
97
125
  const termNode = term.getNode(),
98
126
  termNodeMatches = this.matchNode(termNode),
@@ -137,7 +137,7 @@ export default define(class Variable extends Element {
137
137
 
138
138
  context = generalContext; ///
139
139
 
140
- const variableNode = variable.getIdentifier();
140
+ const variableNode = variable.getNode();
141
141
 
142
142
  variable = context.findVariableByVariableNode(variableNode);
143
143
 
package/src/node/term.js CHANGED
@@ -5,6 +5,20 @@ import { NonTerminalNode } from "occam-languages";
5
5
  import { ARGUMENT_RULE_NAME, VARIABLE_RULE_NAME } from "../ruleNames";
6
6
 
7
7
  export default class TermNode extends NonTerminalNode {
8
+ getVariableIdentifier() {
9
+ let variableIdentifier = null;
10
+
11
+ const singular = this.isSingular();
12
+
13
+ if (singular) {
14
+ const variableNode = this.getVariableNode();
15
+
16
+ variableIdentifier = variableNode.getVariableIdentifier();
17
+ }
18
+
19
+ return variableIdentifier;
20
+ }
21
+
8
22
  isSingular() {
9
23
  let singular = false;
10
24
 
@@ -66,7 +66,7 @@ export function separateGroundedTermsAndDefinedVariables(equivalences, groundedT
66
66
 
67
67
  separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences, context);
68
68
 
69
- const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.getLength();
69
+ const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.length;
70
70
 
71
71
  if (initiallyGroundedEquivalencesLength > 0) {
72
72
  groundedEquivalences = initiallyGroundedEquivalences; ///
@@ -97,7 +97,7 @@ export function separateGroundedTermsAndDefinedVariables(equivalences, groundedT
97
97
 
98
98
  push(groundedEquivalences, implicitlyGroundedEquivalences);
99
99
 
100
- implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.getLength(); ///
100
+ implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.length; ///
101
101
  }
102
102
  }
103
103
  }
@@ -2,19 +2,6 @@
2
2
 
3
3
  import elements from "../elements";
4
4
  import EphemeralContext from "../context/ephemeral";
5
- import Substitution from "../element/substitution";
6
-
7
- export function lemmasFromNothing() {
8
- const lemmas = [];
9
-
10
- return lemmas;
11
- }
12
-
13
- export function metaLemmasFromNothing() {
14
- const metaLemmas = [];
15
-
16
- return metaLemmas;
17
- }
18
5
 
19
6
  export function nameFromJSON(json, context) {
20
7
  let { name } = json;
@@ -86,6 +73,12 @@ export function frameFromJSON(json, context) {
86
73
  return frame;
87
74
  }
88
75
 
76
+ export function lemmasFromJSON(json, context) {
77
+ const lemmas = [];
78
+
79
+ return lemmas;
80
+ }
81
+
89
82
  export function negatedFromJSON(json, context) {
90
83
  const { negated } = json;
91
84
 
@@ -186,6 +179,12 @@ export function conclusionFromJSON(json, context) {
186
179
  return conclusion;
187
180
  }
188
181
 
182
+ export function metaLemmasFromJSON(json, context) {
183
+ const metaLemmas = [];
184
+
185
+ return metaLemmas;
186
+ }
187
+
189
188
  export function provisionalFromJSON(json, context) {
190
189
  const { provisional } = json;
191
190
 
@@ -268,22 +267,6 @@ export function termsFromJSON(json, context) {
268
267
  return terms;
269
268
  }
270
269
 
271
- export function rulesFromJSON(json, context) {
272
- let { rules } = json;
273
-
274
- const { Rule } = elements,
275
- rulesJSON = rules; ///
276
-
277
- rules = rulesJSON.map((ruleJSON) => {
278
- const json = ruleJSON, ///
279
- rule = Rule.fromJSON(json, context);
280
-
281
- return rule;
282
- });
283
-
284
- return rules;
285
- }
286
-
287
270
  export function framesFromJSON(json, context) {
288
271
  let { frames } = json;
289
272
 
@@ -316,22 +299,6 @@ export function labelsFromJSON(json, context) {
316
299
  return labels;
317
300
  }
318
301
 
319
- export function axiomsFromJSON(json, context) {
320
- let { axioms } = json;
321
-
322
- const { Axiom } = elements,
323
- axiomsJSON = axioms; ///
324
-
325
- axioms = axiomsJSON.map((axiomJSON) => {
326
- const json = axiomJSON, ///
327
- axiom = Axiom.fromJSON(json, context);
328
-
329
- return axiom;
330
- });
331
-
332
- return axioms;
333
- }
334
-
335
302
  export function premisesFromJSON(json, context) {
336
303
  let { premises } = json;
337
304
 
@@ -348,22 +315,6 @@ export function premisesFromJSON(json, context) {
348
315
  return premises;
349
316
  }
350
317
 
351
- export function theoremsFromJSON(json, context) {
352
- let { theorems } = json;
353
-
354
- const { Theorem } = elements,
355
- theoremsJSON = theorems; ///
356
-
357
- theorems = theoremsJSON.map((theoremJSON) => {
358
- const json = theoremJSON, ///
359
- theorem = Theorem.fromJSON(json, context);
360
-
361
- return theorem;
362
- });
363
-
364
- return theorems;
365
- }
366
-
367
318
  export function variablesFromJSON(json, context) {
368
319
  let { variables } = json;
369
320
 
@@ -529,22 +480,6 @@ export function referencesFromJSON(json, context) {
529
480
  return references;
530
481
  }
531
482
 
532
- export function conjecturesFromJSON(json, context) {
533
- let { conjectures } = json;
534
-
535
- const { Conjecture } = elements,
536
- conjecturesJSON = conjectures; ///
537
-
538
- conjectures = conjecturesJSON.map((conjectureJSON) => {
539
- const json = conjectureJSON, ///
540
- conjecture = Conjecture.fromJSON(json, context);
541
-
542
- return conjecture;
543
- });
544
-
545
- return conjectures;
546
- }
547
-
548
483
  export function combinatorsFromJSON(json, context) {
549
484
  let { combinators } = json;
550
485
 
@@ -922,16 +857,6 @@ export function typesToTypesJSON(types) {
922
857
  return typesJSON;
923
858
  }
924
859
 
925
- export function rulesToRulesJSON(rules) {
926
- const rulesJSON = rules.map((rule) => {
927
- const ruleJSON = rule.toJSON();
928
-
929
- return ruleJSON;
930
- });
931
-
932
- return rulesJSON;
933
- }
934
-
935
860
  export function labelsToLabelsJSON(labels) {
936
861
  const labelsJSON = labels.map((label) => {
937
862
  const labelJSON = label.toJSON();
@@ -952,16 +877,6 @@ export function framesToFramesJSON(frames) {
952
877
  return framesJSON;
953
878
  }
954
879
 
955
- export function axiomsToAxiomsJSON(axioms) {
956
- const axiomsJSON = axioms.map((axiom) => {
957
- const axiomJSON = axiom.toJSON();
958
-
959
- return axiomJSON;
960
- });
961
-
962
- return axiomsJSON;
963
- }
964
-
965
880
  export function premisesToPremisesJSON(premises) {
966
881
  const premisesJSON = premises.map((premise) => {
967
882
  const premiseJSON = premise.toJSON();
@@ -972,16 +887,6 @@ export function premisesToPremisesJSON(premises) {
972
887
  return premisesJSON;
973
888
  }
974
889
 
975
- export function theoremsToTheoremsJSON(theorems) {
976
- const theoremsJSON = theorems.map((theorem) => {
977
- const theoremJSON = theorem.toJSON();
978
-
979
- return theoremJSON;
980
- });
981
-
982
- return theoremsJSON;
983
- }
984
-
985
890
  export function variablesToVariablesJSON(variables) {
986
891
  const variablesJSON = variables.map((variable) => {
987
892
  const variableJSON = variable.toJSON();
@@ -1082,16 +987,6 @@ export function referencesToReferencesJSON(references) {
1082
987
  return referencesJSON;
1083
988
  }
1084
989
 
1085
- export function conjecturesToConjecturesJSON(conjectures) {
1086
- const conjecturesJSON = conjectures.map((conjecture) => {
1087
- const conjectureJSON = conjecture.toJSON();
1088
-
1089
- return conjectureJSON;
1090
- });
1091
-
1092
- return conjecturesJSON;
1093
- }
1094
-
1095
990
  export function combinatorsToCombinatorsJSON(combinators) {
1096
991
  const combinatorsJSON = combinators.map((combinator) => {
1097
992
  const combinatorJSON = combinator.toJSON();