MathGroup Archive 1999

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

Search the Archive

Re: Assertion propagation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16460] Re: [mg16366] Assertion propagation
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sat, 13 Mar 1999 02:21:59 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

On Thu, Mar 11, 1999, Kevin Jaffe <kj0 at mailcity.com> wrote:

>In Section 2.3.5 of the manual, it says:
>
>  However, Mathematica does not automatically
>  propagate assertions, so it cannot determine for
>  example that IntegerQ[x^2] is True. You must load
>  an appropriate Mathematica package to make this
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  possible.
>
>Which package is this?
>
>Thanks,
>
>KJ

I do not think there is any such package (???). However it is easy to
amke one. Here is an example:

In[1]:=
In[1]:=
Unprotect[IntegerQ];
IntegerQ[HoldPattern[Plus[x___]]]:=Apply[And,Map[IntegerQ,{x}]];
IntegerQ[HoldPattern[Times[x___]]]:=Apply[And,Map[IntegerQ,{x}]];
IntegerQ[x_^y_/;IntegerQ[x]&&IntegerQ[y]&&Positive[y]]=True;
Protect[IntegerQ];
Now you  define some variables to be integers:

In[2]:=
x/:IntegerQ[x]=True;y/:IntegerQ[y]=True;

Now Mathematica will "propagate assertions", to a limted extend of course:

In[3]:=
IntegerQ[x+y]
Out[3]=
True

In[4]:=
IntegerQ[x^2]

Out[4]=
True

In[5]:=
IntegerQ[x^x]
Out[5]=
False

However, if we add the rule:
In[6]:=
x/:Positive[x]=True
Out[6]=
True



You have to be careful not to exect too much, e.g.

In[7]:=
IntegerQ[x(x+1)/2]
Out[7]=
False

while of course x(x+1)/2 is an integer. 

Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/
http://eri2.tuins.ac.jp/



  • Prev by Date: Re: Matrix Manipulation
  • Next by Date: Problem: Smallest sphere including all 3D points
  • Previous by thread: Assertion propagation
  • Next by thread: Supressing Plot Output