code for unevaluated Boolean and conditional expressions



On 5/4/06, Barton Willis <willisb at unk.edu> wrote:

> Why is the 'ev' needed after 'subst' in  (%i6)? My
> example is overly complicated, but it seemed like
> an interesting test.

Agreed, it's an interesting example.

> (%i1) load("boolsimp.lisp")$
> (%i2) f(x) := if x > 8 then f(x-1) + 3 else x;
> (%o2) f(x):=if x>8 then f(x-1)+3 else x
> (%i3) assume(q > 12);
> (%o3) [q>12]
> (%i4) f(q);
> (%o4) (if q-5>8 then f(q-6)+3 else q-5)+15
> (%i5) subst(q=13,%);
> (%o5) (if 8>8 then f(7)+3 else 8)+15
>
> (%i6) ev(%);   <-- why is this ev needed?
> (%o6) 23

That would be because relational expressions never simplify to true/false.
E.g. '(8 > 8); => 8 > 8, not false.

I think 8 > 8 should simplify to false, but I decided that modifying
the simplification of relational expressions is beyond the scope of
the unevaluated Boolean/conditional stuff.

> (%i7) f(13);
> (%o7) 23       <-- OK, agrees with %o6

The relational expressions get evaluated here (not just simplified).

best,
Robert