Bill Page wrote:
>
> Waldek,
>
> I am sorry that my explanation was so brief.
>
> In your patch:
>
> Modified: trunk/src/algebra/op.spad.pamphlet
> ===================================================================
> --- trunk/src/algebra/op.spad.pamphlet 2009-05-16 00:07:58 UTC (rev 614)
> +++ trunk/src/algebra/op.spad.pamphlet 2009-05-16 17:18:14 UTC (rev 615)
> @@ -202,7 +202,7 @@
> ++ This package exports functions to set some commonly used properties
> ++ of operators, including properties which contain functions.
> ++ Keywords: operator.
> -BasicOperatorFunctions1(A:SetCategory): Exports == Implementation where
> +BasicOperatorFunctions1(A : SetCategory): Exports == Implementation where
> OP ==> BasicOperator
>
> Exports ==> with
> @@ -233,11 +233,10 @@
> derivative : OP -> Union(List(List A -> A), "failed")
> ++ derivative(op) returns the value of the "%diff" property of
> ++ op if it has one, and "failed" otherwise.
> - if A has OrderedSet then
> - constantOperator: A -> OP
> + constantOperator: A -> OP
> ++ constantOperator(a) returns a nullary operator op
> ++ such that \spad{op()} always evaluate to \spad{a}.
> - constantOpIfCan : OP -> Union(A, "failed")
> + constantOpIfCan : OP -> Union(A, "failed")
> ++ constantOpIfCan(op) returns \spad{a} if op is the constant
> ++ nullary operator always returning \spad{a}, "failed" otherwise.
>
> You removed the conditional
>
> - if A has OrderedSet then
>
> Maybe you did not really intend to do this?
>
Well, I did not think long about the change. During switch to
'Comparable' I had trouble compiling previous version. And
requireing order to be able to work with constants did not
look right.
> But later in the code we see:
>
> if A has OrderedSet then
> cdisp : (OutputForm, List OutputForm) -> OutputForm
> csex : (InputForm, List InputForm) -> InputForm
> eqconst?: (OP, OP) -> Boolean
> ltconst?: (OP, OP) -> Boolean
> constOp : A -> OP
>
> opconst:OP :=
> comparison(equality(operator('constant, 0), eqconst?),
> ltconst?)
>
> cdisp(a, l) == a
> csex(a, l) == a
>
> eqconst?(a, b) ==
> (va := property(a, CONST)) case "failed" => not has?(b, CONST)
> ((vb := property(b, CONST)) case None) and
> ((va::None) pretend A) = ((vb::None) pretend A)
>
> ltconst?(a, b) ==
> (va := property(a, CONST)) case "failed" => has?(b, CONST)
> ((vb := property(b, CONST)) case None) and
> ((va::None) pretend A) < ((vb::None) pretend A)
>
> constOp a ==
> setProperty(display(copy opconst, (l1: List(OutputForm)):
> OutputForm +-> cdisp(a::OutputForm, l1)),
> CONST, a pretend None)
>
> constantOpIfCan op ==
> is?(op, 'constant) and
> ((u := property(op, CONST)) case None) => (u::None) pretend A
> "failed"
>
> if A has ConvertibleTo InputForm then
> constantOperator a == input(constOp a, (l1: List(InputForm)):
> InputForm +-> csex(convert a, l1))
> else
> constantOperator a == constOp a
> ------
>
> Notice the indentation. The problem that I had involved a case were
> 'constandOperator' was not defined. Looking at it now I think I see
> that the real was just the incorrect indentation above.
>
I am not sure what you mean. Yes, currently constantOperator is
defined only if A has OrderedSet. But fixing this is more work
than just changing indentation.
> This was something that came up while I was debugging something else
> and I found this and fixed it without taking very good notes. I wanted
> to be able to define a new type like this:
>
> Expression XDistributedPolynomial(Symbol,Integer)
>
> But 'Expression(R:Comparable)' so I modified 'FreeModuleCategory' as follows:
>
> wsp...@debian:~/fricas-src/src/algebra$ svn diff poly.spad.pamphlet
> Makefile.in
> Index: poly.spad.pamphlet
> ===================================================================
> --- poly.spad.pamphlet (revision 666)
> +++ poly.spad.pamphlet (working copy)
> @@ -80,6 +80,17 @@
> ++ \spad{coefficient(x,s)} returns the coefficient of the
> basis element s
> -- attributs
> if R has CommutativeRing then Module(R)
> + if R has Comparable then Comparable
> + add
> + if R has Comparable then
> + smaller?(p:%,q:%):Boolean ==
> + if leadingMonomial(p)=leadingMonomial(q) then
> + if leadingCoefficient(p)=leadingCoefficient(q) then
> + smaller?(reductum p, reductum q)
> + else
> + smaller?(leadingCoefficient(p),leadingCoefficient(q))
> + leadingMonomial(p)<leadingMonomial(q)
> +
>
> @
> \section{domain FM FreeModule}
> Index: Makefile.in
> ===================================================================
> --- Makefile.in (revision 666)
> +++ Makefile.in (working copy)
> @@ -319,10 +319,10 @@
> ATRIG BASTYPE BGAGG BRAGG BTAGG BTCAT CLAGG COMPCAT DIAGG \
> DIFEXT DIFRING DIOPS DIRPCAT DIVRING DPOLCAT DVARCAT ELAGG \
> ELEMFUN ELTAGG ES EUCDOM EVALAB FAMR FAXF FDIVCAT FEVALAB \
> - FFCAT FFIELDC FIELD FINAALG FINITE FINRALG FLAGG FLINEXP FPC FPS \
> - FRAMALG FRETRCT FRNAALG FSAGG FS GCDDOM GRALG GRMOD GROUP \
> - HOAGG HYPCAT IEVALAB INS INTDOM IXAGG KDAGG LALG LIECAT LNAGG \
> - LODOCAT LOGIC LSAGG LZSTAGG MATCAT MODULE MONAD MONADWU \
> + FFCAT FFIELDC FIELD FINAALG FINITE FINRALG FLAGG FLINEXP FMCAT \
> + FPC FPS FRAMALG FRETRCT FRNAALG FSAGG FS GCDDOM GRALG GRMOD \
> + GROUP HOAGG HYPCAT IEVALAB INS INTDOM IXAGG KDAGG LALG LIECAT \
> + LNAGG LODOCAT LOGIC LSAGG LZSTAGG MATCAT MODULE MONAD MONADWU \
> MONOGEN MONOID MTSCAT NAALG NARNG NASRING OC ORDRING ORDSET OREPCAT \
> PDRING PFECAT POLYCAT PSCAT PSETCAT QFCAT QUATCAT RADCAT \
> RCAGG RCFIELD RETRACT RING RMATCAT RNS RPOLCAT RRCC RSETCAT \
> wsp...@debian:~/fricas-src/src/algebra$
>
> to provide a default 'smaller?' operation inherited by the XPOLY domains.
>
That looks like good change.
> Testing revealed the 'constandOperator' problem. Then by changing:
>
> --- op.spad.pamphlet (revision 666)
> +++ op.spad.pamphlet (working copy)
> @@ -271,7 +271,7 @@
> derivative(op, [(l1: List(A)): A +-> f first l1]$List(List A -> A))
> error "Operator is not unary"
>
> - if A has OrderedSet then
> + if A has Comparable then
>
> I found the problem went away. We need at least Comparable in order to
> define 'ltconst?', 'opconst' and 'constOp'.
>
Yes, at least without deeper changes we need Comparable to define
constOp, and constOp is needed in some versions of Expression.
So I think we should do the change you propose.
BTW. I a bit surprised that you hit this trouble with
Expression XDistributedPolynomial(Symbol,Integer). Namely,
Expression XDistributedPolynomial(Symbol,Integer) is a Ring
and for rings expression code should not use constantOperator.
--
Waldek Hebisch
[email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---