Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Head logic

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97065] Re: Head logic
  • From: "Drago Ganic" <dganic at vodatel.net>
  • Date: Wed, 4 Mar 2009 07:13:15 -0500 (EST)
  • References: <goj2bk$2qu$1@smc.vnet.net>

Hi Carlos,
this behavior/logic has nothing to do with Head, but with Mathematica's treatment of 
Integer and Symbol symbols. Unfortunately those symbols which do not have 
values and will never have values are interpreted by Mathematica in the same 
way as variables like

In[10]:= a == b
Out[10]= a == b

and not like constants:

In[11]:= Pi == MachinePrecision
Out[11]= False

The behavior for variables is ok since the output depends on their current 
values (e.g. b = a would evaluate to True; but {a = 3, b = 4} would evaluate 
to False). In the case of symbols like Pi or E the value is fixed (attribute 
Constant) and cannot be changed (attribute Protected) so predicates can 
always give True or False.

If Mathematica would use the attribute Protected in its evaluation of 
predicates (like  Equal[]) we would also get the expected definite behavior 
for Symbol and Integer symbols.

This would generally mean that, for example

In[12]:= Protect[{a, b}]
Out[12]= {"a", "b"}

In[13]:= a == b

would evaluate to False because the symbols have no values and are protected 
(so cannot have values). Those symbols are then just pure symbols and not 
variables. Integer and Symbol have both the Protected attributes and my 
suggestion is that Mathmatica should use it in evaluations.

Other opinions about this matter?

Greetings from Croatia,
Drago

<carlos at colorado.edu> wrote in message news:goj2bk$2qu$1 at smc.vnet.net...
> Entering
>
>   ClearAll[r];
>   Head[r]
>   Head[r]!=Symbol
>   Head[r]==Symbol
>
> give Symbol, False and True as expected. But
>
>   Head[r]==Integer
>
> evaluates to Symbol==Integer. Why not False?
> Head[r] is certainly not Integer. Likewise
>
>  r=4;
>  Head[r]==Integer
>  Head[r]!=Symbol
>  Head[r]==Symbol
>
> give True (correct) but  Integer!=Symbol and Integer==Symbol.
> Why not True and False?
> 



  • Prev by Date: Re: Conjecture: 2n+1= 2^i+p ; 6k-2 or 6k+2 = 3^i+p
  • Next by Date: Re: "Do What I Mean" - a suggestion for improving
  • Previous by thread: Re: Head logic
  • Next by thread: Re: Head logic