axiom-math
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-math] Re: [Axiom-mail] Lexicographic order


From: Martin Rubey
Subject: [Axiom-math] Re: [Axiom-mail] Lexicographic order
Date: Mon, 29 Aug 2005 10:28:13 +0200

Dear Jens,

Although I'm not 100% sure what lexorder? ought to do exactly, you might want
to notice the following:

the first matching type the interpreter finds for [x,y,z] is 

(13) -> [x,y,z]

   (13)  [x,y,z]
                                       Type: List OrderedVariableList [x,y,z]

which means that in sort([x,z,y]) you are using the order imposed by
OrderedVariableList [x,y,z], which is z < y < x.

So, although 

 >   > sort([x,y,z])
 >   [z,y,x]
 > 
 >   > sort([x,z,y])
 >   [y,z,x]

is surprising, it shouldn't be ;-) (<- please note the smiley !)

If you say

sort([x,z,y]::List Symbol), you will get the expected output.

I'm not totally sure how you can find out what ordering a domain uses. But very
likely, if its name doesn't contain something like "Ordered", it is the usual
lexicographic order.

Hope this helps,

Martin

Jens Axel Søgaard writes:
 > Hi all,
 > 
 > Is there a smarter way than the following to write lexorder?(p,q) ?
 > 
 > lexorder?(p,q) ==
 >    if empty?(variables(p))
 >    then return ~empty(variables(q))
 >    else
 >      vars := members(difference( set(variables( secret1*p + secret2*q)),
 >                                  set([secret1, secret2])))
 >      a := members(degree( p::DMP(vars,?) ))
 >      b := members(degree( q::DMP(vars,?) ))
 >      return negative?( first(a) - first(b) )
 > 
 > 
 > My first attempt used:
 > 
 >    vars := sort(members(union(set(variables(p), variables(q)))))
 > 
 > but was surprised to see
 > 
 >   > sort([x,y,z])
 >   [z,y,x]
 > 
 >   > sort([x,z,y])
 >   [y,z,x]
 > 
 > and thus made up the secret-trick in order to avoid sort.
 > 
 > -- 
 > Jens Axel Søgaard
 > 
 > 
 > 
 > _______________________________________________
 > Axiom-mail mailing list
 > address@hidden
 > http://lists.nongnu.org/mailman/listinfo/axiom-mail
 > 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]