|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
listOfTermsDear Tim,
if I naively do the below attached things, I get in FriCAS an export of listOfTerms, also )d op listOfTerms guids me to IDPC and )sh IDPC shows the export... Ciao BF. fauser@selfmaint-145:~> fricas Checking for foreign routines AXIOM="/usr/local/lib/fricas/target/i686-suse-linux" spad-lib="/usr/local/lib/fricas/target/i686-suse-linux/lib/libspad.so" foreign routines found openServer result 0 FriCAS (AXIOM fork) Computer Algebra System Version: FriCAS 2009-10-26 Timestamp: Sunday November 1, 2009 at 22:23:01 ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave FriCAS and return to shell. ----------------------------------------------------------------------------- (1) -> (1) -> )d op listOfTerms There is one exposed function called listOfTerms : [1] D -> List(Record(k: D3,c: D2)) from D if D has IDPC(D2,D3) and D2 has SETCAT and D3 has ORDSET There are 2 unexposed functions called listOfTerms : [1] LieExponentials(D2,D3,D4) -> List(Record(k: PoincareBirkhoffWittLyndonBasis(D2),c: D3)) from LieExponentials(D2,D3,D4) if D2 has ORDSET and D3 has Join(CommutativeRing,Module( Fraction(Integer))) and D4: PI [2] PoincareBirkhoffWittLyndonBasis(D2) -> List(LyndonWord(D2)) from PoincareBirkhoffWittLyndonBasis(D2) if D2 has ORDSET (1) -> )sh IDPC IndexedDirectProductCategory(A: SetCategory,S: OrderedSet) is a category constructor Abbreviation for IndexedDirectProductCategory is IDPC This constructor is exposed in this frame. ------------------------------- Operations -------------------------------- ?=? : (%,%) -> Boolean coerce : % -> OutputForm hash : % -> SingleInteger latex : % -> String leadingCoefficient : % -> A leadingSupport : % -> S map : ((A -> A),%) -> % monomial : (A,S) -> % reductum : % -> % ?~=? : (%,%) -> Boolean construct : List(Record(k: S,c: A)) -> % constructOrdered : List(Record(k: S,c: A)) -> % leadingTerm : % -> Record(k: S,c: A) listOfTerms : % -> List(Record(k: S,c: A)) -- % PD Dr Bertfried Fauser % Research Fellow, School of Computer Science, Univ. of Birmingham % Honorary Associate, University of Tasmania % Privat Docent: University of Konstanz, Physics Dept <http://www.uni-konstanz.de> % contact |-> URL : http://clifford.physik.uni-konstanz.de/~fauser/ % Phone : +49 1520 9874517 _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: listOfTermsDear Tim and Bertfried,
On Mon, 2 Nov 2009, Bertfried Fauser wrote: > There is one exposed function called listOfTerms : > [1] D -> List(Record(k: D3,c: D2)) from D > if D has IDPC(D2,D3) and D2 has SETCAT and D3 has ORDSET yes, that's the one. Franz _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
pointersYou can get a memory pointer to a lisp object.
a:=Fraction(Integer) returns the "memory location of Fraction(Integer)" You can prove this with b:=Fraction(Integer) EQ(a,b)$Lisp The lisp function EQ compares memory pointers. There is a lisp function to get the hash value of any object call sxhash. You can call it. SXHASH(a)$Lisp Note that if c:=Integer then EQ(a,c)$Lisp is false SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp Thus the hash function you seek already exists. You just have to accept the fact that Spad is only syntactic sugar for lisp code and lisp is not evil. Tim _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersTim:
Interesting. Is there a similar function that is more structural? say, can I test whether some domain (which may be passed as a parameter of type Field) is of the form Fraction(something) and if so, extract "something" (that is, assign it to a variable and further test it), sort of a deconstruction? William On Mon, 09 Nov 2009 19:51:45 -0500 Tim Daly <daly@...> wrote: >You can get a memory pointer to a lisp object. > >a:=Fraction(Integer) > >returns the "memory location of Fraction(Integer)" >You can prove this with > >b:=Fraction(Integer) >EQ(a,b)$Lisp > >The lisp function EQ compares memory pointers. > >There is a lisp function to get the hash value of any >object >call sxhash. You can call it. > >SXHASH(a)$Lisp > >Note that if > >c:=Integer > >then >EQ(a,c)$Lisp is false >SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp > >Thus the hash function you seek already exists. >You just have to accept the fact that Spad is only >syntactic >sugar for lisp code and lisp is not evil. > >Tim > > > >_______________________________________________ >Axiom-developer mailing list >Axiom-developer@... >http://lists.nongnu.org/mailman/listinfo/axiom-developer William Sit, Professor Emeritus Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179 Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersTim,
Besides the fact that from the standard we only have that (equal x y) implies (= (sxhash x) (sxhash y)). Do you see any reason why SXHASH is not used by default in SetCategory? Note: OpenAxiom currently defines this default: add hash(s : %): SingleInteger == SXHASH(s)$Lisp Regards, Bill Page. On Mon, Nov 9, 2009 at 7:51 PM, Tim Daly <daly@...> wrote: > ... > There is a lisp function to get the hash value of any object > call sxhash. You can call it. > > SXHASH(a)$Lisp > > Note that if > > c:=Integer > > then > EQ(a,c)$Lisp is false > SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp > > Thus the hash function you seek already exists. > You just have to accept the fact that Spad is only syntactic > sugar for lisp code and lisp is not evil. _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersI'm not sure what you want. Perhaps you'd like to say:
a:=Fraction(Polynomial(Integer)) b:=devaluate(a)$Lisp which returns the list (actually of type SExpression) (Fraction (Polynomial (Integer))) c:=destruct(b) c.2 which returns (Polynomial (Integer)) Does that help? Tim William Sit wrote: > Tim: > > Interesting. Is there a similar function that is more structural? say, > can I test whether some domain (which may be passed as a parameter of > type Field) is of the form Fraction(something) and if so, extract > "something" (that is, assign it to a variable and further test it), > sort of a deconstruction? > > William > > On Mon, 09 Nov 2009 19:51:45 -0500 > Tim Daly <daly@...> wrote: >> You can get a memory pointer to a lisp object. >> >> a:=Fraction(Integer) >> >> returns the "memory location of Fraction(Integer)" >> You can prove this with >> >> b:=Fraction(Integer) >> EQ(a,b)$Lisp >> >> The lisp function EQ compares memory pointers. >> >> There is a lisp function to get the hash value of any object >> call sxhash. You can call it. >> >> SXHASH(a)$Lisp >> >> Note that if >> >> c:=Integer >> >> then >> EQ(a,c)$Lisp is false >> SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >> >> Thus the hash function you seek already exists. >> You just have to accept the fact that Spad is only syntactic >> sugar for lisp code and lisp is not evil. >> >> Tim >> >> >> >> _______________________________________________ >> Axiom-developer mailing list >> Axiom-developer@... >> http://lists.nongnu.org/mailman/listinfo/axiom-developer > > William Sit, Professor Emeritus > Mathematics, City College of New York Office: R6/202C > Tel: 212-650-5179 > Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersOpenAxiom's choice is perfectly rational as far as I can tell.
The only issue would be that Aldor hashing would not equal Spad hashing. I do not know where hashing is used at the Spad level. Spad domains are stored in $ConstructorCache, once they are created. In a newly started session do: )lisp (gethash '|Fraction| |$ConstructorCache|) ==> nil then do a:=1/2 )lisp (gethash '|Fraction| |$ConstructorCache|) ==> ((((|Integer|)) 2 . #<vector 08beb9f4>)) So spad domains are hashed internally. I recommend that we follow OpenAxiom's lead on this provided nothing breaks. Tim Bill Page wrote: > Tim, > > Besides the fact that from the standard we only have that > > (equal x y) implies (= (sxhash x) (sxhash y)). > > Do you see any reason why SXHASH is not used by default in SetCategory? > > Note: OpenAxiom currently defines this default: > > add > hash(s : %): SingleInteger == SXHASH(s)$Lisp > > Regards, > Bill Page. > > On Mon, Nov 9, 2009 at 7:51 PM, Tim Daly <daly@...> wrote: > >> ... >> There is a lisp function to get the hash value of any object >> call sxhash. You can call it. >> >> SXHASH(a)$Lisp >> >> Note that if >> >> c:=Integer >> >> then >> EQ(a,c)$Lisp is false >> SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >> >> Thus the hash function you seek already exists. >> You just have to accept the fact that Spad is only syntactic >> sugar for lisp code and lisp is not evil. >> > > _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersOn Mon, Nov 9, 2009 at 7:09 PM, William Sit <wyscc@...> wrote:
> Tim: > > Interesting. Is there a similar function that is more structural? say, can I > test whether some domain (which may be passed as a parameter of type Field) > is of the form Fraction(something) and if so, extract "something" (that is, > assign it to a variable and further test it), sort of a deconstruction? William -- In OpenAxiom, when you get a domain, you can reify it, and ask for the arguments that were used to instantiate it: (1) -> reify Fraction Integer (1) Fraction Integer Type: ConstructorCall DomainConstructor (2) -> arguments reify Fraction Integer (2) [(Integer)] Type: List Syntax _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersNote that, under this definition
a:Dequeue(Integer):= dequeue [1,2,3,4,5] b:Queue(Integer):= queue [1,2,3,4,5] hash(a) == hash(b) This is because the internal data representation of both objects is: ((1 2 3 4 5)) Nevertheless, this is a perfectly reasonable hash function. Tim Bill Page wrote: > Tim, > > Besides the fact that from the standard we only have that > > (equal x y) implies (= (sxhash x) (sxhash y)). > > Do you see any reason why SXHASH is not used by default in SetCategory? > > Note: OpenAxiom currently defines this default: > > add > hash(s : %): SingleInteger == SXHASH(s)$Lisp > > Regards, > Bill Page. > > On Mon, Nov 9, 2009 at 7:51 PM, Tim Daly <daly@...> wrote: > >> ... >> There is a lisp function to get the hash value of any object >> call sxhash. You can call it. >> >> SXHASH(a)$Lisp >> >> Note that if >> >> c:=Integer >> >> then >> EQ(a,c)$Lisp is false >> SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >> >> Thus the hash function you seek already exists. >> You just have to accept the fact that Spad is only syntactic >> sugar for lisp code and lisp is not evil. >> > > _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersTim Daly <daly@...> writes:
| Note that, under this definition | | a:Dequeue(Integer):= dequeue [1,2,3,4,5] | b:Queue(Integer):= queue [1,2,3,4,5] | | hash(a) == hash(b) ^^ I suspect you meant '='. In any case, unless you have a hash function that is a bijection of the whole universe onto the finite set SingleInteger, you're going to get different objects/values mapped to the same hash value no matter what. OpenAxiom being strongly typed, I'm not worried that you're going to put both a and b in the same HashTable and not being able to avoid the collision. -- Gaby _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersThanks, Tim. That is exactly what I am looking for. Now I
would like to compare c.1 with some known constructor, say Fraction. (In other words, given a domain of category Field, I would like to know if it comes from the constructor Fraction). I tried a few variations and each time, Axiom says: Although Fraction is the name of a constructor, a full type must be specified in the context you have used it. Issue )show Fraction for more information. Things I tried: a:=FiniteField(5,2) b:=devaluate(a)$Lisp c:=destruct(b) c.1 d:="Fraction"::SExpression e:Boolean e:=EQ(c.1,d) -- message above e:=(c.1=Fraction) -- message above e:= (c.1=d$Lisp) -- message above a1:=Fraction Integer b1:=devaluate(a1)$Lisp c1:=destruct(b1) e:=(c.1=c1.1) -- message above I confess that I'm still using a very old Window version (Version of Tuesday November 30, 2004 at 21:11:14) but I don't think that makes a difference in these examples. William On Mon, 09 Nov 2009 21:24:48 -0500 Tim Daly <daly@...> wrote: >I'm not sure what you want. Perhaps you'd like to say: > >a:=Fraction(Polynomial(Integer)) >b:=devaluate(a)$Lisp > >which returns the list (actually of type SExpression) > >(Fraction (Polynomial (Integer))) > >c:=destruct(b) >c.2 > >which returns (Polynomial (Integer)) > >Does that help? > >Tim > > >William Sit wrote: >>Tim: >> >>Interesting. Is there a similar function that is more >>structural? say, >>can I test whether some domain (which may be passed as a >>parameter of >>type Field) is of the form Fraction(something) and if so, >>extract >>"something" (that is, assign it to a variable and further >>test it), >>sort of a deconstruction? >> >>William >> >>On Mon, 09 Nov 2009 19:51:45 -0500 >> Tim Daly <daly@...> wrote: >>>You can get a memory pointer to a lisp object. >>> >>>a:=Fraction(Integer) >>> >>>returns the "memory location of Fraction(Integer)" >>>You can prove this with >>> >>>b:=Fraction(Integer) >>>EQ(a,b)$Lisp >>> >>>The lisp function EQ compares memory pointers. >>> >>>There is a lisp function to get the hash value of any >>>object >>>call sxhash. You can call it. >>> >>>SXHASH(a)$Lisp >>> >>>Note that if >>> >>>c:=Integer >>> >>>then >>>EQ(a,c)$Lisp is false >>>SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >>> >>>Thus the hash function you seek already exists. >>>You just have to accept the fact that Spad is only >>>syntactic >>>sugar for lisp code and lisp is not evil. >>> >>>Tim >>> >>> >>> >>>_______________________________________________ >>>Axiom-developer mailing list >>>Axiom-developer@... >>>http://lists.nongnu.org/mailman/listinfo/axiom-developer >> >>William Sit, Professor Emeritus >>Mathematics, City College of New York >> Office: R6/202C >>Tel: 212-650-5179 >>Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ >> > William Sit, Professor Emeritus Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179 Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersGabriel:
Thanks for the response. Your script shows how to get the parameters, not the constructor. I do not have OpenAxiom installed (sorry). The question is whether I can test that the constructor is Fraction, or otherwise (like FiniteField) when the domain belongs to the category Field. I came across this requirement in algorithms that may take advantage of special knowledge of how the coefficient field is constructed. William On Mon, 9 Nov 2009 21:21:28 -0600 Gabriel Dos Reis <gdr@...> wrote: >On Mon, Nov 9, 2009 at 7:09 PM, William Sit ><wyscc@...> wrote: >> Tim: >> >> Interesting. Is there a similar function that is more >>structural? say, can I >> test whether some domain (which may be passed as a >>parameter of type Field) >> is of the form Fraction(something) and if so, extract >>"something" (that is, >> assign it to a variable and further test it), sort of a >>deconstruction? > >William -- > > In OpenAxiom, when you get a domain, you can reify >it, and >ask for the arguments that were used to instantiate it: > >(1) -> reify Fraction Integer > (1) Fraction Integer > Type: >ConstructorCall DomainConstructor >(2) -> arguments reify Fraction Integer > (2) [(Integer)] > > Type: List Syntax William Sit, Professor Emeritus Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179 Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersTim:
Sorry about the last message, please ignore. The problem is solved (I was simply not being careful) and made some false claims on the results. (16) -> )clear all All user variables and function definitions have been cleared. (1) -> a:=FiniteField(5,2) (1) FiniteField(5,2) Type: Domain (2) -> b:=devaluate(a)$Lisp (2) (FiniteField 5 2) Type: SExpression (3) -> c:=destruct(b) (3) [FiniteField,5,2] Type: List SExpression (4) -> c.1 (4) FiniteField Type: SExpression (5) -> d:="Fraction"::SExpression (5) Fraction Type: SExpression (6) -> e:Boolean Type: Void (7) -> e:=EQ(c.1,d)$Lisp (7) () Type: SExpression (7) -> e:=(c.1=Fraction) -- message above Although Fraction is the name of a constructor, a full type must be specified in the context you have used it. Issue )show Fraction for more information. (7) -> e:= (c.1=d$Lisp) >> System error: The variable |d| is unbound. protected-symbol-warn called with (NIL) (7) -> a1:=Fraction Integer (7) Fraction Integer Type: Domain (8) -> b1:=devaluate(a1)$Lisp (8) (Fraction (Integer)) Type: SExpression (9) -> c1:=destruct(b1) (9) [Fraction,(Integer)] Type: List SExpression (10) -> e:=(c.1=c1.1) (10) false Type: Boolean William ---- On Tue, 10 Nov 2009 11:38:25 -0500 "William Sit" <wyscc@...> wrote: >Thanks, Tim. That is exactly what I am looking for. Now I >would like to compare c.1 with some known constructor, >say Fraction. (In other words, given a domain of category >Field, I would like to know if it comes from the >constructor Fraction). I tried a few variations and each >time, Axiom says: > >Although Fraction is the name of a constructor, a full >type must be specified in the context you have used it. >Issue )show Fraction for more information. > >Things I tried: > >a:=FiniteField(5,2) >b:=devaluate(a)$Lisp >c:=destruct(b) >c.1 >d:="Fraction"::SExpression >e:Boolean >e:=EQ(c.1,d) -- message above >e:=(c.1=Fraction) -- message above >e:= (c.1=d$Lisp) -- message above >a1:=Fraction Integer >b1:=devaluate(a1)$Lisp >c1:=destruct(b1) >e:=(c.1=c1.1) -- message above > >I confess that I'm still using a very old Window version >(Version of Tuesday November 30, 2004 at 21:11:14) but I >don't think that makes a difference in these examples. > >William > >On Mon, 09 Nov 2009 21:24:48 -0500 > Tim Daly <daly@...> wrote: >>I'm not sure what you want. Perhaps you'd like to say: >> >>a:=Fraction(Polynomial(Integer)) >>b:=devaluate(a)$Lisp >> >>which returns the list (actually of type SExpression) >> >>(Fraction (Polynomial (Integer))) >> >>c:=destruct(b) >>c.2 >> >>which returns (Polynomial (Integer)) >> >>Does that help? >> >>Tim >> >> >>William Sit wrote: >>>Tim: >>> >>>Interesting. Is there a similar function that is more >>>structural? say, can I test whether some domain (which >>>may be passed as a parameter of type Field) is of the >>>form Fraction(something) and if so, extract "something" >>>(that is, assign it to a variable and further test it), >>>sort of a deconstruction? >>> >>>William >>> >>>On Mon, 09 Nov 2009 19:51:45 -0500 >>>Tim Daly <daly@...> wrote: >>>>You can get a memory pointer to a lisp object. >>>> >>>>a:=Fraction(Integer) >>>> >>>>returns the "memory location of Fraction(Integer)" >>>>You can prove this with >>>> >>>>b:=Fraction(Integer) >>>>EQ(a,b)$Lisp >>>> >>>>The lisp function EQ compares memory pointers. >>>> >>>>There is a lisp function to get the hash value of any >>>>object >>>>call sxhash. You can call it. >>>> >>>>SXHASH(a)$Lisp >>>> >>>>Note that if >>>> >>>>c:=Integer >>>> >>>>then >>>>EQ(a,c)$Lisp is false >>>>SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >>>> >>>>Thus the hash function you seek already exists. >>>>You just have to accept the fact that Spad is only >>>>syntactic >>>>sugar for lisp code and lisp is not evil. >>>> >>>>Tim >>>> >>>> >>>> >>>>_______________________________________________ >>>>Axiom-developer mailing list >>>>Axiom-developer@... >>>>http://lists.nongnu.org/mailman/listinfo/axiom-developer >>> >>>William Sit, Professor Emeritus >>>Mathematics, City College of New York >>> Office: R6/202C >>>Tel: 212-650-5179 >>>Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ >>> >> > >William Sit, Professor Emeritus >Mathematics, City College of New York > Office: R6/202C Tel: 212-650-5179 >Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ William Sit, Professor Emeritus Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179 Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersIt appears that to test the constructor, one must test a
candidate against a known one via the constructor itself, and not be "fiat" by using a SExpression. Is this related to hashing of pointers? Continuing with script in the previous email (attached): (11) -> EQ(c.1,d)$Lisp (11) () Type: SExpression (12) -> EQ(c1.1,d)$Lisp (12) () Type: SExpression -- So EQ$Lisp returns () in both cases, even for -- EQ(c.1,c1.1)$Lisp -- (19) () --Type: SExpression (13) -> e:=(c.1=d) (13) false Type: Boolean (14) -> e:=(c1.1=d) (14) false Type: Boolean -- same problem with = using SExpression. 15) -> e:=(c1.1=c1.1) (15) true Type: Boolean (16) -> d (16) Fraction Type: SExpression (17) -> c1.1 (17) Fraction Type: SExpression So it seems there is some distinction: d (defined explicitly as Fraction::SExpression) is different from c1.1 defined using devaluate/destruct from a domain. A user should not need to know the various way "equal" is tested if the two arguments for "equal" come from the same domain SExpression. So is this a bug? William On Tue, 10 Nov 2009 12:00:58 -0500 "William Sit" <wyscc@...> wrote: >Tim: > >Sorry about the last message, please ignore. >The problem is solved (I was simply not being careful) >and made some false claims on the results. > >(16) -> )clear all > All user variables and function definitions have been >cleared. >(1) -> a:=FiniteField(5,2) > > (1) FiniteField(5,2) > > > Type: Domain >(2) -> b:=devaluate(a)$Lisp > > (2) (FiniteField 5 2) > > > Type: SExpression >(3) -> c:=destruct(b) > > (3) [FiniteField,5,2] > Type: >List SExpression >(4) -> c.1 > > (4) FiniteField > > > Type: SExpression >(5) -> d:="Fraction"::SExpression > > (5) Fraction > > > Type: SExpression >(6) -> e:Boolean > > > Type: Void >(7) -> e:=EQ(c.1,d)$Lisp > > (7) () > Type: >SExpression >(7) -> e:=(c.1=Fraction) -- message above > > Although Fraction is the name of a constructor, a >full >type must be > specified in the context you have used it. Issue >)show Fraction > for more information. >(7) -> e:= (c.1=d$Lisp) > > >> System error: > The variable |d| is unbound. > >protected-symbol-warn called with (NIL) >(7) -> a1:=Fraction Integer > > (7) Fraction Integer > > > Type: Domain >(8) -> b1:=devaluate(a1)$Lisp > > (8) (Fraction (Integer)) > > > Type: SExpression >(9) -> c1:=destruct(b1) > > (9) [Fraction,(Integer)] > Type: >List SExpression >(10) -> e:=(c.1=c1.1) > > (10) false > > > Type: Boolean > >William >---- > >On Tue, 10 Nov 2009 11:38:25 -0500 > "William Sit" <wyscc@...> wrote: >>Thanks, Tim. That is exactly what I am looking for. Now I >>would like to compare c.1 with some known constructor, >>say Fraction. (In other words, given a domain of category >>Field, I would like to know if it comes from the >>constructor Fraction). I tried a few variations and each >>time, Axiom says: >> >>Although Fraction is the name of a constructor, a full >>type must be specified in the context you have used it. >>Issue )show Fraction for more information. >> >>Things I tried: >> >>a:=FiniteField(5,2) >>b:=devaluate(a)$Lisp >>c:=destruct(b) >>c.1 >>d:="Fraction"::SExpression >>e:Boolean >>e:=EQ(c.1,d) -- message above >>e:=(c.1=Fraction) -- message above >>e:= (c.1=d$Lisp) -- message above >>a1:=Fraction Integer >>b1:=devaluate(a1)$Lisp >>c1:=destruct(b1) >>e:=(c.1=c1.1) -- message above >> >>I confess that I'm still using a very old Window version >>(Version of Tuesday November 30, 2004 at 21:11:14) but I >>don't think that makes a difference in these examples. >> >>William >> >>On Mon, 09 Nov 2009 21:24:48 -0500 >> Tim Daly <daly@...> wrote: >>>I'm not sure what you want. Perhaps you'd like to say: >>> >>>a:=Fraction(Polynomial(Integer)) >>>b:=devaluate(a)$Lisp >>> >>>which returns the list (actually of type SExpression) >>> >>>(Fraction (Polynomial (Integer))) >>> >>>c:=destruct(b) >>>c.2 >>> >>>which returns (Polynomial (Integer)) >>> >>>Does that help? >>> >>>Tim >>> >>> >>>William Sit wrote: >>>>Tim: >>>> >>>>Interesting. Is there a similar function that is more >>>>structural? say, can I test whether some domain (which >>>>may be passed as a parameter of type Field) is of the >>>>form Fraction(something) and if so, extract "something" >>>>(that is, assign it to a variable and further test it), >>>>sort of a deconstruction? >>>> >>>>William >>>> >>>>On Mon, 09 Nov 2009 19:51:45 -0500 >>>>Tim Daly <daly@...> wrote: >>>>>You can get a memory pointer to a lisp object. >>>>> >>>>>a:=Fraction(Integer) >>>>> >>>>>returns the "memory location of Fraction(Integer)" >>>>>You can prove this with >>>>> >>>>>b:=Fraction(Integer) >>>>>EQ(a,b)$Lisp >>>>> >>>>>The lisp function EQ compares memory pointers. >>>>> >>>>>There is a lisp function to get the hash value of any >>>>>object >>>>>call sxhash. You can call it. >>>>> >>>>>SXHASH(a)$Lisp >>>>> >>>>>Note that if >>>>> >>>>>c:=Integer >>>>> >>>>>then >>>>>EQ(a,c)$Lisp is false >>>>>SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >>>>> >>>>>Thus the hash function you seek already exists. >>>>>You just have to accept the fact that Spad is only >>>>>syntactic >>>>>sugar for lisp code and lisp is not evil. >>>>> >>>>>Tim >>>>> >>>>> >>>>> >>>>>_______________________________________________ >>>>>Axiom-developer mailing list >>>>>Axiom-developer@... >>>>>http://lists.nongnu.org/mailman/listinfo/axiom-developer >>>> >>>>William Sit, Professor Emeritus >>>>Mathematics, City College of New York >>>> Office: R6/202C >>>>Tel: 212-650-5179 >>>>Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ >>>> >>> >> >>William Sit, Professor Emeritus >>Mathematics, City College of New York >> Office: R6/202C Tel: 212-650-5179 >>Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > >William Sit, Professor Emeritus >Mathematics, City College of New York > Office: R6/202C Tel: 212-650-5179 >Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ William Sit, Professor Emeritus Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179 Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersI'm not sure what you are asking. Are you having trouble with working in
the SExpression domain? You can move the SExpressions out to other domains. Sometimes it is painful but it works. So: a:=FiniteField(5,2) b:=devaluate(a) string(SYMBOL_-NAME(b.1)$Lisp) ==> "FiniteField" (of type String) integer(b.1) ==> 5 (of type PositiveInteger) Does this help? Tim William Sit wrote: > It appears that to test the constructor, one must test a candidate > against a known one via the constructor itself, and not be "fiat" by > using a SExpression. Is this related to hashing of pointers? > Continuing with script in the previous email (attached): > > (11) -> EQ(c.1,d)$Lisp > > (11) () > Type: > SExpression > (12) -> EQ(c1.1,d)$Lisp > > (12) () > > Type: SExpression > -- So EQ$Lisp returns () in both cases, even for -- EQ(c.1,c1.1)$Lisp > > -- (19) () > --Type: > SExpression > > (13) -> e:=(c.1=d) > > (13) false > Type: > Boolean > > (14) -> e:=(c1.1=d) > > (14) false > Type: > Boolean > -- same problem with = using SExpression. > 15) -> e:=(c1.1=c1.1) > > (15) true > Type: > Boolean > (16) -> d > > (16) Fraction > Type: > SExpression > (17) -> c1.1 > > (17) Fraction > Type: > SExpression > > So it seems there is some distinction: d (defined explicitly as > Fraction::SExpression) is different from c1.1 defined using > devaluate/destruct from a domain. A user should not need to know the > various way "equal" is tested if the two arguments for "equal" come > from the same domain SExpression. So is this a bug? > > William > > On Tue, 10 Nov 2009 12:00:58 -0500 > "William Sit" <wyscc@...> wrote: >> Tim: >> >> Sorry about the last message, please ignore. >> The problem is solved (I was simply not being careful) and made some >> false claims on the results. >> >> (16) -> )clear all >> All user variables and function definitions have been cleared. >> (1) -> a:=FiniteField(5,2) >> >> (1) FiniteField(5,2) >> >> Type: Domain >> (2) -> b:=devaluate(a)$Lisp >> >> (2) (FiniteField 5 2) >> >> Type: SExpression >> (3) -> c:=destruct(b) >> >> (3) [FiniteField,5,2] >> Type: List >> SExpression >> (4) -> c.1 >> >> (4) FiniteField >> >> Type: SExpression >> (5) -> d:="Fraction"::SExpression >> >> (5) Fraction >> >> Type: SExpression >> (6) -> e:Boolean >> >> Type: Void >> (7) -> e:=EQ(c.1,d)$Lisp >> >> (7) () >> Type: SExpression >> (7) -> e:=(c.1=Fraction) -- message above >> >> Although Fraction is the name of a constructor, a full type must be >> specified in the context you have used it. Issue )show Fraction >> for more information. >> (7) -> e:= (c.1=d$Lisp) >> >> >> System error: >> The variable |d| is unbound. >> >> protected-symbol-warn called with (NIL) >> (7) -> a1:=Fraction Integer >> >> (7) Fraction Integer >> >> Type: Domain >> (8) -> b1:=devaluate(a1)$Lisp >> >> (8) (Fraction (Integer)) >> >> Type: SExpression >> (9) -> c1:=destruct(b1) >> >> (9) [Fraction,(Integer)] >> Type: List >> SExpression >> (10) -> e:=(c.1=c1.1) >> >> (10) false >> >> Type: Boolean >> >> William >> ---- >> >> On Tue, 10 Nov 2009 11:38:25 -0500 >> "William Sit" <wyscc@...> wrote: >>> Thanks, Tim. That is exactly what I am looking for. Now I would like >>> to compare c.1 with some known constructor, say Fraction. (In other >>> words, given a domain of category Field, I would like to know if it >>> comes from the constructor Fraction). I tried a few variations and >>> each time, Axiom says: >>> >>> Although Fraction is the name of a constructor, a full type must be >>> specified in the context you have used it. Issue )show Fraction for >>> more information. >>> >>> Things I tried: >>> >>> a:=FiniteField(5,2) >>> b:=devaluate(a)$Lisp >>> c:=destruct(b) >>> c.1 >>> d:="Fraction"::SExpression >>> e:Boolean >>> e:=EQ(c.1,d) -- message above >>> e:=(c.1=Fraction) -- message above >>> e:= (c.1=d$Lisp) -- message above >>> a1:=Fraction Integer >>> b1:=devaluate(a1)$Lisp >>> c1:=destruct(b1) >>> e:=(c.1=c1.1) -- message above >>> >>> I confess that I'm still using a very old Window version (Version of >>> Tuesday November 30, 2004 at 21:11:14) but I don't think that makes >>> a difference in these examples. >>> >>> William >>> >>> On Mon, 09 Nov 2009 21:24:48 -0500 >>> Tim Daly <daly@...> wrote: >>>> I'm not sure what you want. Perhaps you'd like to say: >>>> >>>> a:=Fraction(Polynomial(Integer)) >>>> b:=devaluate(a)$Lisp >>>> >>>> which returns the list (actually of type SExpression) >>>> >>>> (Fraction (Polynomial (Integer))) >>>> >>>> c:=destruct(b) >>>> c.2 >>>> >>>> which returns (Polynomial (Integer)) >>>> >>>> Does that help? >>>> >>>> Tim >>>> >>>> >>>> William Sit wrote: >>>>> Tim: >>>>> >>>>> Interesting. Is there a similar function that is more structural? >>>>> say, can I test whether some domain (which may be passed as a >>>>> parameter of type Field) is of the form Fraction(something) and if >>>>> so, extract "something" (that is, assign it to a variable and >>>>> further test it), sort of a deconstruction? >>>>> >>>>> William >>>>> >>>>> On Mon, 09 Nov 2009 19:51:45 -0500 >>>>> Tim Daly <daly@...> wrote: >>>>>> You can get a memory pointer to a lisp object. >>>>>> >>>>>> a:=Fraction(Integer) >>>>>> >>>>>> returns the "memory location of Fraction(Integer)" >>>>>> You can prove this with >>>>>> >>>>>> b:=Fraction(Integer) >>>>>> EQ(a,b)$Lisp >>>>>> >>>>>> The lisp function EQ compares memory pointers. >>>>>> >>>>>> There is a lisp function to get the hash value of any object >>>>>> call sxhash. You can call it. >>>>>> >>>>>> SXHASH(a)$Lisp >>>>>> >>>>>> Note that if >>>>>> >>>>>> c:=Integer >>>>>> >>>>>> then >>>>>> EQ(a,c)$Lisp is false >>>>>> SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp >>>>>> >>>>>> Thus the hash function you seek already exists. >>>>>> You just have to accept the fact that Spad is only syntactic >>>>>> sugar for lisp code and lisp is not evil. >>>>>> >>>>>> Tim >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Axiom-developer mailing list >>>>>> Axiom-developer@... >>>>>> http://lists.nongnu.org/mailman/listinfo/axiom-developer >>>>> >>>>> William Sit, Professor Emeritus >>>>> Mathematics, City College of New York Office: >>>>> R6/202C Tel: 212-650-5179 >>>>> Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ >>>>> >>>> >>> >>> William Sit, Professor Emeritus >>> Mathematics, City College of New York Office: R6/202C >>> Tel: 212-650-5179 >>> Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ >> >> William Sit, Professor Emeritus >> Mathematics, City College of New York Office: R6/202C >> Tel: 212-650-5179 >> Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > > William Sit, Professor Emeritus > Mathematics, City College of New York Office: R6/202C > Tel: 212-650-5179 > Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersWilliam Sit wrote:
> Gabriel: > > Thanks for the response. Your script shows how to get the > parameters, not the constructor. I do not have OpenAxiom > installed (sorry). The question is whether I can test that > the constructor is Fraction, or otherwise (like > FiniteField) when the domain belongs to the category > Field. > Do you want something like this? (10) -> a := Fraction(Integer) (10) Fraction Integer Type: Domain (11) -> (opOf(devaluate(a)$Lisp)$Lisp = 'Fraction::SEX)@Boolean (11) true Type: Boolean (12) -> (opOf(devaluate(a)$Lisp)$Lisp = 'FiniteField::SEX)@Boolean (12) false Type: Boolean (13) -> a :=FiniteField(5,2) (13) FiniteField(5,2) Type: Domain (14) -> (opOf(devaluate(a)$Lisp)$Lisp = 'Fraction::SEX)@Boolean (14) false Type: Boolean (15) -> (opOf(devaluate(a)$Lisp)$Lisp = 'FiniteField::SEX)@Boolean (15) true Type: Boolean -- Waldek Hebisch hebisch@... _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersHi Waldek:
Thanks. That is exactly what I want. Good solution. So the "trick" is to use ' instead of the string. So is the following a bug? a:='Fraction::SEX Fraction Type:SExpression b:="Fraction"::SEX Fraction Type:SExpression (a=b)@Boolean false Type Boolean That is, I was deceived by the output which looked the same. Perhaps the output should have been ('Fraction) and ("Fraction") ?? Also, destruct(a) or destruct(b) leads to an Error: Function Selection for destruct Arguments: SEX [1] signature: SEX -> LIST SEX implemented: slot (List $)$ from SEX >> Error detected within library code: Non-list protected-symbol-warn called with (NIL) William Waldek Hebisch wrote: > > William Sit wrote: > > Gabriel: > > > > Thanks for the response. Your script shows how to get the > > parameters, not the constructor. I do not have OpenAxiom > > installed (sorry). The question is whether I can test that > > the constructor is Fraction, or otherwise (like > > FiniteField) when the domain belongs to the category > > Field. > > > > Do you want something like this? > > (10) -> a := Fraction(Integer) > > (10) Fraction Integer > Type: Domain > (11) -> (opOf(devaluate(a)$Lisp)$Lisp = 'Fraction::SEX)@Boolean > > (11) true > Type: Boolean > (12) -> (opOf(devaluate(a)$Lisp)$Lisp = 'FiniteField::SEX)@Boolean > > (12) false > Type: Boolean > (13) -> a :=FiniteField(5,2) > > (13) FiniteField(5,2) > Type: Domain > (14) -> (opOf(devaluate(a)$Lisp)$Lisp = 'Fraction::SEX)@Boolean > > (14) false > Type: Boolean > (15) -> (opOf(devaluate(a)$Lisp)$Lisp = 'FiniteField::SEX)@Boolean > > (15) true > Type: Boolean > > > -- > Waldek Hebisch > hebisch@... > > _______________________________________________ > Axiom-developer mailing list > Axiom-developer@... > http://lists.nongnu.org/mailman/listinfo/axiom-developer -- William Sit Department of Mathematics..Email: wyscc@... City College of New York................Tel: 212-650-5179 New York, NY 10031, USA.................Fax: 212-862-0004 Home page: .......http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersWilliam,
a:='Fraction::SEX is a lisp symbol. A lisp symbol is essentially the address of a data structure which is approximately struct symbol-function (pointer to code) symbol-name (a string representation of the symbol) symbol-package (the lisp package (a hash table pointer)) symbol-value (the value of the symbol) symbol-plist (an association list hanging on the symbol) a:="Fraction"::Sex is a lisp string, a contiguous set of bytes containing character code So a:=SYMBOL_-NAME('Fraction::SEX)$Lisp (get the symbol-name from the fraction struct) b:="Fraction"::SEX (make a string of bytes containing "Fraction") EQ(a,b)$Lisp ==> () (are they the same storage location? no) c:=STRING_-EQUAL(a,b)$Lisp ==> T (are they the same sequence of bytes? yes) Tim William Sit wrote: > Hi Waldek: > > Thanks. That is exactly what I want. Good solution. So the > "trick" is to use ' instead of the string. So is the > following a bug? > > a:='Fraction::SEX > Fraction Type:SExpression > b:="Fraction"::SEX > Fraction Type:SExpression > (a=b)@Boolean > false Type Boolean > > That is, I was deceived by the output which looked the same. > Perhaps the output should have been ('Fraction) and > ("Fraction") ?? > > Also, > > destruct(a) or destruct(b) leads to an Error: > > Function Selection for destruct > Arguments: SEX > > [1] signature: SEX -> LIST SEX > implemented: slot (List $)$ from SEX > > > >> Error detected within library code: > Non-list > > protected-symbol-warn called with (NIL) > > William > > > Waldek Hebisch wrote: > >> William Sit wrote: >> >>> Gabriel: >>> >>> Thanks for the response. Your script shows how to get the >>> parameters, not the constructor. I do not have OpenAxiom >>> installed (sorry). The question is whether I can test that >>> the constructor is Fraction, or otherwise (like >>> FiniteField) when the domain belongs to the category >>> Field. >>> >>> >> Do you want something like this? >> >> (10) -> a := Fraction(Integer) >> >> (10) Fraction Integer >> Type: Domain >> (11) -> (opOf(devaluate(a)$Lisp)$Lisp = 'Fraction::SEX)@Boolean >> >> (11) true >> Type: Boolean >> (12) -> (opOf(devaluate(a)$Lisp)$Lisp = 'FiniteField::SEX)@Boolean >> >> (12) false >> Type: Boolean >> (13) -> a :=FiniteField(5,2) >> >> (13) FiniteField(5,2) >> Type: Domain >> (14) -> (opOf(devaluate(a)$Lisp)$Lisp = 'Fraction::SEX)@Boolean >> >> (14) false >> Type: Boolean >> (15) -> (opOf(devaluate(a)$Lisp)$Lisp = 'FiniteField::SEX)@Boolean >> >> (15) true >> Type: Boolean >> >> >> -- >> Waldek Hebisch >> hebisch@... >> >> _______________________________________________ >> Axiom-developer mailing list >> Axiom-developer@... >> http://lists.nongnu.org/mailman/listinfo/axiom-developer >> > > _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointers//Decontructing domainsTim:
Thanks, your method works. For me at least, it is much easier to handle strings than SExpression. Waldek also provided a working method using opOf (but that involves SExpression, and the output in SExpression can be misleading), which is perhaps a bug (see my reply to Waldek). To summarize: It is possible to deconstruct a domain (that is, trace its constructor and the parameters to that constructor) using Lisp primitives. Given an identifier whose value at turn time is an Axiom domain, the function devaluate$Lisp returns its value as an SExpression, and the function deconstrut further turns the result into a list of SExpressions (which may be useful to extract the first level of parameters, but not necessary). The components can then be analyzed. However, testing for equality of SExpressions can be hazardous when the SExpressions are constructed in different ways but the outputForms look identical. There are (at least?) two ways to get around the problem. Assume we have a, b defined below (but the value of the identifier a is not really assumed known at compile time): a:=Fraction Integer b:=devaluate(a)$Lisp (Fraction (Integer)) Type SExpression (1) (Waldek): use opOF to pick out the constructor of the domain and test against a candidate using a quote expression in Lisp coerced to an SExpression: testW:='Fraction::SEX c:=opOf(b)$Lisp (c=testW)@Boolean (2) (Tim): use a Lisp function SYMBOL_-NAME and then convert the result into a string before testing: testT:="Fraction" c:=string(SYMBOL_-NAME(b.1)$Lisp) (c=testT)@Boolean In either method, do not set testW or testT to "Fraction"::SEX, which would not test correctly. William Tim Daly wrote: > > I'm not sure what you are asking. Are you having trouble with working in > the SExpression domain? > You can move the SExpressions out to other domains. Sometimes it is > painful but it works. So: > > a:=FiniteField(5,2) > b:=devaluate(a) > string(SYMBOL_-NAME(b.1)$Lisp) ==> "FiniteField" (of type String) > integer(b.1) ==> 5 (of type PositiveInteger) > > Does this help? > > Tim > > William Sit wrote: > > It appears that to test the constructor, one must test a candidate > > against a known one via the constructor itself, and not be "fiat" by > > using a SExpression. Is this related to hashing of pointers? > > Continuing with script in the previous email (attached): > > > > (11) -> EQ(c.1,d)$Lisp > > > > (11) () > > Type: > > SExpression > > (12) -> EQ(c1.1,d)$Lisp > > > > (12) () > > > > Type: SExpression > > -- So EQ$Lisp returns () in both cases, even for -- EQ(c.1,c1.1)$Lisp > > > > -- (19) () > > --Type: > > SExpression > > > > (13) -> e:=(c.1=d) > > > > (13) false > > Type: > > Boolean > > > > (14) -> e:=(c1.1=d) > > > > (14) false > > Type: > > Boolean > > -- same problem with = using SExpression. > > 15) -> e:=(c1.1=c1.1) > > > > (15) true > > Type: > > Boolean > > (16) -> d > > > > (16) Fraction > > Type: > > SExpression > > (17) -> c1.1 > > > > (17) Fraction > > Type: > > SExpression > > > > So it seems there is some distinction: d (defined explicitly as > > Fraction::SExpression) is different from c1.1 defined using > > devaluate/destruct from a domain. A user should not need to know the > > various way "equal" is tested if the two arguments for "equal" come > > from the same domain SExpression. So is this a bug? > > > > William > > > > On Tue, 10 Nov 2009 12:00:58 -0500 > > "William Sit" <wyscc@...> wrote: > >> Tim: > >> > >> Sorry about the last message, please ignore. > >> The problem is solved (I was simply not being careful) and made some > >> false claims on the results. > >> > >> (16) -> )clear all > >> All user variables and function definitions have been cleared. > >> (1) -> a:=FiniteField(5,2) > >> > >> (1) FiniteField(5,2) > >> > >> Type: Domain > >> (2) -> b:=devaluate(a)$Lisp > >> > >> (2) (FiniteField 5 2) > >> > >> Type: SExpression > >> (3) -> c:=destruct(b) > >> > >> (3) [FiniteField,5,2] > >> Type: List > >> SExpression > >> (4) -> c.1 > >> > >> (4) FiniteField > >> > >> Type: SExpression > >> (5) -> d:="Fraction"::SExpression > >> > >> (5) Fraction > >> > >> Type: SExpression > >> (6) -> e:Boolean > >> > >> Type: Void > >> (7) -> e:=EQ(c.1,d)$Lisp > >> > >> (7) () > >> Type: SExpression > >> (7) -> e:=(c.1=Fraction) -- message above > >> > >> Although Fraction is the name of a constructor, a full type must be > >> specified in the context you have used it. Issue )show Fraction > >> for more information. > >> (7) -> e:= (c.1=d$Lisp) > >> > >> >> System error: > >> The variable |d| is unbound. > >> > >> protected-symbol-warn called with (NIL) > >> (7) -> a1:=Fraction Integer > >> > >> (7) Fraction Integer > >> > >> Type: Domain > >> (8) -> b1:=devaluate(a1)$Lisp > >> > >> (8) (Fraction (Integer)) > >> > >> Type: SExpression > >> (9) -> c1:=destruct(b1) > >> > >> (9) [Fraction,(Integer)] > >> Type: List > >> SExpression > >> (10) -> e:=(c.1=c1.1) > >> > >> (10) false > >> > >> Type: Boolean > >> > >> William > >> ---- > >> > >> On Tue, 10 Nov 2009 11:38:25 -0500 > >> "William Sit" <wyscc@...> wrote: > >>> Thanks, Tim. That is exactly what I am looking for. Now I would like > >>> to compare c.1 with some known constructor, say Fraction. (In other > >>> words, given a domain of category Field, I would like to know if it > >>> comes from the constructor Fraction). I tried a few variations and > >>> each time, Axiom says: > >>> > >>> Although Fraction is the name of a constructor, a full type must be > >>> specified in the context you have used it. Issue )show Fraction for > >>> more information. > >>> > >>> Things I tried: > >>> > >>> a:=FiniteField(5,2) > >>> b:=devaluate(a)$Lisp > >>> c:=destruct(b) > >>> c.1 > >>> d:="Fraction"::SExpression > >>> e:Boolean > >>> e:=EQ(c.1,d) -- message above > >>> e:=(c.1=Fraction) -- message above > >>> e:= (c.1=d$Lisp) -- message above > >>> a1:=Fraction Integer > >>> b1:=devaluate(a1)$Lisp > >>> c1:=destruct(b1) > >>> e:=(c.1=c1.1) -- message above > >>> > >>> I confess that I'm still using a very old Window version (Version of > >>> Tuesday November 30, 2004 at 21:11:14) but I don't think that makes > >>> a difference in these examples. > >>> > >>> William > >>> > >>> On Mon, 09 Nov 2009 21:24:48 -0500 > >>> Tim Daly <daly@...> wrote: > >>>> I'm not sure what you want. Perhaps you'd like to say: > >>>> > >>>> a:=Fraction(Polynomial(Integer)) > >>>> b:=devaluate(a)$Lisp > >>>> > >>>> which returns the list (actually of type SExpression) > >>>> > >>>> (Fraction (Polynomial (Integer))) > >>>> > >>>> c:=destruct(b) > >>>> c.2 > >>>> > >>>> which returns (Polynomial (Integer)) > >>>> > >>>> Does that help? > >>>> > >>>> Tim > >>>> > >>>> > >>>> William Sit wrote: > >>>>> Tim: > >>>>> > >>>>> Interesting. Is there a similar function that is more structural? > >>>>> say, can I test whether some domain (which may be passed as a > >>>>> parameter of type Field) is of the form Fraction(something) and if > >>>>> so, extract "something" (that is, assign it to a variable and > >>>>> further test it), sort of a deconstruction? > >>>>> > >>>>> William > >>>>> > >>>>> On Mon, 09 Nov 2009 19:51:45 -0500 > >>>>> Tim Daly <daly@...> wrote: > >>>>>> You can get a memory pointer to a lisp object. > >>>>>> > >>>>>> a:=Fraction(Integer) > >>>>>> > >>>>>> returns the "memory location of Fraction(Integer)" > >>>>>> You can prove this with > >>>>>> > >>>>>> b:=Fraction(Integer) > >>>>>> EQ(a,b)$Lisp > >>>>>> > >>>>>> The lisp function EQ compares memory pointers. > >>>>>> > >>>>>> There is a lisp function to get the hash value of any object > >>>>>> call sxhash. You can call it. > >>>>>> > >>>>>> SXHASH(a)$Lisp > >>>>>> > >>>>>> Note that if > >>>>>> > >>>>>> c:=Integer > >>>>>> > >>>>>> then > >>>>>> EQ(a,c)$Lisp is false > >>>>>> SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp > >>>>>> > >>>>>> Thus the hash function you seek already exists. > >>>>>> You just have to accept the fact that Spad is only syntactic > >>>>>> sugar for lisp code and lisp is not evil. > >>>>>> > >>>>>> Tim > >>>>>> > >>>>>> > >>>>>> > >>>>>> _______________________________________________ > >>>>>> Axiom-developer mailing list > >>>>>> Axiom-developer@... > >>>>>> http://lists.nongnu.org/mailman/listinfo/axiom-developer > >>>>> > >>>>> William Sit, Professor Emeritus > >>>>> Mathematics, City College of New York Office: > >>>>> R6/202C Tel: 212-650-5179 > >>>>> Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > >>>>> > >>>> > >>> > >>> William Sit, Professor Emeritus > >>> Mathematics, City College of New York Office: R6/202C > >>> Tel: 212-650-5179 > >>> Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > >> > >> William Sit, Professor Emeritus > >> Mathematics, City College of New York Office: R6/202C > >> Tel: 212-650-5179 > >> Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > > > > William Sit, Professor Emeritus > > Mathematics, City College of New York Office: R6/202C > > Tel: 212-650-5179 > > Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/ > > -- William Sit Department of Mathematics..Email: wyscc@... City College of New York................Tel: 212-650-5179 New York, NY 10031, USA.................Fax: 212-862-0004 Home page: .......http://scisun.sci.ccny.cuny.edu/~wyscc/ _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
|
|
Re: pointersOn Tue, Nov 10, 2009 at 10:45 AM, William Sit <wyscc@...> wrote:
> Gabriel: > > Thanks for the response. Your script shows how to get the parameters, not > the constructor. I do not have OpenAxiom installed (sorry). The question is > whether I can test that the constructor is Fraction, or otherwise (like > FiniteField) when the domain belongs to the category Field. You can get the constructors too (1) -> constructor Fraction Integer (1) Fraction Type: DomainConstructor (2) -> constructor Integer (2) Integer Type: DomainConstructor (3) -> constructor Field (3) Field Type: CategoryConstructor There is a prepackaged Windows binary for OpenAxiom from the download area and it can co-exist with any other AXIOM flavour. Category constructors and domain constructors satisfy SetCategory: (4) -> DomainConstructor has SetCategory (4) true Type: Boolean (5) -> CategoryConstructor has SetCategory (5) true Type: Boolean so, you can use the equality comparator. > > I came across this requirement in algorithms that may take advantage of > special knowledge of how the coefficient field is constructed. Interesting. -- Gaby _______________________________________________ Axiom-developer mailing list Axiom-developer@... http://lists.nongnu.org/mailman/listinfo/axiom-developer |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |