# Revision history [back]

A couple of answer elements :

• Sage per se has not (yet) symbolic logical operators (but see Trac#31911).

• Your (Mathematica ?) syntax is not Python : there is no such operators as && or ||...

With these limitations in mind, you can do :

sage: var("A, B, C, D")
(A, B, C, D)
sage: import sympy
sage: sympy.sympify('((A <= B) & (B <= C)) | ((A <= D) & (D <= C)) | ((B <= A) & (A <= D) & (D <= C)) | ((D >= C) & (A <= B) & (B <= C) ) | ((B <= A) & (D >= C))').simplify()
((A >= B) & (C <= D)) | ((C >= D) & (A <= D)) | ((A <= B) & (B <= C))


but this result cannot (yet) be translated in Sage.

There is some support for propositional logic in Sage, but these tools use string representation of the formulæ ; the translation to Sage symbolic expressions would require the addition of some support for symbolic logical functions (see the Trac cicket...).

FWIW :

sage: mathematica("FullSimplify[(A <= B && B <= C) || (A <= D && D <= C) || (B <= A && A <= D && D <= C) || (D >= C && A <= B && B <= C ) || (B <= A && D >= C)]")
(D >= C && B <= A) || (A <= B && B <= C) || (A <= D && D <= C)

sage: maxima_console()