Skip to content

Commit 707df07

Browse files
committed
feat(Data/PFunctor): make M.corec' universe generic (#30400)
Previously `corec'` required the generating type reside in the same universe as the constructed object. This change corrects this by separating the universes. As corec takes the parameter (g : β → P (α ::: β)), (where α is a TypeVec.{u} and β is a Type u) it is forced into the same universe by how the TypeVec construction works. This means corec cant be generalised by this construction.
1 parent e99565a commit 707df07

File tree

1 file changed

+5
-5
lines changed
  • Mathlib/Data/PFunctor/Multivariate

1 file changed

+5
-5
lines changed

Mathlib/Data/PFunctor/Multivariate/M.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ that `A` is a possibly infinite tree.
4646

4747

4848

49-
universe u
49+
universe u v
5050

5151
open MvFunctor
5252

@@ -103,7 +103,7 @@ instance inhabitedM {α : TypeVec _} [I : Inhabited P.A] [∀ i : Fin2 n, Inhabi
103103

104104
/-- construct through corecursion the shape of an M-type
105105
without its contents -/
106-
def M.corecShape {β : Type u} (g₀ : β → P.A) (g₂ : ∀ b : β, P.last.B (g₀ b) → β) :
106+
def M.corecShape {β : Type v} (g₀ : β → P.A) (g₂ : ∀ b : β, P.last.B (g₀ b) → β) :
107107
β → P.last.M :=
108108
PFunctor.M.corec fun b => ⟨g₀ b, g₂ b⟩
109109

@@ -115,7 +115,7 @@ def castLastB {a a' : P.A} (h : a = a') : P.last.B a → P.last.B a' := fun b =>
115115

116116
/-- Using corecursion, construct the contents of an M-type -/
117117
def M.corecContents {α : TypeVec.{u} n}
118-
{β : Type u}
118+
{β : Type v}
119119
(g₀ : β → P.A)
120120
(g₁ : ∀ b : β, P.drop.B (g₀ b) ⟹ α)
121121
(g₂ : ∀ b : β, P.last.B (g₀ b) → β)
@@ -141,7 +141,7 @@ def M.corecContents {α : TypeVec.{u} n}
141141
M.corecContents g₀ g₁ g₂ (f j) (g₂ b (P.castLastB h₀ j)) h₁ i c
142142

143143
/-- Corecursor for M-type of `P` -/
144-
def M.corec' {α : TypeVec n} {β : Type u} (g₀ : β → P.A) (g₁ : ∀ b : β, P.drop.B (g₀ b) ⟹ α)
144+
def M.corec' {α : TypeVec n} {β : Type v} (g₀ : β → P.A) (g₁ : ∀ b : β, P.drop.B (g₀ b) ⟹ α)
145145
(g₂ : ∀ b : β, P.last.B (g₀ b) → β) : β → P.M α := fun b =>
146146
⟨M.corecShape P g₀ g₂ b, M.corecContents P g₀ g₁ g₂ _ _ rfl⟩
147147

@@ -182,7 +182,7 @@ theorem M.dest_eq_dest' {α : TypeVec n} {x : P.last.M} {a : P.A}
182182
M.dest P ⟨x, f'⟩ = M.dest' P h f' :=
183183
M.dest'_eq_dest' _ _ _ _
184184

185-
theorem M.dest_corec' {α : TypeVec.{u} n} {β : Type u} (g₀ : β → P.A)
185+
theorem M.dest_corec' {α : TypeVec.{u} n} {β : Type v} (g₀ : β → P.A)
186186
(g₁ : ∀ b : β, P.drop.B (g₀ b) ⟹ α) (g₂ : ∀ b : β, P.last.B (g₀ b) → β) (x : β) :
187187
M.dest P (M.corec' P g₀ g₁ g₂ x) = ⟨g₀ x, splitFun (g₁ x) (M.corec' P g₀ g₁ g₂ ∘ g₂ x)⟩ :=
188188
rfl

0 commit comments

Comments
 (0)