dear group,
offlist I got a message from Johann Weilharter <johnny.weilharter at sbg.at> from Austria,
pointing to a file of Otto Prem (Handelsakademie, St. Johann, Austria) using
infix-operators to construct truth tables (=wtafel=Wahrheitstafel).
"=>"(r,s):= not r or s $ infix("=>") $
"<=>"(r,s):= not (r or s) or (r and s)$ infix("<=>") $
"xor"(r,s):= (r and not s) or (not r and s)$ infix("xor")$
/* Otto Prem, Handelsakademie St. Johann, Austria: */
wtafel('term):=block([zk:string(term),
li:listofvars(term),k0,k1,k2,k3,k4,k5,k6,k7,a1,a2],
k0:string(makelist([true,false],i,1,length(li))),
k1:substring(k0,2,slength(k0)),
k2:sconc("flatten(outermap(f,",k1,"))"),
k3:eval_string(k2),
k4:map(args,k3),
k5:create_list(li[i]=x0[i],i,makelist(i,i,1,length(li))),
k6:sconc("map(lambda([x0],at(term,",k5,")),k4)"),
k7:eval_string(k6),
a1:makelist(endcons(k7[i],k4[i]),i,1,length(k4)),
a2:endcons(zk,li),
a3:cons(a2,a1),apply(matrix,a3) )$
wtafel(a xor b);
wtafel(x<=>y);
wtafel((not p and q) and ((not p) =>q));
wtafel(not(p and q)<=>not p or not q);
wtafel(not(not(a and b) and c));
wtafel((a or b)and(a or c));
ausdruck:readonly("logic expression (operators not, and, or, xor, =>, <=>)");
wtafel(''ausdruck);
Maybe this is of interest to other maxima users, too.
PS: I take the opportunity to point to a new German introduction to MAXIMA from Mag.
(=Magister= math theacher) Walter Wegscheider, Austria, link:
http://www.austromath.at/daten/maxima/index.htm
--
HTH Wolfgang
> -----Urspr?ngliche Nachricht-----
> Von: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] Im Auftrag von
> Wolfgang Lindner
> Gesendet: Freitag, 22. Juni 2007 23:12
> An: maxima-help
> Betreff: [Maxima] implication as infix operator
>
> dear group,
>
> I want to define the logical 'implication' as an infix operator:
>
> (%i1) implication(p,q) := ((not (p)) or (q));
> (%i2) "==>"(p, q) := ((not (p)) or (q));
> (%i3) infix ("==>", 41, 41)$
> (%i4) true ==> false;
> (%o4) false
>
> Here are my questions:
> (Q1) I'm not sure if I have choosen an appropriate l/r
> binding power with the value 41.
> Are there any conflicts possible?
> (Q2) Is it possible to ask MAXIMA for the binding powers of
> an (pre)defined operator?
>
> (Bug?): the following example of the help file entry 'infix'
> does _not_ work for me, I get an error (wxMaxima 0.7.2, Maxima 5.12):
>
> (ko) "@"(a, b) := sconcat("(", a, ",", b, ")")$ whereas
> using '~' instead of the at-sign works:
> (ok) "~"(a, b) := sconcat("(", a, ",", b, ")")$
>
> (Q3) is there a list of vorbidden/allowed signs for operators?
>
> HTH Wolfgang
--------------------------------------------------------------------------------