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" <[email protected]> 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" <[email protected]> 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 <[email protected]> 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 <[email protected]> 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
[email protected]
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
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer