# list manipulation – “Total” function for a Boolean expression

I have a very long vector of the form

``````{a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,
a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,
a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4, ...}
``````

(here I just repeated the elements for simplicity, but in general, each element is different).
And I want to transform it into a Boolean expression where `Plus->Or` and `Times->And`.

What is the fastest way to do it? At the moment, I use `Replace`, but it’s really slow when the expression is bigger. Here the simpler example takes 0.000034 seconds:

``````RepeatedTiming({a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,
a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,
a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4} /. {Times -> And} /. {Plus -> Or})
``````

Also, is there an equivalent of the `Total` function for Boolean expressions?