Zulip Chat Archive

Stream: new members

Topic: proving union of sets is equal to \N


max (Nov 12 2024 at 18:47):

def IsPerfectPower (m : ) :=  n k, 1 < k  n ^ k = m
def Perfect : Set  := {n :  | IsPerfectPower n}
def nonPerfect : Set  := {n :  | ¬IsPerfectPower n}
theorem n_is_perfect_or_not (n : ) : (IsPerfectPower n  ¬IsPerfectPower n) := by
  apply Classical.em

theorem covers_n : Perfect  nonPerfect =  := by
  unfold Perfect nonPerfect
  sorry

I was able to prove that for any n: N, it is either a perfect power or not by the law of the excluded middle.
I want to prove basically the same, but showing that the union of the non perfect and perfect naturals is equal to all the naturals.

The type of Perfect \un nonPerfect is Set \N, but N is not Set N, how should I approach this?
Thanks again, I am really enjoying being on this zulip. Everyone has been so helpful

Floris van Doorn (Nov 12 2024 at 18:51):

The element of Set ℕ that consists of all natural numbers is spelled Set.univ (or ), not .

Notification Bot (Nov 12 2024 at 18:51):

A message was moved here from #lean4 > proving union of sets is equal to \N by Floris van Doorn.

Floris van Doorn (Nov 12 2024 at 18:54):

@max this is a possible way to prove this

import Mathlib.Tactic

def IsPerfectPower (m : ) :=  n k, 1 < k  n ^ k = m
def Perfect : Set  := {n :  | IsPerfectPower n}
def nonPerfect : Set  := {n :  | ¬IsPerfectPower n}
theorem n_is_perfect_or_not (n : ) : (IsPerfectPower n  ¬IsPerfectPower n) := by
  apply Classical.em

theorem covers_n : Perfect  nonPerfect = Set.univ := by
  unfold Perfect nonPerfect
  ext n
  simp
  exact n_is_perfect_or_not n

Floris van Doorn (Nov 12 2024 at 18:54):

Also, for next time: please list your imports (see #mwe )

Floris van Doorn (Nov 12 2024 at 18:55):

I recommend that you read Section 4.1 of Mathematics in Lean: https://leanprover-community.github.io/mathematics_in_lean/C04_Sets_and_Functions.html

max (Nov 13 2024 at 17:50):

thanks a lot Floris!


Last updated: May 02 2025 at 03:31 UTC