Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Mathlib/Computability/Primrec/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ theorem mem_range_encode : PrimrecPred (fun n => n ∈ Set.range (encode : α
this.of_eq fun _ => decode₂_ne_none_iff

instance ulower : Primcodable (ULower α) :=
Primcodable.subtype mem_range_encode
fast_instance% Primcodable.subtype mem_range_encode

end ULower

Expand Down Expand Up @@ -886,11 +886,11 @@ theorem option_get {f : α → Option β} {h : ∀ a, (f a).isSome} :

theorem ulower_down : Primrec (ULower.down : α → ULower α) :=
letI : ∀ a, Decidable (a ∈ Set.range (encode : α → ℕ)) := decidableRangeEncode _
subtype_mk .encode
subtype_mk .encode (hp := Primcodable.mem_range_encode)

theorem ulower_up : Primrec (ULower.up : ULower α → α) :=
letI : ∀ a, Decidable (a ∈ Set.range (encode : α → ℕ)) := decidableRangeEncode _
option_get (Primrec.decode₂.comp subtype_val)
option_get (Primrec.decode₂.comp (subtype_val (hp := Primcodable.mem_range_encode)))

theorem fin_val_iff {n} {f : α → Fin n} : (Primrec fun a => (f a).1) ↔ Primrec f := by
letI : Primcodable { a // a < n } := Primcodable.subtype (nat_lt.comp .id (const _))
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/Computability/Primrec/List.lean
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ variable {α : Type*} [Primcodable α]
open Primrec

instance vector {n} : Primcodable (List.Vector α n) :=
subtype ((@Primrec.eq ℕ _).comp list_length (const _))
fast_instance% subtype ((@Primrec.eq ℕ _).comp list_length (const _))

instance finArrow {n} : Primcodable (Fin n → α) :=
ofEquiv _ (Equiv.vectorEquivFin _ _).symm
Expand All @@ -529,11 +529,11 @@ variable {α : Type*} {β : Type*} {σ : Type*}
variable [Primcodable α] [Primcodable β] [Primcodable σ]

theorem vector_toList {n} : Primrec (@List.Vector.toList α n) :=
subtype_val
subtype_val (hp := (@Primrec.eq ℕ _).comp list_length (const _))

theorem vector_toList_iff {n} {f : α → List.Vector β n} :
(Primrec fun a => (f a).toList) ↔ Primrec f :=
subtype_val_iff
subtype_val_iff (hp := (@Primrec.eq ℕ _).comp list_length (const _))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a little disappointing. Are we missing some API or something?

Copy link
Copy Markdown
Contributor Author

@sgouezel sgouezel Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The whole API was relying on defeq abuse, hoping that hp would be somehow embedded in an instance. It's not any more the case when we break the defeq abuse, so we have to give this argument that it couldn't guess otherwise -- but it makes sense.


theorem vector_cons {n} : Primrec₂ (@List.Vector.cons α n) :=
vector_toList_iff.1 <| by simpa using list_cons.comp fst (vector_toList_iff.2 snd)
Expand Down
Loading