1-- Foundational set mathematics2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Set.Core8import Hierarchy910-- The public root of Cumulus set theory: extensional mathematics,11-- classes, relations, Foundation, ordinals, rank, and the cumulative hierarchy.12predicate Nonempty (A : Set) :=∃ x, x ∈ A13predicate Disjoint (A B : Set) := A ∩ B =∅1415theorem Subset.transitive (A B C : Set)16requires hAB : A ⊆ B17requires hBC : B ⊆ C18shows (A ⊆ C)19proof20simp2122theorem Subset.antisymmetric (A B : Set)23requires hAB : A ⊆ B24requires hBA : B ⊆ A25shows A = B26proof27ext y28simp2930theorem empty.subset (A : Set)31shows (∅⊆ A)32proof33simp3435theorem union2.subset (A B C : Set)36requires hA : A ⊆ C37requires hB : B ⊆ C38shows (A ∪ B ⊆ C)39proof40simp4142theorem union2.subset_left (A B : Set)43shows (A ⊆ A ∪ B)44proof45simp4647theorem union2.subset_right (A B : Set)48shows (B ⊆ A ∪ B)49proof50simp5152theorem union.contains (x A S : Set)53requires hA : A ∈ S54requires hx : x ∈ A55shows x ∈⋃(S)56proof57simp [set.union]5859theorem union.subset (S B : Set)60requires h : ∀ A ∈ S, (A ⊆ B)61shows (⋃(S) ⊆ B)62proof63intros x hx64simp [set.union] at hx65obtain⟨A, hAS, hxA⟩:= hx66exact h with A, hAS, x, hxA6768theorem intersection.subset_right (A B : Set)69shows (A ∩ B ⊆ B)70proof71simp7273theorem intersection.greatest (A B C : Set)74requires hA : C ⊆ A75requires hB : C ⊆ B76shows (C ⊆ A ∩ B)77proof78simp7980theorem difference.subset_left (A B : Set)81shows (A ∖ B ⊆ A)82proof83simp8485theorem powerset.membership_iff (A B : Set)86shows A ∈𝒫(B) ↔ (A ⊆ B)87proof88simp8990theorem powerset.monotone (A B : Set)91requires h : A ⊆ B92shows (𝒫(A) ⊆𝒫(B))93proof94simp [Subset, set.powerset]9596theorem Nonempty.singleton (x : Set)97shows Nonempty({x})98proof99simp [Nonempty]100101theorem Nonempty.ne_empty (A : Set)102requires inhabited : Nonempty(A)103shows A ≠∅104proof105intro equal106obtain⟨x, member⟩:= inhabited107rw equal at member108exactset.empty with member109110-- The converse needs only classical logic and extensionality.111theorem Nonempty.of_ne_empty (A : Set)112requires different : A ≠∅113shows Nonempty(A)114proof115by_contra absent116apply different117ext x118constructor119 . intro member120exfalso121apply absent122unfold Nonempty123refine⟨x, member⟩124 . intro member125exfalso126exactset.empty with member127128theorem Nonempty.iff_ne_empty (A : Set)129shows Nonempty(A) ↔ A ≠∅130proof131simp [Nonempty.ne_empty, Nonempty.of_ne_empty]132133theorem Disjoint.symmetric (A B : Set)134requires h : Disjoint(A, B)135shows Disjoint(B, A)136proof137unfold Disjoint at h138unfold Disjoint139 rwa intersection.commutative140141theorem singleton.ne_empty (x : Set)142shows {x} ≠∅143proof144intro singletonEmpty145haveself:= singleton.self at x146rw singletonEmpty atself147simp148149