Skip to content

Commit

Permalink
feat(data/nat/pairing): add an equiv version of nat.mkpair/`nat.u…
Browse files Browse the repository at this point in the history
…npair` (#10520)
  • Loading branch information
urkud committed Nov 30, 2021
1 parent af5c778 commit 41fa32b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/data/nat/pairing.lean
Expand Up @@ -63,8 +63,15 @@ begin
simp [unpair, ae, nat.not_lt_zero, add_assoc] }
end

/-- An equivalence between `ℕ × ℕ` and `ℕ`. -/
@[simps { fully_applied := ff }] def mkpair_equiv : ℕ × ℕ ≃ ℕ :=
⟨uncurry mkpair, unpair, λ ⟨a, b⟩, unpair_mkpair a b, mkpair_unpair⟩

lemma surjective_unpair : surjective unpair :=
λ ⟨m, n⟩, ⟨mkpair m n, unpair_mkpair m n⟩
mkpair_equiv.symm.surjective

@[simp] lemma mkpair_eq_mkpair {a b c d : ℕ} : mkpair a b = mkpair c d ↔ a = c ∧ b = d :=
mkpair_equiv.injective.eq_iff.trans (@prod.ext_iff ℕ ℕ (a, b) (c, d))

theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n :=
let s := sqrt n in begin
Expand Down

0 comments on commit 41fa32b

Please sign in to comment.