1 | initial version |

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()
;;; Loading #P"/usr/local/sage-9/local/lib/ecl-21.2.1/sb-bsd-sockets.fas"
;;; Loading #P"/usr/local/sage-9/local/lib/ecl-21.2.1/sockets.fas"
Maxima 5.45.0 https://maxima.sourceforge.io
using Lisp ECL 21.2.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) simplify((A <= B and B <= C) or (A <= D and D <= C) or (B <= A and A <= D and D <= C) or (D >= C and A <= B and B <= C ) or (B <= A and D >= C));
(%o1) simplify(((A <= B) and (B <= C)) or ((A <= D) and (D <= C))
or ((B <= A) and (A <= D) and (D <= C))
or ((D >= C) and (A <= B) and (B <= C)) or ((B <= A) and (D >= C)))
```

HTH,

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.