On Wed, 1 Feb 2006 10:29:24 -0700 Robert Dodier asked C Y: How does Axiom handle boolean expressions which don't evaluate to true or false? Likewise, what happens to if ... then ... else when the condition is a boolean expression which doesn't evaluate to true or false. Here are some examples. I'll try to use a "package agnostic" notation: Let A = 100. What does "(A > 0) and (B > A) or (C > A)" evaluate to? Maybe "(B > 100) or (C > 100)" ? Something else? Let X = 100. What does "if (X != 0) then (if (Y != 0) then X/Y else Y/X) else FOO" evaluate to? Maybe "if (Y != 0) then 100/Y else Y/100" ? Something else? fricas A:=100
Type: PositiveInteger?fricas A > 0
Type: Booleanfricas B > A fricas X:=100
Type: PositiveInteger?fricas X ~= 0
Type: Booleanfricas Y ~= 0
Type: Booleanfricas X/Y
Type: Fraction(Polynomial(Integer))fricas Y/X
Type: Polynomial(Fraction(Integer))fricas FOO
Type: Variable(FOO)fricas if X ~= 0 then if Y ~= 0 then X/Y else Y/X else FOO
Type: Fraction(Polynomial(Integer))I'm working on beefing up Maxima's handling of boolean and conditional expressions, and just for a point of reference I'm taking a look at what other packages do. If you have some links or references to the Axiom documentation that would be very helpful. Unlike Maxima, Axiom implements a strongly-typed language. All operators, variables and constants are assigned or assumed to be of a given type (i.e. they must be represented in some domain). By default Axiom makes the assumption: A:=100 that the A > 0 is made by the But the comparison: B > A is treated differently. Axiom doesn't know anything about
I think it would be fair to argue that this result violates the principle of least surprise for the first time Axiom user! Besides polynomials Axiom does have a domain allowing unevaluated expressions so you can write, for example: fricas P:Expression Integer Type: Voidfricas Q:Expression Integer Type: Voidfricas P+1
Type: Expression(Integer)fricas P+Q
Type: Expression(Integer)Unfortunately Axiom makes the mistake of actually implementing a total ordering on Expressions! Personally, I think this is a grave error. :( fricas P > Q I would prefer that in the domain Expression, the function So if a integration function returns something like "if a>0 then if b>0 then There's more, but hopefully that gives some idea of what I'm getting at. Best, Robert Dodier. |

an explanation of the results--Bill Page, Wed, 01 Feb 2006 18:09:20 -0600 reply