rm arith2.adv
/bin/umodem arith2.adv STOP
{ comments are enclosed by curly-braces;
no nested comments are allowed }
{remonter }
Compute(Z) => U(Z);
Compute(S x) => S (Compute x);
S(U x) => U (S x);
{ addition
these rules work when the arguments are numerals
but not for all arbitrary expressions
}
{Compute(Add Z y) => Compute(y);
Compute(Add (S x) y) => S (Compute(Add x y));}
Compute (Add x y) => Add (Compute x) y;
Add (U x) y => Add x (Compute y);
Add Z (U y) => (U y);
Add (S x) (U y) => S (Add x (U y));
{Add x (U y) => U (Add x y) --- inutile !!!}
{ define multiplication (Mult) here }
Compute(Mult x y) => Mult (Compute x) y;
Mult (U x) y => Mult x (Compute y);
Mult (S x) (U y) => Add y (Compute(Mult x y));
Mult Z (U y) => U Z;
{ when all other computation is done }
U x => x;
. { end of rules }
STOP
advise run arith2.adv arith.tests
advise arith arith2.adv