Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If we assume that all $A,B,C,D$ are real, we can use cylindrical algebraic decomposition (CAD) to simplify such an expression (in general, CAD can handle logical formulas involving polynomial (in)equalities). Sage has an interface to QEPCAD (QEPCAD itself, however, I believe is not shipped with sage, so has to be installed) which is one of the most popular implementations of CAD. Here is how QEPCAD simplifies your expression:

sage: from sage.interfaces.qepcad import qepcad_formula, qepcad, qformula
sage: var("A,B,C,D")
sage: qf = qepcad_formula
sage: expr = qf.or_([qf.and_([A<=B, B<=C]), qf.and_([A<=D, D<=C]), qf.and_([B<=A, A<=D, D<=C]), qf.and_([D>=C, A<=B, B<=C]), qf.and_([B<=A, D>=C])])
sage: qepcad(expr)
[ B - A >= 0 /\ C - B >= 0 ] \/ [ D - A >= 0 /\ D - C <= 0 ] \/ [ B - A <= 0 /\ D - C >= 0 ]