Skip to content

Commit

Permalink
chore(Computability): Encodable/Fintype -> Countable/Finite (#…
Browse files Browse the repository at this point in the history
…10869)

Also golf a proof
  • Loading branch information
urkud committed Mar 12, 2024
1 parent 5908dd8 commit 5552411
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
14 changes: 5 additions & 9 deletions Mathlib/Computability/Encoding.lean
Expand Up @@ -6,7 +6,7 @@ Authors: Pim Spelier, Daan van Gent
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.Data.Option.Basic
import Mathlib.SetTheory.Cardinal.Ordinal
import Mathlib.SetTheory.Cardinal.Basic

#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"

Expand Down Expand Up @@ -245,17 +245,13 @@ theorem Encoding.card_le_card_list {α : Type u} (e : Encoding.{u, v} α) :
Cardinal.lift_mk_le'.2 ⟨⟨e.encode, e.encode_injective⟩⟩
#align computability.encoding.card_le_card_list Computability.Encoding.card_le_card_list

theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
cases' isEmpty_or_nonempty e.Γ with h h
· simp only [Cardinal.mk_le_aleph0]
· rw [Cardinal.mk_list_eq_aleph0]
theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Countable e.Γ] :
#α ≤ ℵ₀ :=
haveI : Countable α := e.encode_injective.countable
Cardinal.mk_le_aleph0
#align computability.encoding.card_le_aleph_0 Computability.Encoding.card_le_aleph0

theorem FinEncoding.card_le_aleph0 {α : Type u} (e : FinEncoding α) : #α ≤ ℵ₀ :=
haveI : Encodable e.Γ := Fintype.toEncodable _
e.toEncoding.card_le_aleph0
#align computability.fin_encoding.card_le_aleph_0 Computability.FinEncoding.card_le_aleph0

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Computability/Primrec.lean
Expand Up @@ -781,7 +781,7 @@ theorem list_indexOf₁ [DecidableEq α] (l : List α) : Primrec fun a => l.inde
list_findIdx₁ (.swap .beq) l
#align primrec.list_index_of₁ Primrec.list_indexOf₁

theorem dom_fintype [Fintype α] (f : α → σ) : Primrec f :=
theorem dom_fintype [Finite α] (f : α → σ) : Primrec f :=
let ⟨l, _, m⟩ := Finite.exists_univ_list α
option_some_iff.1 <| by
haveI := decidableEqOfEncodable α
Expand Down
14 changes: 6 additions & 8 deletions Mathlib/Computability/TuringMachine.lean
Expand Up @@ -1616,18 +1616,16 @@ section

variable {Γ : Type*} [Inhabited Γ]

theorem exists_enc_dec [Fintype Γ] : ∃ (n : ℕ) (enc : Γ → Vector Bool n) (dec : Vector Bool n → Γ),
theorem exists_enc_dec [Finite Γ] : ∃ (n : ℕ) (enc : Γ → Vector Bool n) (dec : Vector Bool n → Γ),
enc default = Vector.replicate n false ∧ ∀ a, dec (enc a) = a := by
letI := Classical.decEq Γ
let n := Fintype.card Γ
obtain ⟨F⟩ := Fintype.truncEquivFin Γ
rcases Finite.exists_equiv_fin Γ with ⟨n, ⟨e⟩⟩
letI : DecidableEq Γ := e.decidableEq
let G : Fin n ↪ Fin n → Bool :=
fun a b ↦ a = b, fun a b h ↦
Bool.of_decide_true <| (congr_fun h b).trans <| Bool.decide_true rfl⟩
let H := (F.toEmbedding.trans G).trans (Equiv.vectorEquivFin _ _).symm.toEmbedding
classical
let enc := H.setValue default (Vector.replicate n false)
exact ⟨_, enc, Function.invFun enc, H.setValue_eq _ _, Function.leftInverse_invFun enc.2
let H := (e.toEmbedding.trans G).trans (Equiv.vectorEquivFin _ _).symm.toEmbedding
let enc := H.setValue default (Vector.replicate n false)
exact ⟨_, enc, Function.invFun enc, H.setValue_eq _ _, Function.leftInverse_invFun enc.2
#align turing.TM1to1.exists_enc_dec Turing.TM1to1.exists_enc_dec

variable {Λ : Type*} [Inhabited Λ]
Expand Down

0 comments on commit 5552411

Please sign in to comment.