# matching Inequalities

Consider the following list

list={0 < x < 1/12, 0 < x < 1/4}


I wish to find the intersection of the two ranges of x and check if the result is an element of the above list, i.e.

In:=Simplify[And @@ list]
out:=0<x<1/12


Now I want to check if the above range of x belongs to the list.

in:=MemberQ[list, Simplify[And @@ list]]
out:= False


But It is clear that such a range is an element of list. This is not giving the expected result because the Heads are not matching.

in:=FullForm[Simplify[And @@ list]]
out:=Inequality[0,Less,x,Less,Rational[1,12]]


Whereas,

in:=FullForm[0 < x < 1/12]
out:=Less[0,x,Rational[1,12]]


How to resolve this?

• This is weird. I didn't know it converted to Inequality. A possible workaround is to construct intervals like intervals = Interval[{First[#], Last[#]}] & /@ list; then do result = IntervalIntersection @@ intervals and MemberQ[intervals, result] is true. But this will not work well for arbitrary inequalities, only these two sided ones. Commented Aug 3, 2020 at 16:40
• Forcing it to expand the inequalities into logical expressions with && seems to work around it too MemberQ[ReduceInequalityExpand /@ list, ReduceInequalityExpand[Simplify[And @@ list2]]] Commented Aug 3, 2020 at 17:52
• Yes. After using LogicalExpand, it is working Commented Aug 3, 2020 at 18:18

Your intent is interval arithmetics. Mathematica offers specialized built-ins to deal with intervals.

Interval

IntervalUnion[Interval[{0, 1/12}], Interval[{0, 1/4}]]

Interval[{0, 1/4}]

IntervalIntersection[Interval[{0, 1/12}], Interval[{0, 1/4}]]

Interval[{0, 1/12}]

FullForm@IntervalIntersection[Interval[{0, 1/12}], Interval[{0, 1/4}]]

Interval[List,[0,Rational[1,12]]]


This is some a tautology and the check corresponding Your MemberQ input is redundant.

On the other hand there is the built-in IntervalMemberQ:

IntervalMemberQ[Interval[{0, 1/12}], Interval[{0, 1/15}]]

True


To more directly:

Equal[Inequality[0, Less, x, Less, Rational[1, 12]],
Less[0, x, Rational[1, 12]]]

(0 < x < 1/12) == (0 < x < 1/12)


The output is not True and

Expand[%]

does not alter any.

But

Equivalent@Equal[Inequality[0, Less, x, Less, Rational[1, 12]], Less[0, x, Rational[1, 12]]]

True

Equivalent represents the logical equivalence of both representation.

Equivalent[%741] // TautologyQ

True

TautologyQ@Equal[Inequality[0, Less, x, Less, Rational[1, 12]],
Less[0, x, Rational[1, 12]]]

False


It is in the terms of Mathematica not a direct tautology, but is set with Equal.

NumberLinePlot[{Interval[{0, 1/4}], Interval[{0, 1/12}]}]


This does not work with the Inequality.

NumberLinePlot[Simplify[And @@ list], {x, 0, .1}]


This brings up the real differences between both representation and how there are meant to be made equal in Mathematica.

And it visualizes the main drawback. The interval in Mathematica is closed, the inequalities are strict and therefore open.

The very most suitable answer is use Reduce:

Reduce[list, x]


0 < x < 1/12

Reduce[Inequality[0, Less, x, Less, Rational[1, 12]], x]


0 < x < 1/12

FullForm of both is the very same.

FullForm@Reduce[Inequality[0, Less, x, Less, Rational[1, 12]], x]


Inequality[0,Less,x,Less,Rational[1,12]]

FullForm@Reduce[list, x] Inequality[0,Less,x,Less,Rational[1,12]]

FullForm@Reduce[Inequality[0, Less, x, Less, Rational[1, 12]], x]==FullForm@Reduce[list, x]


True

• Equivalent@Equal[Inequality[0, Less, x, Less, Rational[1, 12]], Less[0, x, Rational[1, 12]]] This isn't doing what you think. Try Equivalent@Equal[1, 0] for example. It returns True. Commented Aug 3, 2020 at 17:30