not_iff_not_selftheoremProved here from basic factsNo axioms
not_iff_not_selfLean 4Proved here from basic factsFormally verified
/-- **No statement is equivalent to its own negation.** If `p ↔ ¬p`, then assuming `p` gives `¬p`,so `p` is refuted; but then `¬p` gives `p`. This proof is constructive. -/theorem not_iff_not_self (p : Prop) : ¬ (p ↔ ¬ p) := by intro h have hnp : ¬ p := fun hp => h.mp hp hp exact hnp (h.mpr hnp)
no_russell_relationtheoremProved here from basic factsNo axioms
no_russell_relationLean 4Proved here from basic factsFormally verified
/-- **Russell's theorem, in pure logic.** For any relation `E` on any type, there is no `r` whose"members" are exactly the things that are not members of themselves: taking `x = r` would give`r E r ↔ ¬ (r E r)`. -/theorem no_russell_relation {α : Type*} (E : α → α → Prop) : ¬ ∃ r, ∀ x, E x r ↔ ¬ E x x := by rintro ⟨r, hr⟩ exact not_iff_not_self (E r r) (hr r)
no_barbertheoremProved here from basic factsNo axioms
no_barberLean 4Proved here from basic factsFormally verified
/-- **The barber.** In no village is there a barber who shaves exactly those villagers who do notshave themselves. This is `no_russell_relation` for the relation "`y` shaves `x`". The barber is nota paradox: it simply proves that such a barber does not exist. -/theorem no_barber {Person : Type*} (shaves : Person → Person → Prop) : ¬ ∃ b, ∀ p, shaves b p ↔ ¬ shaves p p := no_russell_relation (fun x y => shaves y x)
naive_comprehension_inconsistenttheoremProved here from basic factsNo axioms
naive_comprehension_inconsistentLean 4Proved here from basic factsFormally verified
/-- **Naive comprehension is inconsistent.** Suppose a membership relation `mem` had the propertythat every predicate `P` is the membership predicate of some "set" `s`. Applying this to`P x := ¬ mem x x` produces a Russell set, which `no_russell_relation` forbids. -/theorem naive_comprehension_inconsistent {α : Type*} (mem : α → α → Prop) (comprehension : ∀ P : α → Prop, ∃ s, ∀ x, mem x s ↔ P x) : False := no_russell_relation mem (comprehension fun x => ¬ mem x x)
russell_sep_not_memtheoremProved here from basic factspropext, Quot.sound
russell_sep_not_memLean 4Proved here from basic factsFormally verified
/-- **Separation blocks the paradox.** In Mathlib's model of ZFC, for every set `A` the Russellset *inside `A`*, `R = {x ∈ A | x ∉ x}` (built with the separation axiom `ZFSet.sep`), is not anelement of `A`. If it were, then `R ∈ R ↔ (R ∈ A ∧ R ∉ R) ↔ R ∉ R`. Only `ZFSet.mem_sep` is used —not the axiom of foundation. -/theorem russell_sep_not_mem (A : ZFSet) : ZFSet.sep (fun x => x ∉ x) A ∉ A := by intro hA -- `h : R ∈ R ↔ R ∈ A ∧ R ∉ R`, where `R` is the Russell set inside `A`. have h := ZFSet.mem_sep (p := fun x => x ∉ x) (x := A) (y := ZFSet.sep (fun x => x ∉ x) A) exact not_iff_not_self _ ⟨fun hRR => (h.mp hRR).2, fun hRR => h.mpr ⟨hA, hRR⟩⟩
no_universal_settheoremProved here from basic factspropext, Quot.sound
no_universal_setLean 4Proved here from basic factsFormally verified
/-- **There is no set of all sets.** If `U` contained every set, it would contain its own Russellset `{x ∈ U | x ∉ x}`, contradicting `russell_sep_not_mem`. -/theorem no_universal_set : ¬ ∃ U : ZFSet, ∀ x, x ∈ U := by rintro ⟨U, hU⟩ exact russell_sep_not_mem U (hU _)
mem_irrefltheoremApplies a library theorempropext, Quot.sound
mem_irreflLean 4Applies a library theoremFormally verified
/-- In ZFC no set is a member of itself — Mathlib's `ZFSet.mem_irrefl`, which comes from the axiomof foundation (Mathlib proves that membership of `ZFSet`s is well-founded). The paradox is *not*avoided this way: `russell_sep_not_mem` never used this fact. -/theorem mem_irrefl (x : ZFSet) : x ∉ x := ZFSet.mem_irrefl x
russell_sep_eq_selftheoremProved here from basic factspropext, Quot.sound
russell_sep_eq_selfLean 4Proved here from basic factsFormally verified
/-- With foundation, the Russell set inside `A` is `A` itself: every element `x` of `A` satisfies`x ∉ x`. So `russell_sep_not_mem` then says simply `A ∉ A`. -/theorem russell_sep_eq_self (A : ZFSet) : ZFSet.sep (fun x => x ∉ x) A = A := by ext x rw [ZFSet.mem_sep] exact ⟨fun h => h.1, fun h => ⟨h, mem_irrefl x⟩⟩
cantor_of_russelltheoremProved here from basic factsNo axioms
cantor_of_russellLean 4Proved here from basic factsFormally verified
/-- **Cantor's theorem is Russell's argument in disguise.** For `f : α → Set α`, read `x ∈ f y` as"`x` is a member of `y`". A surjective `f` would hit the diagonal set `{x | x ∉ f x}` at some `r`,and that `r` would be a Russell element for this relation. -/theorem cantor_of_russell {α : Type*} (f : α → Set α) : ¬ Function.Surjective f := by intro hf obtain ⟨r, hr⟩ := hf {x | x ∉ f x} apply no_russell_relation (fun x y => x ∈ f y) refine ⟨r, fun x => ?_⟩ rw [hr] rfl
typed_universetheoremProved here from basic factsNo axioms
typed_universeLean 4Proved here from basic factsFormally verified
/-- **In type theory a "set of everything" is harmless.** For each type `α` there is a setcontaining every element of `α` — `Set.univ` — but it has type `Set α`, so it is not itself anelement of `α`, and the question "is it a member of itself?" cannot be asked. -/theorem typed_universe (α : Type*) : ∃ U : Set α, ∀ x : α, x ∈ U := ⟨Set.univ, fun _ => trivial⟩
/-- No statement is equivalent to its own negation.Hint: `intro h`; first prove `¬ p` (assume `hp : p` and use `h.mp hp hp`), then use `h.mpr`. -/theorem not_iff_not_self (p : Prop) : ¬ (p ↔ ¬ p) := by sorry
Show the compiled solution
not_iff_not_selfLean 4Proved here from basic factsFormally verified
/-- **No statement is equivalent to its own negation.** If `p ↔ ¬p`, then assuming `p` gives `¬p`,so `p` is refuted; but then `¬p` gives `p`. This proof is constructive. -/theorem not_iff_not_self (p : Prop) : ¬ (p ↔ ¬ p) := by intro h have hnp : ¬ p := fun hp => h.mp hp hp exact hnp (h.mpr hnp)
/-- There is no barber who shaves exactly those who do not shave themselves.Hint: `rintro ⟨b, hb⟩` and look at `hb b`. -/theorem no_barber {Person : Type*} (shaves : Person → Person → Prop) : ¬ ∃ b, ∀ p, shaves b p ↔ ¬ shaves p p := by sorry
Show the compiled solution
no_barberLean 4Proved here from basic factsFormally verified
/-- **The barber.** In no village is there a barber who shaves exactly those villagers who do notshave themselves. This is `no_russell_relation` for the relation "`y` shaves `x`". The barber is nota paradox: it simply proves that such a barber does not exist. -/theorem no_barber {Person : Type*} (shaves : Person → Person → Prop) : ¬ ∃ b, ∀ p, shaves b p ↔ ¬ shaves p p := no_russell_relation (fun x y => shaves y x)