ahmednabil88's answer is correct. Let me give you an explanation based on simple Boolean algebra. For self-containnedness we restate the problem here:
Given two close intervals [start1, end1], [start2, end2], we want a minimal
boolean expression that is true iff. the two intervals overlap.
It's hard to enuermate all the case of intersection. But there are only 2 cases when the two intervals don't overlap. The boolean expression for non-overlapping is:
$(start1 \leq end1 < start2 \leq end2) \vee (start2 \leq end2 < start1 \leq end1)$
We simply take the negation to get the expression for overlapping:
$\neg \big((start1 \leq end1 < start2 \leq end2) \vee (start2 \leq end2 < start1 \leq end1)\big)$
However, the implementation would be more efficient if we simplify the expression manually. We rewrite the expression first:
$\neg \big((start1 \leq end1 \wedge end1 < start2 \wedge start2 \leq end2) \vee (start2 \leq end2 \wedge end2 < start1 \wedge start1 \leq end1)\big)$
Note that $start1 \leq end1$ and $start2 \leq end2$ can be killed because they are already assumed to be true. So we have:
$\neg \big((end1 < start2) \vee (end2 < start1)\big)$
by De Morgan's rule, we have:
$ \neg(end1 < start2) \wedge \neg(end2 < start1)$
by De Morgan's rule again, we conclude that:
$ end1 \geq start2 \wedge end2 \geq start1 $