/-- The **supremum** of a non-empty family `S` of cuts that is bounded above by a cut `B`: the
union of the family. The proofs check that the union is again a cut: it is non-empty because `S`
and its members are; it is not everything because it lies inside `B`; and it is closed
downwards and has no greatest element because each member is and has none. -/
def sup (S : Set Cut) (hS : S.Nonempty) (hB : ∃ B : Cut, ∀ A ∈ S, A ≤ B) : Cut where
carrier := ⋃ A ∈ S, A.carrier
nonempty := by
obtain ⟨A, hA⟩ := hS
obtain ⟨p, hp⟩ := A.nonempty
exact ⟨p, Set.mem_biUnion hA hp⟩
ne_univ := by
obtain ⟨B, hB⟩ := hB
obtain ⟨q, hq⟩ : ∃ q, q ∉ B.carrier := by
by_contra h
exact B.ne_univ (Set.eq_univ_of_forall fun q => by_contra fun hq => h ⟨q, hq⟩)
intro h
have hq' : q ∈ ⋃ A ∈ S, A.carrier := h ▸ Set.mem_univ q
obtain ⟨A, hA, hqA⟩ := Set.mem_iUnion₂.mp hq'
exact hq (hB A hA hqA)
lower := by
intro p q hp hqp
obtain ⟨A, hA, hpA⟩ := Set.mem_iUnion₂.mp hp
exact Set.mem_biUnion hA (A.lower hpA hqp)
no_max := by
intro p hp
obtain ⟨A, hA, hpA⟩ := Set.mem_iUnion₂.mp hp
obtain ⟨q, hqA, hpq⟩ := A.no_max p hpA
exact ⟨q, Set.mem_biUnion hA hqA, hpq⟩