Re: Re: finite domains
- To: mathgroup at smc.vnet.net
- Subject: [mg53090] Re: [mg53053] Re: finite domains
- From: János <janos.lobb at yale.edu>
- Date: Thu, 23 Dec 2004 07:58:28 -0500 (EST)
- References: <cp3t2v$9ai$1@smc.vnet.net> <200412201134.GAA02658@smc.vnet.net> <cq8u48$h47$1@smc.vnet.net> <200412220952.EAA04409@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Dec 22, 2004, at 4:52 AM, Paul Abbott wrote: > In article <cq8u48$h47$1 at smc.vnet.net>, János <janos.lobb at yale.edu> > wrote: > > >> I looked at the article and I understand that for that particular >> case. However that case fell back in the definition on an already >> existing infinite domain of the same order namely Z. There is also a >> similar definition in the Book for Odd numbers. >> >> In my case I cannot fall back on an existing finite domain, or I do >> not know how to explore/exploite it with Boolean. >> >> I am thinking of a domain named Irany having elements >> {North,East,South,West}. How can I do that without a reference to a >> more basic domain as foundation and expect that >> Element[NorthWest,Irany] will give me False? >> > The following code does what _you_ want: > > Irany /: Element[x_, Irany]:= MemberQ[{North,East,South,West}, #]& /@ > x > > Element[{North, West}, Irany] > > Element[NorthWest, Irany] > > However, this violates the "spirit" of Mathematica because, for an > arbitrary symbol, the definition should return the unevaluated > expression -- but if you try > > Element[y, Irany] > > you get false, rather than the unevaluated expression. Now, y could be > North, or it could be NorthWest ... > > Cheers, > Paul Not exactly. In[5]:= Irany /: (x_) \[Element] Irany := (MemberQ[{North, East, South, West}, #1] & ) /@ xIn[5]:= Irany /: (x_) \[Element] Irany := (MemberQ[{North, East, South, West}, #1] & ) /@ x In[6]:= {North, West} \[Element] Irany Out[6]= {True, True} In[7]:= NorthWest \[Element] Irany Out[7]= NorthWest In[8]:= y = North Out[8]= North In[9]:= y \[Element] Irany Out[9]= North Here above I expected a True. In[10]:= y = NorthWest Out[10]= NorthWest In[11]:= y \[Element] Irany Out[11]= NorthWest Here above I expected a False or NorthWest \[Element] Irany in the "spirit" of Mathematica. Let' see how Booleans is doing in similar situation: In[40]:= True \[Element] Booleans Out[40]= True In[41]:= y = True Out[41]= True In[42]:= y \[Element] Booleans Out[42]= True as expected. Now let' see what Booleans is doing with y=NorthWest In[59]:= y = NorthWest Out[59]= NorthWest In[60]:= y \[Element] Booleans Out[60]= NorthWest \[Element] Booleans That is the behavior you described as the "spirit" of Mathematica and that is fine. So, I still do not know how to define a finite domain, however I will try to explore more of the direction you laid down. Thanks a lot. János In[71]:= $Version Out[71]= 5.1 for Mac OS X (October 25, 2004) ------ "..because Annushka has already bought sunflower oil, and not only bought it, but spilled it too." Bulgakov: Master and Margarita
- References:
- Re: finite domains
- From: Paul Abbott <paul@physics.uwa.edu.au>
- Re: finite domains
- From: Paul Abbott <paul@physics.uwa.edu.au>
- Re: finite domains