# Simplifying a logical expression with multivariate polynomials

I have several expressions similar to

a (a b + c d) != 0 || b (a b + c d) != 0 || c (a b + c d) != 0 || d (a b + c d) != 0


and I would like to reduce them maximally; in the above example, the given logical statement is clearly just equivalent to a b + c d != 0, but how to arrive at this?

Both Reduce and Resolve, as well as FullSimplify return it unchanged. I tried

BooleanConvert[
(a != 0 && a b + c d != 0) ||
(b != 0 && a b + c d != 0) ||
(c != 0 && a b + c d != 0) ||
(d != 0 && a b + c d != 0)
, "CNF"
]


but it stops at

(a != 0 || b != 0 || c != 0 || d != 0) && a b + c d != 0


Is there a way?

• If we know the required result, then Resolve[ForAll[{a, b, c, d}, Equivalent[(a != 0 && a b + c d != 0) || (b != 0 && a b + c d != 0) || (c != 0 && a b + c d != 0) || (d != 0 && a b + c d != 0), a b + c d != 0]]] confirms it by True. Feb 23 at 15:16
• @user64494 Thank you, this is important information. So it definitly should be doable in Mathematica somehow. Feb 23 at 15:26
• A possible reason for non-simplification could be that FullSimplify[(a != 0 || b != 0) && a b != 0] simplifies to a b != 0, whereas FullSimplify[(a != 0 || b != 0) && a + b != 0] does not simplify to a + b != 0 Feb 24 at 23:12

## 2 Answers

\$Version

"14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)"

Clear["Global*"]

expr = a  (a  b + c  d) != 0 || b  (a  b + c  d) != 0 ||
c  (a  b + c  d) != 0 || d  (a  b + c  d) != 0;


Tell Mathematica that the variables are boolean

Assuming[{a, b, c, d} ∈ Booleans, expr // Simplify]

(* a b + c d != 0 *)

• The variables are not assumed to be Boolean, or at least this is not stated and also not a necessary assumption for the desired simplification to hold. Feb 23 at 20:46
• @DanielLichtblau Actually I need it for complex numbers - or for that matter for any field... Feb 23 at 20:47

The following is a very manual approach, but might be informative

expr = a (a b + c d) != 0 || b (a b + c d) != 0 ||
c (a b + c d) != 0 || d (a b + c d) != 0;


Considering the negation of the expression feels more natural

Simplify[! expr]
(*
a (a b + c d) == 0 && b (a b + c d) == 0 && c (a b + c d) == 0 &&
d (a b + c d) == 0 *)


Employing an obvious rule

x_ y_ == 0 :> x == 0 || y == 0;

%% /. %
(* (a == 0 || a b + c d == 0) && (b == 0 ||
a b + c d == 0) && (c == 0 || a b + c d == 0) && (d == 0 ||
a b + c d == 0) *)


We get a simple expression

negative = FullSimplify[%]
(* (a == 0 && b == 0 && c == 0 && d == 0) || a b + c d == 0 *)


The following implication is obviously true

implication = Implies[First[negative], Last[negative]]
(*
a == 0 && b == 0 && c == 0 && d == 0 \[Implies] a b + c d == 0 *)


Mathematica but doesn't recognise this implication as true, but can recognise its negative as false

! FullSimplify[! implication]
(* True *)


Combining the implication and the statement we get

! (implication && negative) // BooleanConvert
(* a b + c d != 0 *)
`
• I believe this same observation (or rather its equivalent without negation) was made by @user64494 in a comment to the question. This, I believe, shows that potentially Mathematica can do it without the hint too somehow. Feb 24 at 15:43