diff options
author | Gabriel Dos Reis <gdr@axiomatics.org> | 2015-12-30 10:59:32 -0800 |
---|---|---|
committer | Gabriel Dos Reis <gdr@axiomatics.org> | 2015-12-30 10:59:32 -0800 |
commit | 853eb071dce89161c796d81b24eddd9e073687af (patch) | |
tree | 32087791713be9e19d9d895a647904a9fe5f1634 /src/algebra | |
parent | 93910b392982db0452864f30db17267e0f30ea41 (diff) | |
download | open-axiom-853eb071dce89161c796d81b24eddd9e073687af.tar.gz |
Use CoercibleTo category instances instead of ad-hoc hard-wired 'coerce: % -> T' signatures.
Diffstat (limited to 'src/algebra')
-rw-r--r-- | src/algebra/crfp.spad.pamphlet | 2 | ||||
-rw-r--r-- | src/algebra/forttyp.spad.pamphlet | 10 | ||||
-rw-r--r-- | src/algebra/modring.spad.pamphlet | 12 | ||||
-rw-r--r-- | src/algebra/permgrps.spad.pamphlet | 7 | ||||
-rw-r--r-- | src/algebra/pfr.spad.pamphlet | 6 | ||||
-rw-r--r-- | src/algebra/space.spad.pamphlet | 2 | ||||
-rw-r--r-- | src/algebra/tableau.spad.pamphlet | 4 | ||||
-rw-r--r-- | src/algebra/variable.spad.pamphlet | 2 | ||||
-rw-r--r-- | src/algebra/view2D.spad.pamphlet | 7 | ||||
-rw-r--r-- | src/algebra/xlpoly.spad.pamphlet | 36 |
10 files changed, 15 insertions, 73 deletions
diff --git a/src/algebra/crfp.spad.pamphlet b/src/algebra/crfp.spad.pamphlet index 9f61ed5d..7ba3af33 100644 --- a/src/algebra/crfp.spad.pamphlet +++ b/src/algebra/crfp.spad.pamphlet @@ -539,7 +539,7 @@ ComplexRootFindingPackage(R, UP): public == private where num : I := approxNthRoot(globalDigits * numer r ,n)$IntegerRoots(I) num/den -- the following doesn't compile - --R has coerce: % -> Fraction Integer => + --R has CoercibleTo Fraction Integer => -- q : Fraction Integer := coerce(r)@Fraction(Integer) -- den : I := approxNthRoot(globalDigits * denom q ,n)$IntegerRoots(I) -- num : I := approxNthRoot(globalDigits * numer q ,n)$IntegerRoots(I) diff --git a/src/algebra/forttyp.spad.pamphlet b/src/algebra/forttyp.spad.pamphlet index 77e05eed..d2cfdc81 100644 --- a/src/algebra/forttyp.spad.pamphlet +++ b/src/algebra/forttyp.spad.pamphlet @@ -26,7 +26,7 @@ ++ basic FORTRAN data types: REAL, INTEGER, COMPLEX, LOGICAL and CHARACTER FortranScalarType() : exports == implementation where - exports == CoercibleTo OutputForm with + exports == Join(CoercibleTo OutputForm,CoercibleTo Symbol,CoercibleTo SExpression) with coerce : String -> $ ++ coerce(s) transforms the string s into an element of ++ FortranScalarType provided s is one of "real", "double precision", @@ -38,10 +38,6 @@ FortranScalarType() : exports == implementation where ++ FortranScalarType provided s is one of real, complex,double precision, ++ logical, integer, character, REAL, COMPLEX, LOGICAL, ++ INTEGER, CHARACTER, DOUBLE PRECISION - coerce : $ -> Symbol - ++ coerce(x) returns the symbol associated with x - coerce : $ -> SExpression - ++ coerce(x) returns the s-expression associated with x real? : $ -> Boolean ++ real?(t) tests whether t is equivalent to the FORTRAN type REAL. double? : $ -> Boolean @@ -294,9 +290,7 @@ SymbolTable() : exports == implementation where L ==> List FSTU ==> Union(fst:FortranScalarType,void:"void") - exports ==> CoercibleTo OutputForm with - coerce : $ -> Table(Symbol,FortranType) - ++ coerce(x) returns a table view of x + exports ==> Join(CoercibleTo OutputForm,CoercibleTo Table(Symbol,FortranType)) with empty : () -> $ ++ empty() returns a new, empty symbol table declare! : (L Symbol,FortranType,$) -> FortranType diff --git a/src/algebra/modring.spad.pamphlet b/src/algebra/modring.spad.pamphlet index a802176d..19edbc9d 100644 --- a/src/algebra/modring.spad.pamphlet +++ b/src/algebra/modring.spad.pamphlet @@ -34,11 +34,9 @@ ModularRing(R,Mod,reduction:(R,Mod) -> R, R : CommutativeRing Mod : AbelianMonoid - C == Ring with + C == Join(Ring,CoercibleTo R) with modulus : % -> Mod ++ modulus(x) \undocumented - coerce : % -> R - ++ coerce(x) \undocumented reduce : (R,Mod) -> % ++ reduce(r,m) \undocumented exQuo : (%,%) -> Union(%,"failed") @@ -114,11 +112,9 @@ EuclideanModularRing(S,R,Mod,reduction:(R,Mod) -> R, R : UnivariatePolynomialCategory S Mod : AbelianMonoid - C == Join(EuclideanDomain, Eltable(R,R)) with + C == Join(EuclideanDomain, Eltable(R,R),CoercibleTo R) with modulus : % -> Mod ++ modulus(x) \undocumented - coerce : % -> R - ++ coerce(x) \undocumented reduce : (R,Mod) -> % ++ reduce(r,m) \undocumented exQuo : (%,%) -> Union(%,"failed") @@ -208,11 +204,9 @@ ModularField(R,Mod,reduction:(R,Mod) -> R, R : CommutativeRing Mod : AbelianMonoid - C == Field with + C == Join(Field,CoercibleTo R) with modulus : % -> Mod ++ modulus(x) \undocumented - coerce : % -> R - ++ coerce(x) \undocumented reduce : (R,Mod) -> % ++ reduce(r,m) \undocumented exQuo : (%,%) -> Union(%,"failed") diff --git a/src/algebra/permgrps.spad.pamphlet b/src/algebra/permgrps.spad.pamphlet index eaaaf376..39a9db79 100644 --- a/src/algebra/permgrps.spad.pamphlet +++ b/src/algebra/permgrps.spad.pamphlet @@ -54,10 +54,8 @@ PermutationGroup(S:SetCategory): public == private where REC3 ==> Record(elt:V NNI,lst:L NNI) REC4 ==> Record(bool:B,lst:L NNI) - public ==> SetCategory with + public ==> Join(SetCategory,HomotopicTo L PERM S) with - coerce : % -> L PERM S - ++ coerce(gp) returns the generators of the group {\em gp}. generators : % -> L PERM S ++ generators(gp) returns the generators of the group {\em gp}. elt : (%,NNI) -> PERM S @@ -84,9 +82,6 @@ PermutationGroup(S:SetCategory): public == private where ++ generators of the group {\em gp} in the original generators of ++ {\em gp}, represented by their indices in the list, given by ++ {\em generators}. - coerce : L PERM S -> % - ++ coerce(ls) coerces a list of permutations {\em ls} to the group - ++ generated by this list. permutationGroup : L PERM S -> % ++ permutationGroup(ls) coerces a list of permutations {\em ls} to ++ the group generated by this list. diff --git a/src/algebra/pfr.spad.pamphlet b/src/algebra/pfr.spad.pamphlet index a8de6b27..4faabd28 100644 --- a/src/algebra/pfr.spad.pamphlet +++ b/src/algebra/pfr.spad.pamphlet @@ -43,11 +43,7 @@ PartialFraction(R: EuclideanDomain): Cat == Capsule where FRR ==> Factored R SUPR ==> SparseUnivariatePolynomial R - Cat == Join(Field, Algebra R) with - coerce: % -> Fraction R - ++ coerce(p) sums up the components of the partial fraction and - ++ returns a single fraction. - + Cat == Join(Field, Algebra R,CoercibleTo Fraction R) with coerce: Fraction FRR -> % ++ coerce(f) takes a fraction with numerator and denominator in ++ factored form and creates a partial fraction. It is diff --git a/src/algebra/space.spad.pamphlet b/src/algebra/space.spad.pamphlet index 23d46039..61b7260d 100644 --- a/src/algebra/space.spad.pamphlet +++ b/src/algebra/space.spad.pamphlet @@ -287,8 +287,6 @@ ThreeSpaceCategory(R:Ring): Exports == Implementation where subspace : % -> SUBSPACE ++ subspace(s) returns the \spadtype{SubSpace} which holds all the point ++ information in the \spadtype{ThreeSpace}, s. - coerce : % -> O - ++ coerce(s) returns the \spadtype{ThreeSpace} s to Output format. @ \section{domain SPACE3 ThreeSpace} diff --git a/src/algebra/tableau.spad.pamphlet b/src/algebra/tableau.spad.pamphlet index a5432bec..a6177938 100644 --- a/src/algebra/tableau.spad.pamphlet +++ b/src/algebra/tableau.spad.pamphlet @@ -33,13 +33,11 @@ Tableau(S:SetCategory):Exports == Implementation where OUT ==> OutputForm V ==> Vector fm==>formMatrix$PrintableForm() - Exports ==> with + Exports ==> CoercibleTo OUT with tableau : L L S -> % ++ tableau(ll) converts a list of lists ll to a tableau. listOfLists : % -> L L S ++ listOfLists t converts a tableau t to a list of lists. - coerce : % -> OUT - ++ coerce(t) converts a tableau t to an output form. Implementation ==> add Rep := L L S diff --git a/src/algebra/variable.spad.pamphlet b/src/algebra/variable.spad.pamphlet index 1ae7899d..3489579f 100644 --- a/src/algebra/variable.spad.pamphlet +++ b/src/algebra/variable.spad.pamphlet @@ -46,8 +46,6 @@ OrderedVariableList(VariableList:List Symbol): ++ Description: ++ This domain implements variables Variable(sym:Symbol): Join(SetCategory, CoercibleTo Symbol) with - coerce : % -> Symbol - ++ coerce(x) returns the symbol variable: () -> Symbol ++ variable() returns the symbol == add diff --git a/src/algebra/view2D.spad.pamphlet b/src/algebra/view2D.spad.pamphlet index bdd63f5e..e3ac52c7 100644 --- a/src/algebra/view2D.spad.pamphlet +++ b/src/algebra/view2D.spad.pamphlet @@ -163,9 +163,6 @@ GraphImage (): Exports == Implementation where ++ \spadfun{pointSizeDefault}. The graph data is then sent to the ++ viewport manager where it waits to be included in a two-dimensional ++ viewport window. - coerce : $ -> E - ++ coerce(gi) returns the indicated graph, \spad{gi}, of domain - ++ \spadtype{GraphImage} as output of the domain \spadtype{OutputForm}. putColorInfo : (L L P,L PAL) -> L L P ++ putColorInfo(llp,lpal) takes a list of list of points, \spad{llp}, ++ and returns the points with their hue and shade components @@ -748,10 +745,6 @@ TwoDimensionalViewport ():Exports == Implementation where key : $ -> I ++ key(v) returns the process ID number of the given two-dimensional ++ viewport, v, which is of domain \spadtype{TwoDimensionalViewport}. - coerce : $ -> E - ++ coerce(v) returns the given two-dimensional viewport, v, which - ++ is of domain \spadtype{TwoDimensionalViewport} as output of - ++ the domain \spadtype{OutputForm}. Implementation ==> add diff --git a/src/algebra/xlpoly.spad.pamphlet b/src/algebra/xlpoly.spad.pamphlet index 6090799a..0ce1f1b0 100644 --- a/src/algebra/xlpoly.spad.pamphlet +++ b/src/algebra/xlpoly.spad.pamphlet @@ -35,12 +35,9 @@ Magma(VarSet:OrderedSet):Public == Private where WORD ==> OrderedFreeMonoid(VarSet) EX ==> OutputForm - Public == Join(OrderedSet,RetractableTo VarSet) with + Public == Join(OrderedSet,RetractableTo VarSet,CoercibleTo WORD) with * : ($,$) -> $ ++ \axiom{x*y} returns the tree \axiom{[x,y]}. - coerce : $ -> WORD - ++ \axiom{coerce(x)} returns the element of \axiomType{OrderedFreeMonoid}(VarSet) - ++ corresponding to \axiom{x} by removing parentheses. first : $ -> VarSet ++ \axiom{first(x)} returns the first entry of the tree \axiom{x}. left : $ -> $ @@ -204,7 +201,7 @@ LyndonWord(VarSet:OrderedSet):Public == Private where OF ==> OutputForm ARRAY1==> OneDimensionalArray - Public == Join(OrderedSet,RetractableTo VarSet) with + Public == Join(OrderedSet,RetractableTo VarSet,CoercibleTo OFMON,CoercibleTo Magma VarSet) with retractable? : $ -> Boolean ++ \axiom{retractable?(x)} tests if \axiom{x} is a tree with only one entry. left : $ -> $ @@ -218,12 +215,6 @@ LyndonWord(VarSet:OrderedSet):Public == Private where lexico : ($,$) -> Boolean ++ \axiom{lexico(x,y)} returns \axiom{true} iff \axiom{x} is smaller than ++ \axiom{y} w.r.t. the lexicographical ordering induced by \axiom{VarSet}. - coerce : $ -> OFMON - ++ \axiom{coerce(x)} returns the element of \axiomType{OrderedFreeMonoid}(VarSet) - ++ corresponding to \axiom{x}. - coerce : $ -> Magma VarSet - ++ \axiom{coerce(x)} returns the element of \axiomType{Magma}(VarSet) - ++ corresponding to \axiom{x}. factor : OFMON -> List $ ++ \axiom{factor(x)} returns the decreasing factorization into Lyndon words. lyndon?: OFMON -> Boolean @@ -395,16 +386,12 @@ FreeLieAlgebra(VarSet:OrderedSet, R:CommutativeRing) :Category == CatDef where RN ==> Fraction Integer LWORD ==> LyndonWord(VarSet) - CatDef == Join(LieAlgebra(R)) with + CatDef == Join(LieAlgebra(R),CoercibleTo XDPOLY,CoercibleTo XRPOLY) with coef : (XRPOLY , $) -> R ++ \axiom{coef(x,y)} returns the scalar product of \axiom{x} by \axiom{y}, ++ the set of words being regarded as an orthogonal basis. coerce : VarSet -> $ ++ \axiom{coerce(x)} returns \axiom{x} as a Lie polynomial. - coerce : $ -> XDPOLY - ++ \axiom{coerce(x)} returns \axiom{x} as distributed polynomial. - coerce : $ -> XRPOLY - ++ \axiom{coerce(x)} returns \axiom{x} as a recursive polynomial. degree : $ -> NonNegativeInteger ++ \axiom{degree(x)} returns the greatest length of a word in the support of \axiom{x}. --if R has Module(RN) then @@ -743,12 +730,9 @@ PoincareBirkhoffWittLyndonBasis(VarSet: OrderedSet): Public == Private where NNI ==> NonNegativeInteger EX ==> OutputForm - Public == Join(OrderedSet, RetractableTo LWORD) with + Public == Join(OrderedSet, RetractableTo LWORD,CoercibleTo WORD) with 1: constant -> % ++ \spad{1} returns the empty list. - coerce : $ -> WORD - ++ \spad{coerce([l1]*[l2]*...[ln])} returns the word \spad{l1*l2*...*ln}, - ++ where \spad{[l_i]} is the backeted form of the Lyndon word \spad{l_i}. coerce : VarSet -> $ ++ \spad{coerce(v)} return \spad{v} first : $ -> LWORD @@ -866,13 +850,9 @@ XPBWPolynomial(VarSet:OrderedSet,R:CommutativeRing): XDPcat == XDPdef where I ==> Integer RN ==> Fraction(Integer) - XDPcat == Join(XPolynomialsCat(VarSet,R), FreeModuleCat(R, BASIS)) with + XDPcat == Join(XPolynomialsCat(VarSet,R), FreeModuleCat(R, BASIS),CoercibleTo XDPOLY,CoercibleTo XRPOLY) with coerce : LPOLY -> $ ++ \axiom{coerce(p)} returns \axiom{p}. - coerce : $ -> XDPOLY - ++ \axiom{coerce(p)} returns \axiom{p} as a distributed polynomial. - coerce : $ -> XRPOLY - ++ \axiom{coerce(p)} returns \axiom{p} as a recursive polynomial. LiePolyIfCan: $ -> Union(LPOLY,"failed") ++ \axiom{LiePolyIfCan(p)} return \axiom{p} if \axiom{p} is a Lie polynomial. product : ($,$,NNI) -> $ -- produit tronque a l'ordre n @@ -1111,17 +1091,13 @@ LieExponentials(VarSet, R, Order): XDPcat == XDPdef where TERM1 ==> Record(k:LWORD, c:R) EQ ==> Equation(R) - XDPcat == Group with + XDPcat == Join(Group,CoercibleTo XDPOLY,CoercibleTo PBWPOLY) with exp : LPOLY -> $ ++ \axiom{exp(p)} returns the exponential of \axiom{p}. log : $ -> LPOLY ++ \axiom{log(p)} returns the logarithm of \axiom{p}. ListOfTerms : $ -> LTERMS ++ \axiom{ListOfTerms(p)} returns the internal representation of \axiom{p}. - coerce : $ -> XDPOLY - ++ \axiom{coerce(g)} returns the internal representation of \axiom{g}. - coerce : $ -> PBWPOLY - ++ \axiom{coerce(g)} returns the internal representation of \axiom{g}. mirror : $ -> $ ++ \axiom{mirror(g)} is the mirror of the internal representation of \axiom{g}. varList : $ -> List VarSet |