1-- Finite set constructions2-- 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.Finite8import Basic910namespace FiniteSet1112def insert (x A : Set) : Set:= {x} ∪ A13def doubleton (x y : Set) : Set:= {x} ∪ {y}1415theorem singleton.membership (x a : Set)16shows x ∈ {a} ↔ x = a17proof18simp [singleton, pair.membership]1920theorem union2.membership (x A B : Set)21shows x ∈ A ∪ B ↔ (x ∈ A ∨ x ∈ B)22proof23simp [union2, set.union, pair.membership]2425theorem union2.right (x A B : Set)26requires hx : x ∈ B27shows x ∈ A ∪ B28proof29simp3031theorem union2.commutative (A B : Set)32shows A ∪ B = B ∪ A33proof34ext y35simp3637theorem union2.idempotent (A : Set)38shows A ∪ A = A39proof40ext y41simp4243theorem union2.associative (A B C : Set)44shows (A ∪ B) ∪ C = A ∪ (B ∪ C)45proof46ext y47simp4849theorem insert.membership (x y A : Set)50shows x ∈ insert(y, A) ↔ (x = y ∨ x ∈ A)51proof52simp [insert, union2.membership, singleton.membership]5354theorem insert.self (x A : Set)55shows x ∈ insert(x, A)56proof57simp5859theorem insert.contains (x y A : Set)60requires hx : x ∈ A61shows x ∈ insert(y, A)62proof63simp6465theorem doubleton.membership (x a b : Set)66shows x ∈ doubleton(a, b) ↔ (x = a ∨ x = b)67proof68simp [doubleton, union2.membership, singleton.membership]6970theorem insert.restore (V x : Set)71requires member : x ∈ V72shows insert(x, V ∖ {x}) = V73proof74ext y75simp7677end FiniteSet7879exportopen Grace.Cumulus.Set.Finite.FiniteSet80