occam-verify-cli 1.0.612 → 1.0.631
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/lib/context/ephemeral.js +210 -77
- package/lib/context/file/nominal.js +157 -135
- package/lib/context/liminal.js +34 -59
- package/lib/context/scoped.js +37 -58
- package/lib/context.js +103 -53
- package/lib/element/assertion/contained.js +3 -1
- package/lib/element/assertion/defined.js +3 -1
- package/lib/element/assertion/property.js +10 -58
- package/lib/element/assertion/satisfies.js +3 -1
- package/lib/element/assertion/subproof.js +3 -1
- package/lib/element/assertion/type.js +63 -109
- package/lib/element/assertion.js +5 -9
- package/lib/element/assumption.js +50 -19
- package/lib/element/combinator.js +8 -1
- package/lib/element/conclusion.js +8 -1
- package/lib/element/constructor.js +8 -1
- package/lib/element/declaration.js +3 -7
- package/lib/element/deduction.js +8 -1
- package/lib/element/derivation.js +15 -10
- package/lib/element/equality.js +109 -62
- package/lib/element/equivalence.js +13 -6
- package/lib/element/equivalences.js +11 -4
- package/lib/element/error.js +10 -7
- package/lib/element/frame.js +21 -21
- package/lib/element/hypothesis.js +12 -7
- package/lib/element/judgement.js +55 -26
- package/lib/element/label.js +8 -1
- package/lib/element/metaType.js +9 -2
- package/lib/element/metavariable.js +16 -10
- package/lib/element/parameter.js +8 -1
- package/lib/element/procedureCall.js +21 -29
- package/lib/element/procedureReference.js +15 -1
- package/lib/element/proof.js +8 -1
- package/lib/element/proofAssertion.js +8 -1
- package/lib/element/property.js +8 -1
- package/lib/element/propertyRelation.js +8 -1
- package/lib/element/reference.js +16 -28
- package/lib/element/rule.js +22 -21
- package/lib/element/section.js +8 -1
- package/lib/element/signature.js +8 -1
- package/lib/element/statement.js +34 -40
- package/lib/element/subDerivation.js +11 -6
- package/lib/element/subproof.js +8 -1
- package/lib/element/substitution/frame.js +6 -6
- package/lib/element/substitution/reference.js +6 -6
- package/lib/element/substitution/statement.js +6 -6
- package/lib/element/substitution/term.js +9 -3
- package/lib/element/substitution.js +73 -49
- package/lib/element/term.js +15 -1
- package/lib/element/topLevelAssertion/axiom.js +8 -1
- package/lib/element/topLevelAssertion/conjecture.js +8 -1
- package/lib/element/topLevelAssertion/lemma.js +8 -1
- package/lib/element/topLevelAssertion/theorem.js +8 -1
- package/lib/element/topLevelAssertion.js +11 -17
- package/lib/element/topLevelMetaAssertion/metaLemma.js +8 -1
- package/lib/element/topLevelMetaAssertion/metatheorem.js +8 -1
- package/lib/element/topLevelMetaAssertion.js +9 -11
- package/lib/element/type.js +8 -1
- package/lib/element/typePrefix.js +8 -1
- package/lib/element/variable.js +51 -5
- package/lib/preamble.js +1 -2
- package/lib/process/assign.js +96 -27
- package/lib/process/unify.js +3 -4
- package/lib/process/validate.js +2 -2
- package/lib/process/verify.js +2 -2
- package/lib/utilities/element.js +74 -12
- package/lib/utilities/json.js +2 -2
- package/lib/utilities/string.js +9 -24
- package/lib/utilities/substitutions.js +15 -23
- package/package.json +2 -2
- package/src/context/ephemeral.js +234 -82
- package/src/context/file/nominal.js +195 -135
- package/src/context/liminal.js +43 -80
- package/src/context/scoped.js +56 -81
- package/src/context.js +97 -46
- package/src/element/assertion/contained.js +4 -0
- package/src/element/assertion/defined.js +4 -0
- package/src/element/assertion/property.js +15 -26
- package/src/element/assertion/satisfies.js +4 -0
- package/src/element/assertion/subproof.js +4 -0
- package/src/element/assertion/type.js +67 -77
- package/src/element/assertion.js +4 -8
- package/src/element/assumption.js +57 -18
- package/src/element/combinator.js +7 -0
- package/src/element/conclusion.js +7 -0
- package/src/element/constructor.js +7 -0
- package/src/element/declaration.js +1 -3
- package/src/element/deduction.js +7 -0
- package/src/element/derivation.js +10 -5
- package/src/element/equality.js +116 -74
- package/src/element/equivalence.js +15 -7
- package/src/element/equivalences.js +14 -5
- package/src/element/error.js +5 -2
- package/src/element/frame.js +25 -25
- package/src/element/hypothesis.js +11 -6
- package/src/element/judgement.js +62 -26
- package/src/element/label.js +7 -0
- package/src/element/metaType.js +8 -1
- package/src/element/metavariable.js +20 -14
- package/src/element/parameter.js +7 -0
- package/src/element/procedureCall.js +21 -14
- package/src/element/procedureReference.js +13 -0
- package/src/element/proof.js +7 -0
- package/src/element/proofAssertion.js +7 -0
- package/src/element/property.js +7 -0
- package/src/element/propertyRelation.js +7 -0
- package/src/element/reference.js +20 -33
- package/src/element/rule.js +16 -19
- package/src/element/section.js +7 -0
- package/src/element/signature.js +7 -0
- package/src/element/statement.js +36 -44
- package/src/element/subDerivation.js +10 -5
- package/src/element/subproof.js +7 -0
- package/src/element/substitution/frame.js +3 -3
- package/src/element/substitution/reference.js +3 -3
- package/src/element/substitution/statement.js +3 -3
- package/src/element/substitution/term.js +4 -2
- package/src/element/substitution.js +60 -40
- package/src/element/term.js +20 -2
- package/src/element/topLevelAssertion/axiom.js +7 -0
- package/src/element/topLevelAssertion/conjecture.js +7 -0
- package/src/element/topLevelAssertion/lemma.js +7 -0
- package/src/element/topLevelAssertion/theorem.js +7 -0
- package/src/element/topLevelAssertion.js +5 -15
- package/src/element/topLevelMetaAssertion/metaLemma.js +7 -0
- package/src/element/topLevelMetaAssertion/metatheorem.js +7 -0
- package/src/element/topLevelMetaAssertion.js +4 -6
- package/src/element/type.js +7 -0
- package/src/element/typePrefix.js +7 -0
- package/src/element/variable.js +9 -4
- package/src/preamble.js +0 -1
- package/src/process/assign.js +113 -38
- package/src/process/unify.js +2 -3
- package/src/process/validate.js +1 -1
- package/src/process/verify.js +1 -1
- package/src/utilities/element.js +83 -26
- package/src/utilities/json.js +1 -1
- package/src/utilities/string.js +7 -29
- package/src/utilities/substitutions.js +19 -30
- package/lib/element/substitutions.js +0 -225
- package/src/element/substitutions.js +0 -84
package/src/process/verify.js
CHANGED
|
@@ -295,8 +295,8 @@ class ConbinatorPass extends SimplePass {
|
|
|
295
295
|
let success = false;
|
|
296
296
|
|
|
297
297
|
const statement = statementFromStatementNode(statementNode, context),
|
|
298
|
-
assignments = null,
|
|
299
298
|
stated = false,
|
|
299
|
+
assignments = null,
|
|
300
300
|
statementValidates = statement.validate(assignments, stated, context);
|
|
301
301
|
|
|
302
302
|
if (statementValidates) {
|
package/src/utilities/element.js
CHANGED
|
@@ -7,6 +7,7 @@ import { baseTypeFromNothing } from "../utilities/type";
|
|
|
7
7
|
import { instantiateReference } from "../process/instantiate";
|
|
8
8
|
import { findMetaTypeByMetaTypeName } from "../metaTypes";
|
|
9
9
|
import { equivalenceStringFromTerms,
|
|
10
|
+
typeStringFromNominalTypeName,
|
|
10
11
|
rulsStringFromLabelsPremisesAndConclusion,
|
|
11
12
|
sectionStringFromHypothesesTopLevelAssertion,
|
|
12
13
|
subproofStringFromSuppositionsAndSubDerivation,
|
|
@@ -23,16 +24,15 @@ export function typeFromTypeNode(typeNode, context) {
|
|
|
23
24
|
type = baseType; ///
|
|
24
25
|
} else {
|
|
25
26
|
const { Type } = elements,
|
|
26
|
-
typeName = typeNode.getTypeName(),
|
|
27
|
-
typePrefixName = typeNode.getTypePrefixName(),
|
|
28
|
-
nominalTypeName = typeNode.getNominalTypeName(),
|
|
29
|
-
string = nominalTypeName, ///
|
|
30
27
|
node = typeNode, ///
|
|
31
|
-
name =
|
|
32
|
-
prefixName =
|
|
33
|
-
superTypes =
|
|
34
|
-
properties =
|
|
35
|
-
provisional =
|
|
28
|
+
name = nameFromTypeNode(typeNode, context),
|
|
29
|
+
prefixName = prefixNameFromTypeNode(typeNode, context),
|
|
30
|
+
superTypes = superTypesFromTypeNode(typeNode, context),
|
|
31
|
+
properties = propertiesFromTypeNode(typeNode, context),
|
|
32
|
+
provisional = provisionalFromTypeNode(typeNode, context),
|
|
33
|
+
nominalTypeName = nominalTypeNameFromTypeNode(typeNode, context),
|
|
34
|
+
typeString = typeStringFromNominalTypeName(nominalTypeName),
|
|
35
|
+
string = typeString; ///
|
|
36
36
|
|
|
37
37
|
type = new Type(context, string, node, name, prefixName, superTypes, properties, provisional);
|
|
38
38
|
}
|
|
@@ -195,7 +195,7 @@ export function theoremFromTheoremNode(theoremNode, context) {
|
|
|
195
195
|
|
|
196
196
|
export function metaTypeFromMetaTypeNode(metaTypeNode, context) {
|
|
197
197
|
const metaTypeName = metaTypeNode.getMetaTypeName(),
|
|
198
|
-
metaType = findMetaTypeByMetaTypeName(metaTypeName);
|
|
198
|
+
metaType = context.findMetaTypeByMetaTypeName(metaTypeName);
|
|
199
199
|
|
|
200
200
|
return metaType;
|
|
201
201
|
}
|
|
@@ -236,21 +236,15 @@ export function subproofFromSubproofNode(subproofNode, context) {
|
|
|
236
236
|
return subproof;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
export function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
string = context.nodeAsString(node),
|
|
247
|
-
leftTerm = leftTermFromEqualityNode(equalityNode, context),
|
|
248
|
-
rightTerm = rightTermFromEqualityNode(equalityNode, context);
|
|
249
|
-
|
|
250
|
-
equality = new Equality(context, string, node, leftTerm, rightTerm);
|
|
251
|
-
}
|
|
239
|
+
export function equalityFromEqualityNode(equalityNode, context) {
|
|
240
|
+
const { Equality } = elements,
|
|
241
|
+
node = equalityNode, ///
|
|
242
|
+
string = context.nodeAsString(node),
|
|
243
|
+
leftTerm = leftTermFromEqualityNode(equalityNode, context),
|
|
244
|
+
rightTerm = rightTermFromEqualityNode(equalityNode, context),
|
|
245
|
+
subproof = new Equality(context, string, node, leftTerm, rightTerm);
|
|
252
246
|
|
|
253
|
-
return
|
|
247
|
+
return subproof;
|
|
254
248
|
}
|
|
255
249
|
|
|
256
250
|
export function deductionFromDeductionNode(deductionNode, context) {
|
|
@@ -713,6 +707,13 @@ export function metavariableDeclarationFromMetavariableDeclarationNode(metavaria
|
|
|
713
707
|
return metavariableDeclaration;
|
|
714
708
|
}
|
|
715
709
|
|
|
710
|
+
export function nameFromTypeNode(typeNode, context) {
|
|
711
|
+
const typeName = typeNode.getTypeName(),
|
|
712
|
+
name = typeName; ///
|
|
713
|
+
|
|
714
|
+
return name;
|
|
715
|
+
}
|
|
716
|
+
|
|
716
717
|
export function typeFromTermNode(termNode, context) {
|
|
717
718
|
const type = null;
|
|
718
719
|
|
|
@@ -793,6 +794,25 @@ export function referenceFromStepNode(stepNode, context) {
|
|
|
793
794
|
return reference;
|
|
794
795
|
}
|
|
795
796
|
|
|
797
|
+
export function superTypesFromTypeNode(typeNode, context) {
|
|
798
|
+
const superTypes = null;
|
|
799
|
+
|
|
800
|
+
return superTypes;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
export function propertiesFromTypeNode(typeNode, context) {
|
|
804
|
+
const properties = null;
|
|
805
|
+
|
|
806
|
+
return properties;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export function prefixNameFromTypeNode(typeNode, context) {
|
|
810
|
+
const typePrefixName = typeNode.getTypePrefixName(),
|
|
811
|
+
prefixName = typePrefixName; ///
|
|
812
|
+
|
|
813
|
+
return prefixName;
|
|
814
|
+
}
|
|
815
|
+
|
|
796
816
|
export function conclusionFromRuleNode(ruleNode, context) {
|
|
797
817
|
const conclusionNode = ruleNode.getConclusionNode(),
|
|
798
818
|
conclusion = conclusionFromConclusionNode(conclusionNode, context);
|
|
@@ -833,6 +853,12 @@ export function derivationFromProofNode(proofNode, context) {
|
|
|
833
853
|
return derivation;
|
|
834
854
|
}
|
|
835
855
|
|
|
856
|
+
export function provisionalFromTypeNode(typeNode, context) {
|
|
857
|
+
const provisional = null;
|
|
858
|
+
|
|
859
|
+
return provisional;
|
|
860
|
+
}
|
|
861
|
+
|
|
836
862
|
export function termFromConstructorNode(ocnstructorNode, context) {
|
|
837
863
|
const termNode = ocnstructorNode.getTermNode(),
|
|
838
864
|
term = termFromTermNode(termNode, context);
|
|
@@ -859,6 +885,13 @@ export function statementFromPremiseNode(premiseNode, context) {
|
|
|
859
885
|
return statement;
|
|
860
886
|
}
|
|
861
887
|
|
|
888
|
+
export function leftTermFromEqualityNode(equalityNode, context) {
|
|
889
|
+
const leftTermNode = equalityNode.getLeftTermNode(),
|
|
890
|
+
leftTerm = termFromTermNode(leftTermNode, context);
|
|
891
|
+
|
|
892
|
+
return leftTerm;
|
|
893
|
+
}
|
|
894
|
+
|
|
862
895
|
export function termsFromEquivalenceNode(equivalenceNode, context) {
|
|
863
896
|
const termNodes = equivalenceNode.getTermNodes(),
|
|
864
897
|
terms = termsFromTermNodes(termNodes, context);
|
|
@@ -897,6 +930,25 @@ export function conjectureFromSectionNode(sectionNode, context) {
|
|
|
897
930
|
return conjecture;
|
|
898
931
|
}
|
|
899
932
|
|
|
933
|
+
export function rightTermFromEqualityNode(equalityNode, context) {
|
|
934
|
+
const rightTermNode = equalityNode.getRightTermNode(),
|
|
935
|
+
rightTerm = termFromTermNode(rightTermNode, context);
|
|
936
|
+
|
|
937
|
+
return rightTerm;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export function equalityFromStatementNode(statementNode, context) {
|
|
941
|
+
let equality = null;
|
|
942
|
+
|
|
943
|
+
const equalityNode = statementNode.getEqualityNode();
|
|
944
|
+
|
|
945
|
+
if (equalityNode !== null) {
|
|
946
|
+
equality = equalityFromEqualityNode(equalityNode, context);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
return equality;
|
|
950
|
+
}
|
|
951
|
+
|
|
900
952
|
export function termFromTypeAssertionNode(typeAssertionNode, context) {
|
|
901
953
|
const termNode = typeAssertionNode.getTermNode(),
|
|
902
954
|
term = termFromTermNode(termNode, context);
|
|
@@ -956,6 +1008,12 @@ export function stepFromStepOrSubproofNode(stepOrSubproofNode, context) {
|
|
|
956
1008
|
return step;
|
|
957
1009
|
}
|
|
958
1010
|
|
|
1011
|
+
export function nominalTypeNameFromTypeNode(typeNode, context) {
|
|
1012
|
+
const nominalTypeName = typeNode.getNominalTypeName();
|
|
1013
|
+
|
|
1014
|
+
return nominalTypeName;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
959
1017
|
export function assumptionFromJudgementNode(judgementNode, context) {
|
|
960
1018
|
const assumptionNode = judgementNode.getAssumptionNode(),
|
|
961
1019
|
assumption = assumptionFromAssumptionNode(assumptionNode, context);
|
|
@@ -1543,7 +1601,7 @@ export function termSubstitutionFromStatementSubstitutionNode(statementSubstitut
|
|
|
1543
1601
|
const termSubstitutionNode = statementSubstitutionNode.getTermSubstitutionNode();
|
|
1544
1602
|
|
|
1545
1603
|
if (termSubstitutionNode !== null) {
|
|
1546
|
-
termSubstitution =
|
|
1604
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
1547
1605
|
}
|
|
1548
1606
|
|
|
1549
1607
|
return termSubstitution;
|
|
@@ -1676,4 +1734,3 @@ export function stepsOrSubproofsFromSubDerivationNode(subDerivationNode, context
|
|
|
1676
1734
|
|
|
1677
1735
|
return stepsOrSubproofs;
|
|
1678
1736
|
}
|
|
1679
|
-
|
package/src/utilities/json.js
CHANGED
package/src/utilities/string.js
CHANGED
|
@@ -16,20 +16,6 @@ export function termsStringFromTerms(terms) {
|
|
|
16
16
|
return termsString;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function framesStringFromFrames(frames) {
|
|
20
|
-
const framesString = frames.reduce((framesString, frame) => {
|
|
21
|
-
const frameString = frame.getString();
|
|
22
|
-
|
|
23
|
-
framesString = (framesString !== null) ?
|
|
24
|
-
`${framesString}, ${frameString}` :
|
|
25
|
-
frameString;
|
|
26
|
-
|
|
27
|
-
return framesString;
|
|
28
|
-
}, null);
|
|
29
|
-
|
|
30
|
-
return framesString;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
19
|
export function labelsStringFromLabels(labels) {
|
|
34
20
|
const labelsString = labels.reduce((labelsString, label) => {
|
|
35
21
|
const labelString = label.getString();
|
|
@@ -131,20 +117,6 @@ export function suppositionsStringFromSuppositions(suppositions) {
|
|
|
131
117
|
return suppositionsString;
|
|
132
118
|
}
|
|
133
119
|
|
|
134
|
-
export function substitutionsStringFromSubstitutions(substitutions) {
|
|
135
|
-
const substitutionsString = substitutions.reduce((substitutionsString, substitution) => {
|
|
136
|
-
const substitutionString = substitution.getString();
|
|
137
|
-
|
|
138
|
-
substitutionsString = (substitutionsString === null) ?
|
|
139
|
-
substitutionString : ///
|
|
140
|
-
`${substitutionsString}, ${substitutionString}`;
|
|
141
|
-
|
|
142
|
-
return substitutionsString;
|
|
143
|
-
}, null);
|
|
144
|
-
|
|
145
|
-
return substitutionsString;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
120
|
export function signatureStringFromTerms(terms) {
|
|
149
121
|
const termsString = termsStringFromTerms(terms),
|
|
150
122
|
signatureString = `[${termsString}]`;
|
|
@@ -154,11 +126,17 @@ export function signatureStringFromTerms(terms) {
|
|
|
154
126
|
|
|
155
127
|
export function equivalenceStringFromTerms(terms) {
|
|
156
128
|
const termsString = termsStringFromTerms(terms),
|
|
157
|
-
equivalenceString = termsString
|
|
129
|
+
equivalenceString = `[${termsString}]`;
|
|
158
130
|
|
|
159
131
|
return equivalenceString;
|
|
160
132
|
}
|
|
161
133
|
|
|
134
|
+
export function typeStringFromNominalTypeName(nominalTypeName) {
|
|
135
|
+
const typeString = nominalTypeName; ///
|
|
136
|
+
|
|
137
|
+
return typeString;
|
|
138
|
+
}
|
|
139
|
+
|
|
162
140
|
export function termSubstitutionStringFromTermAndVariable(term, variable) {
|
|
163
141
|
const termString = term.getString(),
|
|
164
142
|
variableString = variable.getString(),
|
|
@@ -13,17 +13,13 @@ export function termFromTermAndSubstitutions(term, generalContext, specificConte
|
|
|
13
13
|
|
|
14
14
|
if (termSingular) {
|
|
15
15
|
const variableIdentifier = termNode.getVariableIdentifier(),
|
|
16
|
-
|
|
16
|
+
substitution = specificContext.findSubstitutionByVariableIdentifier(variableIdentifier);
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
18
|
+
if (substitution !== null) {
|
|
19
|
+
const termSubstitution = substitution, ///
|
|
20
|
+
replacementTerm = termSubstitution.getReplacementTerm();
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
const termSubstitution = substitution, ///
|
|
23
|
-
replacementTerm = termSubstitution.getReplacementTerm();
|
|
24
|
-
|
|
25
|
-
term = replacementTerm; ///
|
|
26
|
-
}
|
|
22
|
+
term = replacementTerm; ///
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
}
|
|
@@ -40,17 +36,13 @@ export function frameFromFrameAndSubstitutions(frame, generalContext, specificCo
|
|
|
40
36
|
|
|
41
37
|
if (frameSingular) {
|
|
42
38
|
const metavariableName = frameNode.getMetavariableName(),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (metavariable !== null) {
|
|
46
|
-
const substitution = specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
39
|
+
substitution = specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
if (substitution !== null) {
|
|
42
|
+
const frameSubstitution = substitution, ///
|
|
43
|
+
replacementFrame = frameSubstitution.getReplacementFrame();
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
}
|
|
45
|
+
frame = replacementFrame; ///
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
48
|
}
|
|
@@ -86,20 +78,17 @@ export function statementFromStatementAndSubstitutions(statement, generalContext
|
|
|
86
78
|
specificContext = context; ///
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
const metavariableName = statementNode.getMetavariableName()
|
|
90
|
-
metavariable = generalContext.findMetavariableByMetavariableName(metavariableName);
|
|
81
|
+
const metavariableName = statementNode.getMetavariableName();
|
|
91
82
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
specificContext.
|
|
95
|
-
specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
83
|
+
substitution = (substitution !== null) ?
|
|
84
|
+
specificContext.findSubstitutionByMetavariableNameAndSubstitution(metavariableName, substitution) :
|
|
85
|
+
specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
if (substitution !== null) {
|
|
88
|
+
const statementSubstitution = substitution, ///
|
|
89
|
+
replacementStatement = statementSubstitution.getReplacementStatement();
|
|
100
90
|
|
|
101
|
-
|
|
102
|
-
}
|
|
91
|
+
statement = replacementStatement; ///
|
|
103
92
|
}
|
|
104
93
|
}
|
|
105
94
|
}
|
|
@@ -119,7 +108,7 @@ export function metavariableNamesFromSubstitutions(substitutions) {
|
|
|
119
108
|
});
|
|
120
109
|
|
|
121
110
|
compress(metavariableNames, (metavariableNameA, metavariableNameB) => {
|
|
122
|
-
if (
|
|
111
|
+
if (metavariableNameA !== metavariableNameB) {
|
|
123
112
|
return true;
|
|
124
113
|
}
|
|
125
114
|
});
|
|
@@ -1,225 +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 _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _occamlanguages = require("occam-languages");
|
|
12
|
-
var _necessary = require("necessary");
|
|
13
|
-
var _elements = require("../elements");
|
|
14
|
-
var _constants = require("../constants");
|
|
15
|
-
var _string = require("../utilities/string");
|
|
16
|
-
function _assert_this_initialized(self) {
|
|
17
|
-
if (self === void 0) {
|
|
18
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
19
|
-
}
|
|
20
|
-
return self;
|
|
21
|
-
}
|
|
22
|
-
function _call_super(_this, derived, args) {
|
|
23
|
-
derived = _get_prototype_of(derived);
|
|
24
|
-
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
25
|
-
}
|
|
26
|
-
function _class_call_check(instance, Constructor) {
|
|
27
|
-
if (!(instance instanceof Constructor)) {
|
|
28
|
-
throw new TypeError("Cannot call a class as a function");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function _construct(Parent, args, Class) {
|
|
32
|
-
if (_is_native_reflect_construct()) {
|
|
33
|
-
_construct = Reflect.construct;
|
|
34
|
-
} else {
|
|
35
|
-
_construct = function construct(Parent, args, Class) {
|
|
36
|
-
var a = [
|
|
37
|
-
null
|
|
38
|
-
];
|
|
39
|
-
a.push.apply(a, args);
|
|
40
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
41
|
-
var instance = new Constructor();
|
|
42
|
-
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
43
|
-
return instance;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return _construct.apply(null, arguments);
|
|
47
|
-
}
|
|
48
|
-
function _defineProperties(target, props) {
|
|
49
|
-
for(var i = 0; i < props.length; i++){
|
|
50
|
-
var descriptor = props[i];
|
|
51
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
52
|
-
descriptor.configurable = true;
|
|
53
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
54
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
58
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
59
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
60
|
-
return Constructor;
|
|
61
|
-
}
|
|
62
|
-
function _define_property(obj, key, value) {
|
|
63
|
-
if (key in obj) {
|
|
64
|
-
Object.defineProperty(obj, key, {
|
|
65
|
-
value: value,
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
obj[key] = value;
|
|
72
|
-
}
|
|
73
|
-
return obj;
|
|
74
|
-
}
|
|
75
|
-
function _get_prototype_of(o) {
|
|
76
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
77
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
78
|
-
};
|
|
79
|
-
return _get_prototype_of(o);
|
|
80
|
-
}
|
|
81
|
-
function _inherits(subClass, superClass) {
|
|
82
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
83
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
84
|
-
}
|
|
85
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
86
|
-
constructor: {
|
|
87
|
-
value: subClass,
|
|
88
|
-
writable: true,
|
|
89
|
-
configurable: true
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
93
|
-
}
|
|
94
|
-
function _is_native_function(fn) {
|
|
95
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
96
|
-
}
|
|
97
|
-
function _possible_constructor_return(self, call) {
|
|
98
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
99
|
-
return call;
|
|
100
|
-
}
|
|
101
|
-
return _assert_this_initialized(self);
|
|
102
|
-
}
|
|
103
|
-
function _set_prototype_of(o, p) {
|
|
104
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
105
|
-
o.__proto__ = p;
|
|
106
|
-
return o;
|
|
107
|
-
};
|
|
108
|
-
return _set_prototype_of(o, p);
|
|
109
|
-
}
|
|
110
|
-
function _type_of(obj) {
|
|
111
|
-
"@swc/helpers - typeof";
|
|
112
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
113
|
-
}
|
|
114
|
-
function _wrap_native_super(Class) {
|
|
115
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
116
|
-
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
117
|
-
if (Class === null || !_is_native_function(Class)) return Class;
|
|
118
|
-
if (typeof Class !== "function") {
|
|
119
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
120
|
-
}
|
|
121
|
-
if (typeof _cache !== "undefined") {
|
|
122
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
123
|
-
_cache.set(Class, Wrapper);
|
|
124
|
-
}
|
|
125
|
-
function Wrapper() {
|
|
126
|
-
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
127
|
-
}
|
|
128
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
129
|
-
constructor: {
|
|
130
|
-
value: Wrapper,
|
|
131
|
-
enumerable: false,
|
|
132
|
-
writable: true,
|
|
133
|
-
configurable: true
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return _set_prototype_of(Wrapper, Class);
|
|
137
|
-
};
|
|
138
|
-
return _wrap_native_super(Class);
|
|
139
|
-
}
|
|
140
|
-
function _is_native_reflect_construct() {
|
|
141
|
-
try {
|
|
142
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
143
|
-
} catch (_) {}
|
|
144
|
-
return (_is_native_reflect_construct = function() {
|
|
145
|
-
return !!result;
|
|
146
|
-
})();
|
|
147
|
-
}
|
|
148
|
-
var _Substitutions;
|
|
149
|
-
var first = _necessary.arrayUtilities.first, extract = _necessary.arrayUtilities.extract, correlate = _necessary.arrayUtilities.correlate;
|
|
150
|
-
var _default = (0, _elements.define)((_Substitutions = /*#__PURE__*/ function(Element) {
|
|
151
|
-
_inherits(Substitutions, Element);
|
|
152
|
-
function Substitutions() {
|
|
153
|
-
_class_call_check(this, Substitutions);
|
|
154
|
-
return _call_super(this, Substitutions, arguments);
|
|
155
|
-
}
|
|
156
|
-
_create_class(Substitutions, [
|
|
157
|
-
{
|
|
158
|
-
key: "getNonTrivialLength",
|
|
159
|
-
value: function getNonTrivialLength() {
|
|
160
|
-
var nonTrivialLength = this.reduceSubstitution(function(nonTrivialLength, substitution) {
|
|
161
|
-
var substitutionTrivial = substitution.isTrivial();
|
|
162
|
-
if (!substitutionTrivial) {
|
|
163
|
-
nonTrivialLength += 1;
|
|
164
|
-
}
|
|
165
|
-
return nonTrivialLength;
|
|
166
|
-
}, 0);
|
|
167
|
-
return nonTrivialLength;
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
key: "getFirstSubstitution",
|
|
172
|
-
value: function getFirstSubstitution() {
|
|
173
|
-
var firstSubstitution = null;
|
|
174
|
-
var length = this.getLength();
|
|
175
|
-
if (length > 0) {
|
|
176
|
-
firstSubstitution = first(this.array);
|
|
177
|
-
}
|
|
178
|
-
return firstSubstitution;
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
key: "extractSubstitution",
|
|
183
|
-
value: function extractSubstitution(callbcak) {
|
|
184
|
-
return extract(this.array, callbcak);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
key: "correlateSubstitutions",
|
|
189
|
-
value: function correlateSubstitutions(substitutions) {
|
|
190
|
-
var array = substitutions.getArray(), arrayA = array, arrayB = this.array, correlates = correlate(arrayA, arrayB, function(substitutionA, substitutionB) {
|
|
191
|
-
var substitutionAIsEQualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
192
|
-
if (substitutionAIsEQualToSubstitutionB) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
return correlates;
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
key: "asString",
|
|
201
|
-
value: function asString() {
|
|
202
|
-
var string;
|
|
203
|
-
var length = this.getLength();
|
|
204
|
-
if (length === 0) {
|
|
205
|
-
string = _constants.EMPTY_STRING;
|
|
206
|
-
} else {
|
|
207
|
-
var substitutions = this.array, substitutionsString = (0, _string.substitutionsStringFromSubstitutions)(substitutions);
|
|
208
|
-
string = substitutionsString; ///
|
|
209
|
-
}
|
|
210
|
-
return string;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
], [
|
|
214
|
-
{
|
|
215
|
-
key: "fromNothing",
|
|
216
|
-
value: function fromNothing(context) {
|
|
217
|
-
var node = null, string = _constants.EMPTY_STRING, array = [], savedArray = [], substitutions = new Substitutions(context, string, node, array, savedArray);
|
|
218
|
-
return substitutions;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
]);
|
|
222
|
-
return Substitutions;
|
|
223
|
-
}(_wrap_native_super(_occamlanguages.Element)), _define_property(_Substitutions, "name", "Substitutions"), _Substitutions));
|
|
224
|
-
|
|
225
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9lbGVtZW50L3N1YnN0aXR1dGlvbnMuanMiXSwic291cmNlc0NvbnRlbnQiOlsiXCJ1c2Ugc3RyaWN0XCI7XG5cbmltcG9ydCB7IEVsZW1lbnQgfSBmcm9tIFwib2NjYW0tbGFuZ3VhZ2VzXCI7XG5pbXBvcnQgeyBhcnJheVV0aWxpdGllcyB9IGZyb20gXCJuZWNlc3NhcnlcIjtcblxuaW1wb3J0IHsgZGVmaW5lIH0gZnJvbSBcIi4uL2VsZW1lbnRzXCI7XG5pbXBvcnQgeyBFTVBUWV9TVFJJTkcgfSBmcm9tIFwiLi4vY29uc3RhbnRzXCI7XG5pbXBvcnQgeyBzdWJzdGl0dXRpb25zU3RyaW5nRnJvbVN1YnN0aXR1dGlvbnMgfSBmcm9tIFwiLi4vdXRpbGl0aWVzL3N0cmluZ1wiO1xuXG5jb25zdCB7IGZpcnN0LCBleHRyYWN0LCBjb3JyZWxhdGUgfSA9IGFycmF5VXRpbGl0aWVzO1xuXG5leHBvcnQgZGVmYXVsdCBkZWZpbmUoY2xhc3MgU3Vic3RpdHV0aW9ucyBleHRlbmRzIEVsZW1lbnQge1xuICBnZXROb25Ucml2aWFsTGVuZ3RoKCkge1xuICAgIGNvbnN0IG5vblRyaXZpYWxMZW5ndGggPSB0aGlzLnJlZHVjZVN1YnN0aXR1dGlvbigobm9uVHJpdmlhbExlbmd0aCwgc3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FTTixPQUNUTyxTQUFTLElBQUksQ0FBQ1AsS0FBSyxFQUNuQlEsYUFBYXJCLFVBQVVtQixRQUFRQyxRQUFRLFNBQUNFLGVBQWVDO29CQUNyRCxJQUFNQyxzQ0FBc0NGLGNBQWNHLFNBQVMsQ0FBQ0Y7b0JBRXBFLElBQUlDLHFDQUFxQzt3QkFDdkMsT0FBTztvQkFDVDtnQkFDRjtnQkFFTixPQUFPSDtZQUNUOzs7WUFFQUssS0FBQUE7bUJBQUFBLFNBQUFBO2dCQUNFLElBQUlDO2dCQUVKLElBQU1oQixTQUFTLElBQUksQ0FBQ0MsU0FBUztnQkFFN0IsSUFBSUQsV0FBVyxHQUFHO29CQUNoQmdCLFNBQVNDLHVCQUFZO2dCQUN2QixPQUFPO29CQUNMLElBQU1YLGdCQUFnQixJQUFJLENBQUNKLEtBQUssRUFDMUJnQixzQkFBc0JDLElBQUFBLDRDQUFvQyxFQUFDYjtvQkFFakVVLFNBQVNFLHFCQUFxQixHQUFHO2dCQUNuQztnQkFFQSxPQUFPRjtZQUNUOzs7O1lBSU9JLEtBQUFBO21CQUFQLFNBQU9BLFlBQVlDLE9BQU87Z0JBQ3hCLElBQU1DLE9BQU8sTUFDUE4sU0FBU0MsdUJBQVksRUFDckJmLFFBQVEsRUFBRSxFQUNWcUIsYUFBYSxFQUFFLEVBQ2ZqQixnQkFBZ0IsSUFBSWYsY0FBYzhCLFNBQVNMLFFBQVFNLE1BQU1wQixPQUFPcUI7Z0JBRXRFLE9BQU9qQjtZQUNUOzs7O3FCQXZFZ0RrQix1QkFBTyxJQTZEdkQsaUNBQU9DLFFBQU8ifQ==
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { Element } from "occam-languages";
|
|
4
|
-
import { arrayUtilities } from "necessary";
|
|
5
|
-
|
|
6
|
-
import { define } from "../elements";
|
|
7
|
-
import { EMPTY_STRING } from "../constants";
|
|
8
|
-
import { substitutionsStringFromSubstitutions } from "../utilities/string";
|
|
9
|
-
|
|
10
|
-
const { first, extract, correlate } = arrayUtilities;
|
|
11
|
-
|
|
12
|
-
export default define(class Substitutions extends Element {
|
|
13
|
-
getNonTrivialLength() {
|
|
14
|
-
const nonTrivialLength = this.reduceSubstitution((nonTrivialLength, substitution) => {
|
|
15
|
-
const substitutionTrivial = substitution.isTrivial();
|
|
16
|
-
|
|
17
|
-
if (!substitutionTrivial) {
|
|
18
|
-
nonTrivialLength += 1;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return nonTrivialLength;
|
|
22
|
-
}, 0);
|
|
23
|
-
|
|
24
|
-
return nonTrivialLength;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getFirstSubstitution() {
|
|
28
|
-
let firstSubstitution = null;
|
|
29
|
-
|
|
30
|
-
const length = this.getLength();
|
|
31
|
-
|
|
32
|
-
if (length > 0) {
|
|
33
|
-
firstSubstitution = first(this.array);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return firstSubstitution;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
extractSubstitution(callbcak) { return extract(this.array, callbcak); }
|
|
40
|
-
|
|
41
|
-
correlateSubstitutions(substitutions) {
|
|
42
|
-
const array = substitutions.getArray(),
|
|
43
|
-
arrayA = array, ///
|
|
44
|
-
arrayB = this.array, ///
|
|
45
|
-
correlates = correlate(arrayA, arrayB, (substitutionA, substitutionB) => {
|
|
46
|
-
const substitutionAIsEQualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
47
|
-
|
|
48
|
-
if (substitutionAIsEQualToSubstitutionB) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return correlates;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
asString() {
|
|
57
|
-
let string;
|
|
58
|
-
|
|
59
|
-
const length = this.getLength();
|
|
60
|
-
|
|
61
|
-
if (length === 0) {
|
|
62
|
-
string = EMPTY_STRING;
|
|
63
|
-
} else {
|
|
64
|
-
const substitutions = this.array, ///
|
|
65
|
-
substitutionsString = substitutionsStringFromSubstitutions(substitutions);
|
|
66
|
-
|
|
67
|
-
string = substitutionsString; ///
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static name = "Substitutions";
|
|
74
|
-
|
|
75
|
-
static fromNothing(context) {
|
|
76
|
-
const node = null,
|
|
77
|
-
string = EMPTY_STRING,
|
|
78
|
-
array = [],
|
|
79
|
-
savedArray = [],
|
|
80
|
-
substitutions = new Substitutions(context, string, node, array, savedArray);
|
|
81
|
-
|
|
82
|
-
return substitutions;
|
|
83
|
-
}
|
|
84
|
-
});
|