occam-verify-cli 0.0.1067 → 0.0.1069
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.
- package/bin/action/verify.js +3 -2
- package/lib/assertion/contained.js +2 -2
- package/lib/assertion/defined.js +2 -2
- package/lib/assertion/subproof.js +3 -3
- package/lib/assignment/judgement.js +3 -3
- package/lib/axiom.js +11 -6
- package/lib/combinator.js +9 -9
- package/lib/conclusion.js +13 -10
- package/lib/conjecture.js +11 -6
- package/lib/consequent.js +13 -10
- package/lib/constructor.js +9 -9
- package/lib/context/file.js +34 -126
- package/lib/context/local.js +16 -5
- package/lib/context/release.js +2 -3
- package/lib/declaration.js +96 -2
- package/lib/equivalence.js +2 -2
- package/lib/frame.js +179 -98
- package/lib/index.js +22 -6
- package/lib/judgement.js +84 -5
- package/lib/label.js +12 -8
- package/lib/lemma.js +12 -12
- package/lib/metaLemma.js +120 -8
- package/lib/metaType.js +24 -3
- package/lib/metatheorem.js +145 -9
- package/lib/metavariable.js +128 -43
- package/lib/mixins/statement/qualified/unify.js +6 -10
- package/lib/mixins/statement/unify.js +4 -19
- package/lib/mixins/statement/verify.js +13 -13
- package/lib/mixins/term/unify.js +2 -2
- package/lib/premise.js +21 -13
- package/lib/reference.js +17 -17
- package/lib/rule.js +28 -40
- package/lib/statement/unqualified.js +34 -9
- package/lib/statement.js +7 -5
- package/lib/substitution/frameForMetavariable.js +75 -70
- package/lib/substitution/statementForMetavariable.js +83 -42
- package/lib/substitution/termForVariable.js +65 -68
- package/lib/substitution.js +46 -43
- package/lib/substitutions.js +52 -40
- package/lib/supposition.js +15 -11
- package/lib/term.js +6 -11
- package/lib/theorem.js +11 -6
- package/lib/topLevelAssertion.js +24 -42
- package/lib/type.js +5 -12
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +11 -7
- package/lib/unifier/metavariable.js +6 -6
- package/lib/unifier/statementWithCombinator.js +16 -16
- package/lib/unifier/termWithConstructor.js +7 -7
- package/lib/utilities/brackets.js +10 -10
- package/lib/utilities/json.js +493 -0
- package/lib/utilities/node.js +26 -19
- package/lib/utilities/release.js +53 -0
- package/lib/utilities/releaseContext.js +4 -15
- package/lib/utilities/tokens.js +8 -1
- package/lib/variable.js +14 -15
- package/lib/verifier/topLevel.js +5 -5
- package/package.json +1 -1
- package/src/assertion/contained.js +1 -1
- package/src/assertion/defined.js +1 -1
- package/src/assertion/subproof.js +2 -3
- package/src/assignment/judgement.js +3 -4
- package/src/axiom.js +14 -6
- package/src/combinator.js +12 -13
- package/src/conclusion.js +16 -13
- package/src/conjecture.js +14 -6
- package/src/consequent.js +16 -13
- package/src/constructor.js +11 -13
- package/src/context/file.js +94 -202
- package/src/context/local.js +8 -6
- package/src/context/release.js +2 -3
- package/src/declaration.js +126 -45
- package/src/equivalence.js +2 -2
- package/src/frame.js +225 -141
- package/src/index.js +17 -1
- package/src/judgement.js +109 -3
- package/src/label.js +15 -10
- package/src/lemma.js +17 -10
- package/src/metaLemma.js +102 -1
- package/src/metaType.js +29 -3
- package/src/metatheorem.js +143 -2
- package/src/metavariable.js +189 -66
- package/src/mixins/statement/qualified/unify.js +7 -19
- package/src/mixins/statement/unify.js +3 -25
- package/src/mixins/statement/verify.js +15 -13
- package/src/mixins/term/unify.js +1 -1
- package/src/premise.js +31 -16
- package/src/reference.js +18 -18
- package/src/rule.js +40 -58
- package/src/statement/unqualified.js +41 -11
- package/src/statement.js +6 -3
- package/src/substitution/frameForMetavariable.js +85 -98
- package/src/substitution/statementForMetavariable.js +109 -45
- package/src/substitution/termForVariable.js +83 -94
- package/src/substitution.js +36 -34
- package/src/substitutions.js +53 -46
- package/src/supposition.js +22 -14
- package/src/term.js +5 -15
- package/src/theorem.js +14 -6
- package/src/topLevelAssertion.js +38 -64
- package/src/type.js +5 -20
- package/src/unifier/intrinsicLevel.js +4 -3
- package/src/unifier/metaLevel.js +19 -7
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +19 -19
- package/src/unifier/termWithConstructor.js +7 -7
- package/src/utilities/brackets.js +5 -5
- package/src/utilities/json.js +551 -0
- package/src/utilities/node.js +28 -23
- package/src/{verify → utilities}/release.js +5 -1
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/tokens.js +10 -0
- package/src/variable.js +18 -19
- package/src/verifier/topLevel.js +6 -4
- package/lib/argument.js +0 -106
- package/lib/metaTypes.js +0 -19
- package/lib/unify/metavariableWithFrame.js +0 -40
- package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
- package/lib/unify/statementWithSttaemetnGivenEquivalences.js +0 -45
- package/lib/verify/declaration.js +0 -83
- package/lib/verify/frame.js +0 -120
- package/lib/verify/judgement.js +0 -88
- package/lib/verify/metaLemma.js +0 -49
- package/lib/verify/metatheorem.js +0 -48
- package/lib/verify/metavariableGivenMetaType.js +0 -44
- package/lib/verify/release.js +0 -50
- package/src/argument.js +0 -79
- package/src/metaTypes.js +0 -11
- package/src/unify/metavariableWithFrame.js +0 -40
- package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
- package/src/unify/statementWithSttaemetnGivenEquivalences.js +0 -51
- package/src/verify/declaration.js +0 -113
- package/src/verify/frame.js +0 -157
- package/src/verify/judgement.js +0 -127
- package/src/verify/metaLemma.js +0 -72
- package/src/verify/metatheorem.js +0 -67
- package/src/verify/metavariableGivenMetaType.js +0 -45
package/src/context/file.js
CHANGED
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import shim from "../shim";
|
|
6
|
-
import Rule from "../rule";
|
|
7
|
-
import Axiom from "../axiom";
|
|
8
|
-
import Lemma from "../lemma";
|
|
9
|
-
import Theorem from "../theorem";
|
|
10
|
-
import Variable from "../variable";
|
|
11
|
-
import metaTypes from "../metaTypes";
|
|
12
|
-
import MetaLemma from "../metaLemma";
|
|
13
|
-
import Conjecture from "../conjecture";
|
|
14
|
-
import Combinator from "../combinator";
|
|
15
|
-
import Constructor from "../constructor";
|
|
16
|
-
import Metatheorem from "../metatheorem";
|
|
17
|
-
import Metavariable from "../metavariable";
|
|
18
|
-
|
|
19
5
|
import { objectType } from "../type";
|
|
6
|
+
import { frameMetaType, referenceMetaType, statementMetaType } from "../metaType";
|
|
20
7
|
import { nodeAsTokens, nodeAsString, nodesAsString, tokensAsString } from "../utilities/string";
|
|
8
|
+
import { typesFromJSON,
|
|
9
|
+
rulesFromJSON,
|
|
10
|
+
axiomsFromJSON,
|
|
11
|
+
theoremsFromJSON,
|
|
12
|
+
variablesFromJSON,
|
|
13
|
+
conjecturesFromJSON,
|
|
14
|
+
combinatorsFromJSON,
|
|
15
|
+
constructorsFromJSON,
|
|
16
|
+
metatheoremsFromJSON,
|
|
17
|
+
metavariablesFromJSON,
|
|
18
|
+
typesToTypesJSON,
|
|
19
|
+
rulesToRulesJSON,
|
|
20
|
+
axiomsToAxiomsJSON,
|
|
21
|
+
theoremsToTheoremsJSON,
|
|
22
|
+
variablesToVariablesJSON,
|
|
23
|
+
conjecturesToConjecturesJSON,
|
|
24
|
+
combinatorsToCombinatorsJSON,
|
|
25
|
+
constructorsToConstructorsJSON,
|
|
26
|
+
metatheoremsToMetatheoremsJSON,
|
|
27
|
+
metavariablesToMetavariablesJSON } from "../utilities/json";
|
|
21
28
|
|
|
22
29
|
const { push } = arrayUtilities;
|
|
23
30
|
|
|
@@ -224,6 +231,12 @@ export default class FileContext {
|
|
|
224
231
|
}
|
|
225
232
|
|
|
226
233
|
getMetaTypes(includeRelease = true) {
|
|
234
|
+
const metaTypes = [
|
|
235
|
+
frameMetaType,
|
|
236
|
+
referenceMetaType,
|
|
237
|
+
statementMetaType
|
|
238
|
+
];
|
|
239
|
+
|
|
227
240
|
return metaTypes;
|
|
228
241
|
}
|
|
229
242
|
|
|
@@ -686,6 +699,30 @@ export default class FileContext {
|
|
|
686
699
|
|
|
687
700
|
error(message) { this.releaseContext.error(message, this.filePath); }
|
|
688
701
|
|
|
702
|
+
initialise(json) {
|
|
703
|
+
const fileContext = this;
|
|
704
|
+
|
|
705
|
+
this.types - typesFromJSON(json, fileContext);
|
|
706
|
+
|
|
707
|
+
this.rules = rulesFromJSON(json, fileContext);
|
|
708
|
+
|
|
709
|
+
this.axioms = axiomsFromJSON(json, fileContext);
|
|
710
|
+
|
|
711
|
+
this.theorems = theoremsFromJSON(json, fileContext);
|
|
712
|
+
|
|
713
|
+
this.variables = variablesFromJSON(json, fileContext);
|
|
714
|
+
|
|
715
|
+
this.conjectures = conjecturesFromJSON(json, fileContext);
|
|
716
|
+
|
|
717
|
+
this.combinators = combinatorsFromJSON(json, fileContext);
|
|
718
|
+
|
|
719
|
+
this.constructors = constructorsFromJSON(json, fileContext);
|
|
720
|
+
|
|
721
|
+
this.metatheorems = metatheoremsFromJSON(json, fileContext);
|
|
722
|
+
|
|
723
|
+
this.metavariables = metavariablesFromJSON(json, fileContext);
|
|
724
|
+
}
|
|
725
|
+
|
|
689
726
|
reset() {
|
|
690
727
|
this.types = [];
|
|
691
728
|
this.rules = [];
|
|
@@ -703,99 +740,33 @@ export default class FileContext {
|
|
|
703
740
|
|
|
704
741
|
toJSON() {
|
|
705
742
|
const filePath = this.filePath,
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
}),
|
|
727
|
-
lemmas = this.lemmas.map((lemma) => {
|
|
728
|
-
const lemmaJSON = lemma.toJSON();
|
|
729
|
-
|
|
730
|
-
lemma = lemmaJSON; ///
|
|
731
|
-
|
|
732
|
-
return lemma;
|
|
733
|
-
}),
|
|
734
|
-
theorems = this.theorems.map((theorem) => {
|
|
735
|
-
const theoremJSON = theorem.toJSON();
|
|
736
|
-
|
|
737
|
-
theorem = theoremJSON; ///
|
|
738
|
-
|
|
739
|
-
return theorem;
|
|
740
|
-
}),
|
|
741
|
-
variables = this.variables.map((variable) => {
|
|
742
|
-
const variableJSON = variable.toJSON();
|
|
743
|
-
|
|
744
|
-
variable = variableJSON; ///
|
|
745
|
-
|
|
746
|
-
return variable;
|
|
747
|
-
}),
|
|
748
|
-
metaLemmas = this.metaLemmas.map((metaLemma) => {
|
|
749
|
-
const metaLemmaJSON = metaLemma.toJSON();
|
|
750
|
-
|
|
751
|
-
metaLemma = metaLemmaJSON; ///
|
|
752
|
-
|
|
753
|
-
return metaLemma;
|
|
754
|
-
}),
|
|
755
|
-
conjectures = this.conjectures.map((conjecture) => {
|
|
756
|
-
const conjectureJSON = conjecture.toJSON();
|
|
757
|
-
|
|
758
|
-
conjecture = conjectureJSON; ///
|
|
759
|
-
|
|
760
|
-
return conjecture;
|
|
761
|
-
}),
|
|
762
|
-
combinators = this.combinators.map((combinator) => {
|
|
763
|
-
const combinatorJSON = combinator.toJSON();
|
|
764
|
-
|
|
765
|
-
combinator = combinatorJSON; ///
|
|
766
|
-
|
|
767
|
-
return combinator;
|
|
768
|
-
}),
|
|
769
|
-
constructors = this.constructors.map((constructor) => {
|
|
770
|
-
const constructorJSON = constructor.toJSON();
|
|
771
|
-
|
|
772
|
-
constructor = constructorJSON; ///
|
|
773
|
-
|
|
774
|
-
return constructor;
|
|
775
|
-
}),
|
|
776
|
-
metatheorems = this.metatheorems.map((metatheorem) => {
|
|
777
|
-
const metatheoremJSON = metatheorem.toJSON();
|
|
778
|
-
|
|
779
|
-
metatheorem = metatheoremJSON; ///
|
|
780
|
-
|
|
781
|
-
return metatheorem;
|
|
782
|
-
}),
|
|
783
|
-
metavariables = this.metavariables.map((metavariable) => {
|
|
784
|
-
const metavariableJSON = metavariable.toJSON();
|
|
785
|
-
|
|
786
|
-
metavariable = metavariableJSON; ///
|
|
787
|
-
|
|
788
|
-
return metavariable;
|
|
789
|
-
}),
|
|
743
|
+
typesJSON = typesToTypesJSON(this.types),
|
|
744
|
+
rulesJSON = rulesToRulesJSON(this.rules),
|
|
745
|
+
axiomsJSON = axiomsToAxiomsJSON(this.axioms),
|
|
746
|
+
theoremsJSON = theoremsToTheoremsJSON(this.theorems),
|
|
747
|
+
variablesJSON = variablesToVariablesJSON(this.variables),
|
|
748
|
+
conjecturesJSON = conjecturesToConjecturesJSON(this.conjectures),
|
|
749
|
+
combinatorsJSON = combinatorsToCombinatorsJSON(this.combinators),
|
|
750
|
+
constructorsJSON = constructorsToConstructorsJSON(this.constructors),
|
|
751
|
+
metatheoremsJSON = metatheoremsToMetatheoremsJSON(this.metatheorems),
|
|
752
|
+
metavariablesJSON = metavariablesToMetavariablesJSON(this.metavariables),
|
|
753
|
+
types = typesJSON, ///
|
|
754
|
+
rules = rulesJSON, ///
|
|
755
|
+
axioms = axiomsJSON, ///
|
|
756
|
+
theorems = theoremsJSON, ///
|
|
757
|
+
variables = variablesJSON, ///
|
|
758
|
+
conjectures = conjecturesJSON, ///
|
|
759
|
+
combinators = combinatorsJSON, ///
|
|
760
|
+
constructors = constructorsJSON, ///
|
|
761
|
+
metatheorems = metatheoremsJSON, ///
|
|
762
|
+
metavariables = metavariablesJSON, ///
|
|
790
763
|
json = {
|
|
791
764
|
filePath,
|
|
792
765
|
types,
|
|
793
766
|
rules,
|
|
794
767
|
axioms,
|
|
795
|
-
lemmas,
|
|
796
768
|
theorems,
|
|
797
769
|
variables,
|
|
798
|
-
metaLemmas,
|
|
799
770
|
conjectures,
|
|
800
771
|
combinators,
|
|
801
772
|
constructors,
|
|
@@ -806,108 +777,6 @@ export default class FileContext {
|
|
|
806
777
|
return json;
|
|
807
778
|
}
|
|
808
779
|
|
|
809
|
-
initialise(fileContextJSON) {
|
|
810
|
-
const { types, rules, axioms, lemmas, theorems, metaLemmas, variables, conjectures, combinators, constructors, metatheorems, metavariables } = fileContextJSON,
|
|
811
|
-
fileContext = this, ///
|
|
812
|
-
typesJSON = types, ///
|
|
813
|
-
rulesJSON = rules, ///
|
|
814
|
-
axiomsJSON = axioms, ///
|
|
815
|
-
lemmasJSON = lemmas, ///
|
|
816
|
-
theoremsJSON = theorems, ///
|
|
817
|
-
variablesJSON = variables, ///
|
|
818
|
-
metaLemmasJSON = metaLemmas, ///
|
|
819
|
-
conjecturesJSON = conjectures, ///
|
|
820
|
-
combinatorsJSON = combinators, ///
|
|
821
|
-
constructorsJSON = constructors, ///
|
|
822
|
-
metatheoremsJSON = metatheorems, ///
|
|
823
|
-
metavariablesJSON = metavariables; ///
|
|
824
|
-
|
|
825
|
-
typesJSON.forEach((typeJSON) => {
|
|
826
|
-
const { Type } = shim,
|
|
827
|
-
json = typeJSON, ///
|
|
828
|
-
type = Type.fromJSON(json, fileContext);
|
|
829
|
-
|
|
830
|
-
this.types.push(type);
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
rulesJSON.forEach((ruleJSON) => {
|
|
834
|
-
const json = ruleJSON, ///
|
|
835
|
-
rule = Rule.fromJSON(json, fileContext);
|
|
836
|
-
|
|
837
|
-
this.rules.push(rule);
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
axiomsJSON.forEach((axiomJSON) => {
|
|
841
|
-
const json = axiomJSON, ///
|
|
842
|
-
axiom = Axiom.fromJSON(json, fileContext);
|
|
843
|
-
|
|
844
|
-
this.axioms.push(axiom);
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
lemmasJSON.forEach((lemmaJSON) => {
|
|
848
|
-
const json = lemmaJSON, ///
|
|
849
|
-
lemma = Lemma.fromJSON(json, fileContext);
|
|
850
|
-
|
|
851
|
-
this.lemmas.push(lemma);
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
theoremsJSON.forEach((theoremJSON) => {
|
|
855
|
-
const json = theoremJSON, ///
|
|
856
|
-
theorem = Theorem.fromJSON(json, fileContext);
|
|
857
|
-
|
|
858
|
-
this.theorems.push(theorem);
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
variablesJSON.forEach((variableJSON) => {
|
|
862
|
-
const json = variableJSON, ///
|
|
863
|
-
variable = Variable.fromJSON(json, fileContext);
|
|
864
|
-
|
|
865
|
-
this.variables.push(variable);
|
|
866
|
-
});
|
|
867
|
-
|
|
868
|
-
metaLemmasJSON.forEach((metaLemmaJSON) => {
|
|
869
|
-
const json = metaLemmaJSON, ///
|
|
870
|
-
metaLemma = MetaLemma.fromJSON(json, fileContext);
|
|
871
|
-
|
|
872
|
-
this.metaLemmas.push(metaLemma);
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
conjecturesJSON.forEach((conjectureJSON) => {
|
|
876
|
-
const json = conjectureJSON, ///
|
|
877
|
-
conjecture = Conjecture.fromJSON(json, fileContext);
|
|
878
|
-
|
|
879
|
-
this.conjectures.push(conjecture);
|
|
880
|
-
});
|
|
881
|
-
|
|
882
|
-
combinatorsJSON.forEach((combinatorJSON) => {
|
|
883
|
-
const json = combinatorJSON, ///
|
|
884
|
-
combinator = Combinator.fromJSON(json, fileContext);
|
|
885
|
-
|
|
886
|
-
this.combinators.push(combinator);
|
|
887
|
-
});
|
|
888
|
-
|
|
889
|
-
constructorsJSON.forEach((constructorJSON) => {
|
|
890
|
-
const json = constructorJSON, ///
|
|
891
|
-
constructor = Constructor.fromJSON(json, fileContext);
|
|
892
|
-
|
|
893
|
-
this.constructors.push(constructor);
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
metatheoremsJSON.forEach((metatheoremJSON) => {
|
|
897
|
-
const json = metatheoremJSON, ///
|
|
898
|
-
metatheorem = Metatheorem.fromJSON(json, fileContext);
|
|
899
|
-
|
|
900
|
-
this.metatheorems.push(metatheorem);
|
|
901
|
-
});
|
|
902
|
-
|
|
903
|
-
metavariablesJSON.forEach((metavariableJSON) => {
|
|
904
|
-
const json = metavariableJSON, ///
|
|
905
|
-
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
906
|
-
|
|
907
|
-
this.metavariables.push(metavariable);
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
|
|
911
780
|
static fromFile(file, releaseContext) {
|
|
912
781
|
const lexer = releaseContext.getLexer(),
|
|
913
782
|
parser = releaseContext.getParser(),
|
|
@@ -932,4 +801,27 @@ export default class FileContext {
|
|
|
932
801
|
|
|
933
802
|
return fileContext;
|
|
934
803
|
}
|
|
804
|
+
|
|
805
|
+
static fromFileAndJSON(file, json, releaseContext) {
|
|
806
|
+
const filePath = file.getPath(),
|
|
807
|
+
tokens = null,
|
|
808
|
+
node = null,
|
|
809
|
+
types = null,
|
|
810
|
+
rules = null,
|
|
811
|
+
axioms = null,
|
|
812
|
+
lemmas = [],
|
|
813
|
+
theorems = null,
|
|
814
|
+
variables = null,
|
|
815
|
+
metaLemmas = [],
|
|
816
|
+
conjectures = null,
|
|
817
|
+
combinators = null,
|
|
818
|
+
constructors = null,
|
|
819
|
+
metatheorems = null,
|
|
820
|
+
metavariables = null,
|
|
821
|
+
fileContext = new FileContext(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, variables, metaLemmas, theorems, conjectures, combinators, constructors, metatheorems, metavariables);
|
|
822
|
+
|
|
823
|
+
fileContext.initialise(json);
|
|
824
|
+
|
|
825
|
+
return fileContext;
|
|
826
|
+
}
|
|
935
827
|
}
|
package/src/context/local.js
CHANGED
|
@@ -96,6 +96,10 @@ class LocalContext {
|
|
|
96
96
|
return lastProofStep;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
getLexer() { return this.context.getLexer(); }
|
|
100
|
+
|
|
101
|
+
getParser() { return this.context.getParser(); }
|
|
102
|
+
|
|
99
103
|
getAxioms() { return this.context.getAxioms(); }
|
|
100
104
|
|
|
101
105
|
getLemmas() { return this.context.getLemmas(); }
|
|
@@ -456,15 +460,13 @@ class LocalContext {
|
|
|
456
460
|
return localContext;
|
|
457
461
|
}
|
|
458
462
|
|
|
459
|
-
static
|
|
460
|
-
const
|
|
461
|
-
variables = [],
|
|
463
|
+
static fromContextAndTokens(context, tokens) {
|
|
464
|
+
const variables = [],
|
|
462
465
|
proofSteps = [],
|
|
463
466
|
judgements = [],
|
|
464
467
|
equivalences = [],
|
|
465
|
-
metavariables = []
|
|
466
|
-
|
|
467
|
-
localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences, metavariables); ///
|
|
468
|
+
metavariables = [],
|
|
469
|
+
localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences, metavariables); ///
|
|
468
470
|
|
|
469
471
|
return localContext;
|
|
470
472
|
}
|
package/src/context/release.js
CHANGED
|
@@ -454,9 +454,8 @@ function fileContextsFromJSONAndEntries(json, entries, fileContexts, releaseCont
|
|
|
454
454
|
fileContextsJSON.forEach((fileContextJSON) => {
|
|
455
455
|
const { filePath } = fileContextJSON,
|
|
456
456
|
file = entries.findFile(filePath),
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
fileContext.initialise(fileContextJSON);
|
|
457
|
+
json = fileContextJSON, ///
|
|
458
|
+
fileContext = FileContext.fromFileAndJSON(file, json, releaseContext);
|
|
460
459
|
|
|
461
460
|
fileContexts.push(fileContext);
|
|
462
461
|
});
|
package/src/declaration.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import Reference from "./reference";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "./utilities/query";
|
|
7
|
+
import { stripBracketsFromStatementNode } from "./utilities/brackets";
|
|
8
|
+
|
|
9
|
+
const referenceNodeQuery = nodeQuery("/declaration/reference"),
|
|
10
|
+
statementNodeQuery = nodeQuery("/declaration/statement");
|
|
4
11
|
|
|
5
12
|
export default class Declaration {
|
|
6
|
-
constructor(reference, statement) {
|
|
13
|
+
constructor(string, reference, statement) {
|
|
14
|
+
this.string = string;
|
|
7
15
|
this.reference = reference;
|
|
8
16
|
this.statement = statement;
|
|
9
17
|
}
|
|
10
18
|
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
getReference() {
|
|
12
24
|
return this.reference;
|
|
13
25
|
}
|
|
@@ -16,47 +28,116 @@ export default class Declaration {
|
|
|
16
28
|
return this.statement;
|
|
17
29
|
}
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
unifyStatement(statement, localContext) {
|
|
32
|
+
let statementUnified;
|
|
33
|
+
|
|
34
|
+
const statementString = statement.getString(),
|
|
35
|
+
declarationStatementString = this.statement.getString(); ///
|
|
36
|
+
|
|
37
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${declarationStatementString}' statement...`);
|
|
38
|
+
|
|
39
|
+
let statementNode = statement.getNode();
|
|
40
|
+
|
|
41
|
+
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
42
|
+
|
|
43
|
+
const statementNodeMatches = this.statement.matchStatementNode(statementNode);
|
|
44
|
+
|
|
45
|
+
statementUnified = statementNodeMatches; ///
|
|
46
|
+
|
|
47
|
+
if (statementUnified) {
|
|
48
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${declarationStatementString}' statement.`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return statementUnified;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
unifyMetavariable(metavariable, localContext) {
|
|
55
|
+
let metavariableUnified;
|
|
56
|
+
|
|
57
|
+
const referenceString = this.reference.getString(),
|
|
58
|
+
metavariableString = metavariable.getString();
|
|
59
|
+
|
|
60
|
+
localContext.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
|
|
61
|
+
|
|
62
|
+
const metavariableNode = metavariable.getNode(),
|
|
63
|
+
metavariableNodeMatches = this.reference.matchMetavariableNode(metavariableNode);
|
|
64
|
+
|
|
65
|
+
metavariableUnified = metavariableNodeMatches; ///
|
|
66
|
+
|
|
67
|
+
if (metavariableUnified) {
|
|
68
|
+
localContext.debug(`...unified the '${metavariableString}' metavariable with the '${referenceString}' reference.`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return metavariableUnified;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
unifySubstitution(substitution, localContext) {
|
|
75
|
+
let substitutionUnified;
|
|
76
|
+
|
|
77
|
+
const declarationString = this.string, ///
|
|
78
|
+
substitutionString = substitution.getString();
|
|
79
|
+
|
|
80
|
+
localContext.trace(`Unifying the '${substitutionString}' substitution with the '${declarationString}' declaration...`);
|
|
81
|
+
|
|
82
|
+
const statement = substitution.getStatement(),
|
|
83
|
+
metavariable = substitution.getMetavariable(),
|
|
84
|
+
statementUnified = this.unifyStatement(statement, localContext),
|
|
85
|
+
metavariableUnified = this.unifyMetavariable(metavariable, localContext);
|
|
86
|
+
|
|
87
|
+
substitutionUnified = (metavariableUnified && statementUnified);
|
|
88
|
+
|
|
89
|
+
if (substitutionUnified) {
|
|
90
|
+
localContext.debug(`...unified the '${declarationString}' substitution with the '${substitutionString}' declaration.`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return substitutionUnified;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
verify(assignments, stated, localContext) {
|
|
97
|
+
let verified;
|
|
98
|
+
|
|
99
|
+
const declarationString = this.string; ///
|
|
100
|
+
|
|
101
|
+
localContext.trace(`Verifying the '${declarationString}' declaration...`);
|
|
102
|
+
|
|
103
|
+
stated = true;
|
|
104
|
+
|
|
105
|
+
assignments = null;
|
|
106
|
+
|
|
107
|
+
const referenceVerified = this.reference.verify(localContext);
|
|
108
|
+
|
|
109
|
+
if (referenceVerified) {
|
|
110
|
+
const statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
111
|
+
|
|
112
|
+
verified = statementVerified; ///
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (verified) {
|
|
116
|
+
localContext.debug(`...verified the '${declarationString}' declaration.`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return verified;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static fromDeclarationNode(declarationNode, localContext) {
|
|
123
|
+
let declaration = null;
|
|
124
|
+
|
|
125
|
+
if (declarationNode !== null) {
|
|
126
|
+
const { Statement } = shim,
|
|
127
|
+
referenceNode = referenceNodeQuery(declarationNode);
|
|
128
|
+
|
|
129
|
+
let statementNode = statementNodeQuery(declarationNode);
|
|
130
|
+
|
|
131
|
+
statementNode = stripBracketsFromStatementNode(statementNode); ///
|
|
132
|
+
|
|
133
|
+
const reference = Reference.fromReferenceNode(referenceNode, localContext),
|
|
134
|
+
statement = Statement.fromStatementNode(statementNode, localContext),
|
|
135
|
+
node = declarationNode, ///
|
|
136
|
+
string = localContext.nodeAsString(node);
|
|
137
|
+
|
|
138
|
+
declaration = new Declaration(string, reference, statement);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return declaration;
|
|
142
|
+
}
|
|
62
143
|
}
|
package/src/equivalence.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { nodeQuery } from "./utilities/query";
|
|
4
|
-
import {
|
|
4
|
+
import { stripBracketsFromTermNode } from "./utilities/brackets";
|
|
5
5
|
import { variableNameFromVariableNode } from "./utilities/name";
|
|
6
6
|
|
|
7
7
|
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
@@ -83,7 +83,7 @@ export default class Equivalence {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
matchTermNode(termNode) {
|
|
86
|
-
termNode =
|
|
86
|
+
termNode = stripBracketsFromTermNode(termNode); ///
|
|
87
87
|
|
|
88
88
|
const termNodeMatches = this.terms.some((term) => {
|
|
89
89
|
const termNodeMatches = term.matchTermNode(termNode);
|