Sanitize is not fool proof (yet) .Sanitize2 seems to work as advertized.
Subject: Sanitize is not fool proof (yet) .Sanitize2 seems to work as advertized.
From: Richard Fateman
Date: Mon, 1 Jan 2007 15:06:45 -0800
Aha, I see what is happening.. sanitize ends up evaluating the function body
after the substitution, so oddp(g32641) is changed to false.
Substitution into a function definition does not evaluate the body.
One way around this would be to use Lisp's sublis function instead of subst.
E.g, a non-evaluating Maxima version...
(defun $sublis(L target)
;; L looks like ((mlist) ((mequal) a 1)((mequal) b 2) ...)
(sublis (mapcar #'(lambda(r)(cons (cadr r)(caddr r)))(cdr L)) target))
;; some error checking of args would increase the function size by 3X or
more...
> -----Original Message-----
> From: Michel Van den Bergh [mailto:michel.vandenbergh at uhasselt.be]
> Sent: Monday, January 01, 2007 2:45 PM
> To: Richard Fateman
> Cc: maxima at math.utexas.edu
> Subject: Sanitize is not fool proof (yet) .Sanitize2 seems to work as
> advertized.
>
> Example
>
> f(x):=oddp(x)$
> f(1);
> true
> sanitize(f);
> f(g32641) := false
> f(1);
> false
>
> However sanitize2 works correctly
>
> f(x):=oddp(x)$
> sanitize2(f);
> f(g32629) := oddp(g32629)
> f(1);
> true;
>
> Note: sanitize2 does not sanitize local variables
>
> f(s):=block([t],local(t),t[4]:s[4],t[4]);
> sanitize2(f);
> f(g34408):=block([t], local(t), t[4]: g34408[4], t[4] )
>
> which has the usual problems (see the earlier discussion on the list)
>
> I applied sanitize2 to the five (easy) functions in levin and the test
> script
> still completed succesfully (after commenting out the initial
> "kill(all)" of course).
> sanitize did not work at all.
>
>
> Michel