# HG changeset patch # User paulson # Date 1732291542 0 # Node ID 53e61087bc6f4f5b3bd568fa58d67c508bbe2c0e # Parent e43bff789ac0a165e7e79e27e38ae834c880aa35 Introduced the function some_elem for grabbing an element from a non-empty set, and simplified the theorem the_elem_image_unique diff -r e43bff789ac0 -r 53e61087bc6f src/HOL/Hilbert_Choice.thy --- a/src/HOL/Hilbert_Choice.thy Fri Nov 22 14:54:00 2024 +0000 +++ b/src/HOL/Hilbert_Choice.thy Fri Nov 22 16:05:42 2024 +0000 @@ -147,6 +147,34 @@ qed +subsection \Getting an element of a nonempty set\ + +definition some_elem :: "'a set \ 'a" + where "some_elem A = (SOME x. x \ A)" + +lemma some_elem_eq [simp]: "some_elem {x} = x" + by (simp add: some_elem_def) + +lemma some_elem_nonempty: "A \ {} \ some_elem A \ A" + unfolding some_elem_def by (auto intro: someI) + +lemma is_singleton_some_elem: "is_singleton A \ A = {some_elem A}" + by (auto simp: is_singleton_def) + +lemma some_elem_image_unique: + assumes "A \ {}" + and *: "\y. y \ A \ f y = a" + shows "some_elem (f ` A) = a" + unfolding some_elem_def +proof (rule some1_equality) + from \A \ {}\ obtain y where "y \ A" by auto + with * \y \ A\ have "a \ f ` A" by blast + then show "a \ f ` A" by auto + with * show "\!x. x \ f ` A" + by auto +qed + + subsection \Function Inverse\ lemma inv_def: "inv f = (\y. SOME x. f x = y)" diff -r e43bff789ac0 -r 53e61087bc6f src/HOL/Set.thy --- a/src/HOL/Set.thy Fri Nov 22 14:54:00 2024 +0000 +++ b/src/HOL/Set.thy Fri Nov 22 16:05:42 2024 +0000 @@ -1834,14 +1834,13 @@ lemma the_elem_image_unique: assumes "A \ {}" - and *: "\y. y \ A \ f y = f x" - shows "the_elem (f ` A) = f x" + and *: "\y. y \ A \ f y = a" + shows "the_elem (f ` A) = a" unfolding the_elem_def proof (rule the1_equality) from \A \ {}\ obtain y where "y \ A" by auto - with * have "f x = f y" by simp - with \y \ A\ have "f x \ f ` A" by blast - with * show "f ` A = {f x}" by auto + with * \y \ A\ have "a \ f ` A" by blast + with * show "f ` A = {a}" by auto then show "\!x. f ` A = {x}" by auto qed