reduce imported mathlib chunk

This commit is contained in:
Jon Eugster
2023-04-04 21:29:10 +02:00
parent 2ec897fa39
commit 94b5af1623
122 changed files with 715 additions and 863 deletions
@@ -1,7 +1,6 @@
import Adam.Metadata
import Mathlib.Init.Set
import Mathlib.Tactic.Tauto
import Adam.Options.MathlibPart
set_option tactic.hygienic false
set_option autoImplicit false
@@ -1,7 +1,5 @@
import Adam.Metadata
import Mathlib.Init.Set
import Mathlib.Tactic.Tauto
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,7 +1,6 @@
import Adam.Metadata
import Mathlib.Init.Set
import Mathlib.Tactic.Tauto
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,9 +1,7 @@
import Adam.Metadata
import Adam.Levels.SetTheory.L03_Subset
import Mathlib.Init.Set
import Mathlib.Tactic.Tauto
import Mathlib
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,10 +1,7 @@
import Adam.Metadata
import Adam.Levels.SetTheory.L04_SubsetEmpty
--import Mathlib.Data.Set.Basic
import Mathlib.Init.Set
import Mathlib.Tactic.Tauto
import Mathlib.Tactic.PushNeg
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,7 +1,7 @@
import Adam.Metadata
import Adam.Levels.SetTheory.L05_Empty
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,6 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,6 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
set_option tactic.hygienic false
@@ -1,6 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory"
@@ -1,6 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory"
@@ -1,5 +1,5 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory"
@@ -1,6 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory"
@@ -1,6 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory"
@@ -1,8 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib.Tactic.Ring
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory2"
@@ -1,8 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib.Tactic.Ring
import Adam.Options.MathlibPart
import Adam.ToBePorted
@@ -1,8 +1,7 @@
import Adam.Metadata
import Mathlib
import Mathlib.Algebra.Parity
import Mathlib.Tactic.Ring
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory2"
@@ -1,8 +1,7 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory2"
@@ -1,8 +1,7 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory2"
@@ -1,8 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib.Tactic.Ring
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory2"
@@ -1,8 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory2"
@@ -1,8 +1,6 @@
import Adam.Metadata
import Mathlib.Data.Set.Basic
import Mathlib.Algebra.Parity
import Mathlib.Tactic.Ring
import Adam.Options.MathlibPart
Game "Adam"
World "SetTheory"
@@ -1,4 +1,4 @@
import Mathlib
open Set
+243 -253
View File
@@ -1,296 +1,286 @@
import Adam.Metadata
-- import Adam.Metadata
import Mathlib.Order.SymmDiff
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic.Use
import Mathlib.Tactic.SolveByElim
import Mathlib.Tactic.Tauto
import Mathlib.Tactic.ByContra
import Mathlib.Tactic.Lift
import Mathlib.Data.Set.Basic
import Mathlib.Data.Finset.Powerset
import Mathlib.Tactic.LibrarySearch
import Mathlib
-- import Adam.Options.MathlibPart
set_option tactic.hygienic false
-- set_option tactic.hygienic false
Game "Adam"
World "SetTheory"
Level 1
-- Game "Adam"
-- World "SetTheory"
-- Level 1
Title "Mengen"
-- Title "Mengen"
Introduction
"
In diesem Kapitel schauen wir uns Mengen an.
-- Introduction
-- "
-- In diesem Kapitel schauen wir uns Mengen an.
Zuerst ein ganz wichtiger Punkt: Alle Mengen in Lean sind homogen. Das heisst,
alle Elemente in einer Menge haben den gleichen Typ.
-- Zuerst ein ganz wichtiger Punkt: Alle Mengen in Lean sind homogen. Das heisst,
-- alle Elemente in einer Menge haben den gleichen Typ.
Zum Beispiel `{1, 4, 6}` ist eine Menge von natürlichen Zahlen. Aber man kann keine
Menge `{(2 : ℕ), {3, 1}, \"e\", (1 : ℂ)}` definieren, da die Elemente unterschiedliche Typen haben.
-- Zum Beispiel `{1, 4, 6}` ist eine Menge von natürlichen Zahlen. Aber man kann keine
-- Menge `{(2 : ℕ), {3, 1}, \"e\", (1 : ℂ)}` definieren, da die Elemente unterschiedliche Typen haben.
Für einen Typen `{X : Type*}` definiert damit also `set X` der Type aller Mengen mit Elementen aus
`X`. `set.univ` ist dann ganz `X` also Menge betrachtet, und es ist wichtig den Unterschied
zu kennen: `(univ : set X)` und `(X : Typ*)` haben nicht den gleichen Typ und sind damit auch nicht
austauschbar!
-- Für einen Typen `{X : Type*}` definiert damit also `set X` der Type aller Mengen mit Elementen aus
-- `X`. `set.univ` ist dann ganz `X` also Menge betrachtet, und es ist wichtig den Unterschied
-- zu kennen: `(univ : set X)` und `(X : Typ*)` haben nicht den gleichen Typ und sind damit auch nicht
-- austauschbar!
Am anderen Ende sitzt die leere Menge `(∅ : set X)` (`\\empty`). Bei `univ` und `∅` versucht Lean
automatisch den Typ zu erraten, in exotischen Beispielen muss man wie oben diesen explizit angeben.
-- Am anderen Ende sitzt die leere Menge `(∅ : set X)` (`\\empty`). Bei `univ` und `∅` versucht Lean
-- automatisch den Typ zu erraten, in exotischen Beispielen muss man wie oben diesen explizit angeben.
Als erste Operationen schauen wir uns `∪` (`\\union` oder `\\cup`), `∩`
(`\\inter` oder `\\cap`) und `\\` (`\\\\` oder `\\ `)
-- Als erste Operationen schauen wir uns `∪` (`\\union` oder `\\cup`), `∩`
-- (`\\inter` oder `\\cap`) und `\\` (`\\\\` oder `\\ `)
"
-- "
open Set
-- open Set
Statement
"Wenn $B$ wahr ist, dann ist die Implikation $A \\Rightarrow (A ∧ B)$ wahr."
{X : Type _} {A B : Set X} : univ \ (A ∩ B) ∪ ∅ = (univ \ A) ∪ (univ \ B) ∪ (A \ B) := by
rw [Set.diff_inter]
rw [Set.union_empty]
rw [Set.union_assoc]
rw [←Set.union_diff_distrib]
rw [Set.univ_union]
-- Statement
-- "Wenn $B$ wahr ist, dann ist die Implikation $A \\Rightarrow (A ∧ B)$ wahr."
-- {X : Type _} {A B : Set X} : univ \ (A ∩ B) ∪ ∅ = (univ \ A) ∪ (univ \ B) ∪ (A \ B) := by
-- rw [Set.diff_inter]
-- rw [Set.union_empty]
-- rw [Set.union_assoc]
-- rw [←Set.union_diff_distrib]
-- rw [Set.univ_union]
NewTactic rw
-- NewTactic rw
example : 4 ∈ (univ : Set ℕ) := by
trivial
-- example : 4 ∈ (univ : Set ℕ) := by
-- trivial
example (A : Set ℕ) : 4 ∉ (∅ : Set ℕ) := by
trivial
-- example (A : Set ℕ) : 4 ∉ (∅ : Set ℕ) := by
-- trivial
example (A : Set ℕ) : A ⊆ univ := by
intro x h
trivial
-- example (A : Set ℕ) : A ⊆ univ := by
-- intro x h
-- trivial
-- -- subset_empty_iff
-- example {s : Set α} : s ⊆ ∅ ↔ s = ∅ := by
-- -- -- subset_empty_iff
-- -- example {s : Set α} : s ⊆ ∅ ↔ s = ∅ := by
-- -- constructor
-- -- intro h
-- -- rw [Subset.antisymm_iff]
-- -- constructor
-- -- assumption
-- -- simp only [empty_subset]
-- -- intro a
-- -- rw [Subset.antisymm_iff] at a
-- -- rcases a with ⟨h₁, h₂⟩
-- -- assumption
-- -- -- eq_empty_iff_forall_not_mem
-- -- example {s : Set α} : s = ∅ ↔ ∀ x, x ∉ s := by
-- -- rw [←subset_empty_iff]
-- -- rfl
-- -- -- nonempty_iff_ne_empty
-- -- example (X : Type _) (s : Set X) : Set.Nonempty s ↔ s ≠ ∅ := by
-- -- rw [Set.Nonempty]
-- -- rw [ne_eq, eq_empty_iff_forall_not_mem]
-- -- push_neg
-- -- rfl
-- -- example (A B : ℝ): A = B ↔ A ≤ B ∧ B ≤ A := by library_search
-- namespace Finset
-- theorem powerset_singleton {U : Type _} [DecidableEq U] (x : U) :
-- Finset.powerset {x} = {∅, {x}} := by
-- ext y
-- rw [mem_powerset, subset_singleton_iff, mem_insert, mem_singleton]
-- end Finset
-- /- The powerset of a singleton contains only `∅` and the singleton. -/
-- theorem powerset_singleton {U : Type _} (x : U) :
-- 𝒫 ({x} : Set U) = {∅, {x}} := by
-- ext y
-- rw [mem_powerset_iff, subset_singleton_iff_eq]
-- rw [mem_insert_iff, mem_singleton_iff]
-- lemma mem_powerset_insert_iff {U : Type _} (A S : Set U) (x : U) :
-- S ∈ 𝒫 (insert x A) ↔ S \ {x} ∈ 𝒫 A := by
-- rw [mem_powerset_iff, mem_powerset_iff, diff_singleton_subset_iff]
-- -- lemma powerset_insert {U : Type _} (A : Set U) (x : U) :
-- -- 𝒫 (insert x A) = 𝒫 A ∪ ({B : Set U | B \ {x} ∈ 𝒫 A}) := by
-- -- sorry
-- theorem subset_insert_iff_of_not_mem {U : Type _ }{s t : Set U} (h : a ∉ s) : s ⊆ insert a t ↔ s ⊆ t := by
-- rw [subset_insert_iff, erase_eq_of_not_mem h]
-- lemma mem_powerset_insert_iff₂ {U : Type _} (A S : Set U) (x : U) :
-- S ∈ 𝒫 (insert x A) ↔ S ∈ 𝒫 A ∨ ∃ B ∈ 𝒫 A , insert x B = S := by
-- simp_rw [mem_powerset_iff]
-- constructor
-- intro h
-- rw [Subset.antisymm_iff]
-- constructor
-- assumption
-- simp only [empty_subset]
-- intro a
-- rw [Subset.antisymm_iff] at a
-- rcases a with ⟨h₁, h₂⟩
-- assumption
-- -- eq_empty_iff_forall_not_mem
-- example {s : Set α} : s = ∅ ↔ ∀ x, x ∉ s := by
-- rw [←subset_empty_iff]
-- rfl
-- -- nonempty_iff_ne_empty
-- example (X : Type _) (s : Set X) : Set.Nonempty s ↔ s ≠ ∅ := by
-- rw [Set.Nonempty]
-- rw [ne_eq, eq_empty_iff_forall_not_mem]
-- push_neg
-- rfl
-- example (A B : ℝ): A = B ↔ A ≤ B ∧ B ≤ A := by library_search
namespace Finset
theorem powerset_singleton {U : Type _} [DecidableEq U] (x : U) :
Finset.powerset {x} = {∅, {x}} := by
ext y
rw [mem_powerset, subset_singleton_iff, mem_insert, mem_singleton]
end Finset
/- The powerset of a singleton contains only `∅` and the singleton. -/
theorem powerset_singleton {U : Type _} (x : U) :
𝒫 ({x} : Set U) = {∅, {x}} := by
ext y
rw [mem_powerset_iff, subset_singleton_iff_eq]
rw [mem_insert_iff, mem_singleton_iff]
lemma mem_powerset_insert_iff {U : Type _} (A S : Set U) (x : U) :
S ∈ 𝒫 (insert x A) ↔ S \ {x} ∈ 𝒫 A := by
rw [mem_powerset_iff, mem_powerset_iff, diff_singleton_subset_iff]
-- · intro h
-- by_cases hs : x ∈ S
-- · sorry
-- · left
-- rw [Finset.subset_insert_iff_of_not_mem]
-- · intro h
-- rcases h with h | ⟨B, h₁, h₂⟩
-- · exact le_trans h (subset_insert x A)
-- · rw [←h₂]
-- exact insert_subset_insert h₁
-- lemma powerset_insert {U : Type _} (A : Set U) (x : U) :
-- 𝒫 (insert x A) = 𝒫 A ∪ ({B : Set U | B \ {x} ∈ 𝒫 A}) := by
-- 𝒫 (insert x A) = A.powerset ∪ A.powerset.image (insert x) := by
-- rw [Subset.antisymm_iff]
-- constructor <;>
-- intro B hB <;>
-- simp_rw [mem_powerset_insert_iff₂, mem_union, mem_image] at hB ⊢ <;>
-- assumption
-- example : powerset {0, 1} = {∅, {0}, {1}, {0, 1}} := by
-- simp_rw [powerset_insert, powerset_singleton, Finset.powerset_insert, Finset.powerset_singleton]
-- simp only [image_insert_eq, union_insert, image_singleton, union_singleton]
-- simp only [insert_comm, ←insert_emptyc_eq]
-- example [DecidableEq ℕ] : Finset.powerset {0, 1} = {∅, {0}, {1}, {0, 1}} := by
-- repeat' rw [@ Finset.powerset_insert ℕ]
-- repeat' rw [@Finset.powerset_singleton ℕ]
-- --simp only [image_insert_eq, union_insert, image_singleton, union_singleton]
-- example : powerset {0, 1, 2, 4} =
-- {∅, {0}, {1}, {0, 1}, {2}, {1, 2}, {0, 2}, {0, 1, 2},
-- {4}, {0, 4}, {1, 4}, {0, 1, 4}, {2, 4}, {1, 2, 4}, {0, 2, 4}, {0, 1, 2, 4}} := by
-- simp_rw [powerset_insert, powerset_singleton]
-- simp_rw [image_insert_eq, image_singleton]
-- example : Finset.powerset ({0, 1} : Finset ℕ) = {{0, 1}, ∅, {1}, {0}} := by
-- have h : Finset.powerset ({0, 1} : Finset ℕ) = {∅, {0}, {1}, {0, 1}}
-- rfl
-- rw [h]
-- simp only []
-- example : ({∅, {0}, {1}, {0, 1}} : Finset (Finset ℕ)) = {∅, {1}, {0}, {0, 1}} := by
-- simp only []
-- lemma subset_of_subset_diff {U : Type _} (A B C : Set U) (h : A ⊆ B \ C) : A ⊆ B :=
-- fun _ hx => mem_of_mem_diff (h hx)
-- lemma subset_of_subset_diff' {U : Type _} (A B C : Set U) (h : A ⊆ B) : A \ C ⊆ B :=
-- sorry
theorem subset_insert_iff_of_not_mem {U : Type _ }{s t : Set U} (h : a ∉ s) : s ⊆ insert a t ↔ s ⊆ t := by
rw [subset_insert_iff, erase_eq_of_not_mem h]
-- lemma mem_powerset' {U : Type _} {A B C : Set U}
-- (h' : B ∈ 𝒫 C) (h : A ⊆ B) :
-- A ∈ 𝒫 C := by
-- rw [mem_powerset_iff] at h' ⊢
-- exact le_trans h h'
lemma mem_powerset_insert_iff₂ {U : Type _} (A S : Set U) (x : U) :
S ∈ 𝒫 (insert x A) ↔ S ∈ 𝒫 A ∨ ∃ B ∈ 𝒫 A , insert x B = S := by
simp_rw [mem_powerset_iff]
constructor
· intro h
by_cases hs : x ∈ S
· sorry
· left
rw [Finset.subset_insert_iff_of_not_mem]
· intro h
rcases h with h | ⟨B, h₁, h₂⟩
· exact le_trans h (subset_insert x A)
· rw [←h₂]
exact insert_subset_insert h₁
lemma powerset_insert {U : Type _} (A : Set U) (x : U) :
𝒫 (insert x A) = A.powerset ∪ A.powerset.image (insert x) := by
rw [Subset.antisymm_iff]
constructor <;>
intro B hB <;>
simp_rw [mem_powerset_insert_iff₂, mem_union, mem_image] at hB ⊢ <;>
assumption
example : powerset {0, 1} = {∅, {0}, {1}, {0, 1}} := by
simp_rw [powerset_insert, powerset_singleton, Finset.powerset_insert, Finset.powerset_singleton]
simp only [image_insert_eq, union_insert, image_singleton, union_singleton]
simp only [insert_comm, ←insert_emptyc_eq]
example [DecidableEq ℕ] : Finset.powerset {0, 1} = {∅, {0}, {1}, {0, 1}} := by
repeat' rw [@ Finset.powerset_insert ℕ]
repeat' rw [@Finset.powerset_singleton ℕ]
--simp only [image_insert_eq, union_insert, image_singleton, union_singleton]
example : powerset {0, 1, 2, 4} =
{∅, {0}, {1}, {0, 1}, {2}, {1, 2}, {0, 2}, {0, 1, 2},
{4}, {0, 4}, {1, 4}, {0, 1, 4}, {2, 4}, {1, 2, 4}, {0, 2, 4}, {0, 1, 2, 4}} := by
simp_rw [powerset_insert, powerset_singleton]
simp_rw [image_insert_eq, image_singleton]
-- example (A B : Set ℕ) : A = B ↔ ∀ x, x ∈ A ↔ x ∈ B := by
-- exact ext_iff
example : Finset.powerset ({0, 1} : Finset ℕ) = {{0, 1}, ∅, {1}, {0}} := by
have h : Finset.powerset ({0, 1} : Finset ℕ) = {∅, {0}, {1}, {0, 1}}
rfl
rw [h]
simp only []
-- lemma NO.powerset_insert {U : Type _} (A : Set U) (x : U) :
-- 𝒫 (insert x A) = 𝒫 A ∪ ({insert x B | B ∈ 𝒫 A}) := by
-- ext y
-- rw [mem_powerset_insert_iff]
-- constructor
-- · intro h
-- rw [mem_union, mem_setOf]
-- by_cases hx : x ∈ y
-- · right
-- use y \ {x}
-- constructor
-- · assumption
-- · rw [insert_diff_singleton, insert_eq_of_mem hx]
-- · left
-- rw [diff_singleton_eq_self hx] at h
-- assumption
-- · intro h
-- rw [mem_union, mem_setOf] at h
-- rcases h with h | h
-- · apply mem_powerset' h
-- simp
-- · rcases h with ⟨B, hB⟩
-- rw [←hB.2]
-- apply mem_powerset' hB.1
-- simp
-- -- lemma xxx {U : Type _} (x y : U):
-- -- ({insert x B | B ∈ {∅, }}) = {({x} : Set U), {x, y}} := by
-- -- sorry
-- -- lemma hh {U : Type _} (A : Set U) (x : U) :
-- -- A \ {x} ∈
-- lemma diff_singleton_eq_iff {U : Type _} {A B : Set U} {x : U} :
-- A \ {x} = B ↔ A = B ∨ A = insert x B := by sorry
-- lemma x1 {U : Type _} (x : U) : insert x (∅ : Set U) = {x} := by sorry
-- --set_option maxHeartbeats 20000
example : ({∅, {0}, {1}, {0, 1}} : Finset (Finset ℕ)) = {∅, {1}, {0}, {0, 1}} := by
simp only []
-- example {U : Type _} {x y : U} : ({x, y} : Set U) = {y, x} := by
-- exact pair_comm x y
-- example {U : Type _} {A : Set U} {x y : U} : insert x (insert y A) = insert y (insert x A) := by
-- exact insert_comm x y A
-- open Classical
-- #check decide
-- example : ({{0, 2}, {3, 5, 6}} : Set (Set ℕ)) = {{2, 0}, {5, 3, 6}} := by
-- rw [Subset.antisymm_iff]
-- constructor <;>
-- intro A hA <;>
-- simp_rw [mem_insert_iff, mem_singleton_iff] at *
-- · rw [pair_comm 2 0, insert_comm 5 3]
-- tauto
-- · rw [pair_comm 0 2, insert_comm 3 5]
-- tauto
-- example (A : Set ℕ) : ({{0, 2}, A, {3, 5, 6}} : Set (Set ℕ)) = {{2, 0}, {5, 3, 6}, A} := by
-- simp only [insert_comm, ←insert_emptyc_eq]
lemma subset_of_subset_diff {U : Type _} (A B C : Set U) (h : A ⊆ B \ C) : A ⊆ B :=
fun _ hx => mem_of_mem_diff (h hx)
lemma subset_of_subset_diff' {U : Type _} (A B C : Set U) (h : A ⊆ B) : A \ C ⊆ B :=
sorry
lemma mem_powerset' {U : Type _} {A B C : Set U}
(h' : B ∈ 𝒫 C) (h : A ⊆ B) :
A ∈ 𝒫 C := by
rw [mem_powerset_iff] at h' ⊢
exact le_trans h h'
example (A B : Set ℕ) : A = B ↔ ∀ x, x ∈ A ↔ x ∈ B := by
exact ext_iff
-- example : ({{0, 2}, {3, 5, 6}} : Finset (Finset ℕ)) = {{2, 0}, {5, 3, 6}} := by
-- simp only
lemma NO.powerset_insert {U : Type _} (A : Set U) (x : U) :
𝒫 (insert x A) = 𝒫 A ∪ ({insert x B | B ∈ 𝒫 A}) := by
ext y
rw [mem_powerset_insert_iff]
constructor
· intro h
rw [mem_union, mem_setOf]
by_cases hx : x ∈ y
· right
use y \ {x}
constructor
· assumption
· rw [insert_diff_singleton, insert_eq_of_mem hx]
· left
rw [diff_singleton_eq_self hx] at h
assumption
· intro h
rw [mem_union, mem_setOf] at h
rcases h with h | h
· apply mem_powerset' h
simp
· rcases h with ⟨B, hB⟩
rw [←hB.2]
apply mem_powerset' hB.1
simp
-- lemma xxx {U : Type _} (x y : U):
-- ({insert x B | B ∈ {∅, }}) = {({x} : Set U), {x, y}} := by
-- sorry
-- lemma hh {U : Type _} (A : Set U) (x : U) :
-- A \ {x} ∈
lemma diff_singleton_eq_iff {U : Type _} {A B : Set U} {x : U} :
A \ {x} = B ↔ A = B ∨ A = insert x B := by sorry
lemma x1 {U : Type _} (x : U) : insert x (∅ : Set U) = {x} := by sorry
--set_option maxHeartbeats 20000
example {U : Type _} {x y : U} : ({x, y} : Set U) = {y, x} := by
exact pair_comm x y
example {U : Type _} {A : Set U} {x y : U} : insert x (insert y A) = insert y (insert x A) := by
exact insert_comm x y A
open Classical
#check decide
example : ({{0, 2}, {3, 5, 6}} : Set (Set ℕ)) = {{2, 0}, {5, 3, 6}} := by
rw [Subset.antisymm_iff]
constructor <;>
intro A hA <;>
simp_rw [mem_insert_iff, mem_singleton_iff] at *
· rw [pair_comm 2 0, insert_comm 5 3]
tauto
· rw [pair_comm 0 2, insert_comm 3 5]
tauto
example (A : Set ℕ) : ({{0, 2}, A, {3, 5, 6}} : Set (Set ℕ)) = {{2, 0}, {5, 3, 6}, A} := by
simp only [insert_comm, ←insert_emptyc_eq]
example : ({{0, 2}, {3, 5, 6}} : Finset (Finset ℕ)) = {{2, 0}, {5, 3, 6}} := by
simp only
-- -- This works but does not scale well
-- ext x
-- simp_rw [powerset_insert, powerset_singleton]
-- simp_rw [mem_union, mem_setOf, mem_insert_iff, mem_singleton_iff]
-- simp_rw [diff_singleton_eq_iff, x1]
-- tauto
-- -- -- This works but does not scale well
-- -- ext x
-- -- simp_rw [powerset_insert, powerset_singleton]
-- -- simp_rw [mem_union, mem_setOf, mem_insert_iff, mem_singleton_iff]
-- -- simp_rw [diff_singleton_eq_iff, x1]
-- -- tauto
-- rw [Subset.antisymm_iff]
-- constructor
-- intro A hA
-- rw [mem_powerset_iff] at hA
-- simp_rw [mem_insert_iff, mem_singleton_iff] at *
-- -- rw [Subset.antisymm_iff]
-- -- constructor
-- -- intro A hA
-- -- rw [mem_powerset_iff] at hA
-- -- simp_rw [mem_insert_iff, mem_singleton_iff] at *
example : ({2, 3, 5} : Set ℕ) ⊆ {4, 2, 5, 7, 3} := by
intro a ha
simp_rw [Set.mem_insert_iff, Set.mem_singleton_iff] at *
tauto
-- example : ({2, 3, 5} : Set ℕ) ⊆ {4, 2, 5, 7, 3} := by
-- intro a ha
-- simp_rw [Set.mem_insert_iff, Set.mem_singleton_iff] at *
-- tauto
example : ({0} : Set ℕ) ∪ {1, 2} = {0, 2, 1} := by
rw [Subset.antisymm_iff]
intro A hA
--rw [Set.mem_insert_iff]
-- example : ({0} : Set ℕ) ∪ {1, 2} = {0, 2, 1} := by
-- rw [Subset.antisymm_iff]
-- intro A hA
-- --rw [Set.mem_insert_iff]
-- Trick:
-- attribute [default_instance] Set.instSingletonSet
-- -- Trick:
-- -- attribute [default_instance] Set.instSingletonSet
+66 -66
View File
@@ -1,96 +1,96 @@
import Adam.Metadata
import Mathlib
import Duper.Tactic
-- import Adam.Metadata
import Mathlib.Order.Disjoint
-- import Duper.Tactic
set_option tactic.hygienic false
Game "Adam"
World "SetTheory"
Level 4
-- import Mathlib.Order.Disjoint
Title "Mengen"
-- set_option tactic.hygienic false
Introduction
"
`∈ ∉ ⊆ ⊂ ⋃ ⋂`
"
-- Game "Adam"
-- World "SetTheory"
-- Level 4
open Set
-- Title "Mengen"
-- open_locale cardinal
-- Introduction
-- "
-- `∈ ∉ ⊆ ⊂ ⋃ ⋂`
-- "
variables {X : Type _} (x : X) (A B : Set X)
-- open Set
#check A.Nonempty
#check Nonempty A
#check insert x A -- {x} ∪ A
-- #check disjoint A B -- needs Mathlib.Order.Disjoint
#check A ∆ B
#check Nontrivial A
-- -- open_locale cardinal
#check ({2} : Set ℕ)
-- variables {X : Type _} (x : X) (A B : Set X)
example : ({2} : Set ℕ) ⊆ {4, 2, 3} := by
simp only [mem_singleton_iff, mem_insert_iff, or_self, singleton_subset_iff, or_false, or_true]
-- #check A.Nonempty
-- #check Nonempty A
-- #check insert x A -- {x} ∪ A
-- -- #check disjoint A B -- needs Mathlib.Order.Disjoint
-- #check A ∆ B
-- #check Nontrivial A
example : ({2, 3, 5} : Set ℕ) ⊆ {4, 2, 5, 7, 3} := by
intro n hn
simp only [mem_insert_iff, mem_singleton_iff] at *
tauto
-- #check ({2} : Set ℕ)
example : {2, 3, 5} ⊆ (univ : Set ℕ) := by
tauto
-- example : ({2} : Set ℕ) ⊆ {4, 2, 3} := by
-- simp only [mem_singleton_iff, mem_insert_iff, or_self, singleton_subset_iff, or_false, or_true]
example : 3 ∈ ({4, 2, 5, 7, 3} : Set ℕ) := by
tauto
-- example : ({2, 3, 5} : Set ℕ) ⊆ {4, 2, 5, 7, 3} := by
-- intro n hn
-- simp only [mem_insert_iff, mem_singleton_iff] at *
-- tauto
example : ({4, 9} : Set ℕ) = Set.insert 4 {9} := by
rfl
-- example : {2, 3, 5} ⊆ (univ : Set ℕ) := by
-- tauto
-- example : 3 ∈ ({4, 2, 5, 7, 3} : Set ℕ) := by
-- tauto
-- example : ({4, 9} : Set ℕ) = Set.insert 4 {9} := by
-- rfl
#check Finset.card
-- #check Finset.card
variable (A : Finset ℕ)
-- variable (A : Finset ℕ)
#check A.card
-- #check A.card
-- card_union_eq
example (A B : Finset ℕ) (h : Disjoint A B) : (A ∪ B).card = A.card + B.card := by
-- Not a suitable proof for the course.
rw [← Finset.disjUnion_eq_union A B h, Finset.card_disjUnion _ _ _]
-- -- card_union_eq
-- example (A B : Finset ℕ) (h : Disjoint A B) : (A ∪ B).card = A.card + B.card := by
-- -- Not a suitable proof for the course.
-- rw [← Finset.disjUnion_eq_union A B h, Finset.card_disjUnion _ _ _]
example : ¬Disjoint {n : ℤ | ∃ k, n = 2 * k} {3, 5, 6, 9, 11} := by
rw [not_disjoint_iff]
use 6
constructor
rw [mem_setOf_eq]
use 3
tauto
-- example : ¬Disjoint {n : ℤ | ∃ k, n = 2 * k} {3, 5, 6, 9, 11} := by
-- rw [not_disjoint_iff]
-- use 6
-- constructor
-- rw [mem_setOf_eq]
-- use 3
-- tauto
example : {n : ℕ | Even n ∨ Odd n} = univ := by
rw [setOf_or]
-- example : {n : ℕ | Even n ∨ Odd n} = univ := by
-- rw [setOf_or]
#check Set.eq_of_mem_singleton
#check {n : ℤ | ∃ k, n = 2 * k}
#check {n : ℤ // ∃ k, n = 2 * k}
#check ℤ
variables (C : Set ℤ)
#check {n ∈ C | ∃ (k : ℤ), n = 2 * k}
#check {n : ℤ | n ∈ C ∧ ∃ (k : ℤ), n = 2 * k}
#check {x ∈ A | x = x}
#check {y | y ∈ A}
#check setOf_and
#check setOf_or
#check Disjoint C univ
-- #check Set.eq_of_mem_singleton
-- #check {n : ℤ | ∃ k, n = 2 * k}
-- #check {n : ℤ // ∃ k, n = 2 * k}
-- #check ℤ
-- variables (C : Set ℤ)
-- #check {n ∈ C | ∃ (k : ℤ), n = 2 * k}
-- #check {n : ℤ | n ∈ C ∧ ∃ (k : ℤ), n = 2 * k}
-- #check {x ∈ A | x = x}
-- #check {y | y ∈ A}
-- #check setOf_and
-- #check setOf_or
-- #check Disjoint C univ
example : {n ∈ C | ∃ (k : ℤ), n = 2 * k} = {n : ℤ | n ∈ C ∧ ∃ (k : ℤ), n = 2 * k} := by
rfl
-- example : {n ∈ C | ∃ (k : ℤ), n = 2 * k} = {n : ℤ | n ∈ C ∧ ∃ (k : ℤ), n = 2 * k} := by
-- rfl