Compilable Acc.rec, Acc.rec' and WellFounded.fix #
This module supplies @[csimp] lemmas so that Acc.rec, Acc.rec', WellFounded.fixF and
WellFounded.fix compile to direct recursive code, even though their logical definitions are
noncomputable.
Without this, the following code would fail to compile, as WellFounded.fix is noncomputable.
def log2p1 : Nat → Nat :=
WellFounded.fix Nat.lt_wfRel.2 fun n IH =>
let m := n / 2
if h : m < n then
IH m h + 1
else
0
@[irreducible, specialize #[]]
def Acc.recC {α : Sort u_1} {r : α → α → Prop} {motive : (a : α) → Acc r a → Sort v} (intro : (x : α) → (h : ∀ (y : α), r y x → Acc r y) → ((y : α) → (hr : r y x) → motive y ⋯) → motive x ⋯) {a : α} (t : Acc r a) :
motive a t
A compilable version of Acc.rec and Acc.rec'.
Instances For
@[reducible, inline]
abbrev Acc.recOnC {α : Sort u_1} {r : α → α → Prop} {motive : (a : α) → Acc r a → Sort v} {a : α} (t : Acc r a) (intro : (x : α) → (h : ∀ (y : α), r y x → Acc r y) → ((y : α) → (hr : r y x) → motive y ⋯) → motive x ⋯) :
motive a t
A compilable version of Acc.recOn'.
Equations
- Acc.recOnC t intro = Acc.recC intro t
Instances For
@[reducible, inline]
abbrev Acc.ndrecC {α : Sort u_1} {r : α → α → Prop} {C : α → Sort v} (m : (x : α) → (∀ (y : α), r y x → Acc r y) → ((y : α) → r y x → C y) → C x) {a : α} (n : Acc r a) :
C a
A compilable version of Acc.ndrec and Acc.ndrec'.
Equations
- Acc.ndrecC m n = Acc.recC m n
Instances For
@[reducible, inline]
abbrev Acc.ndrecOnC {α : Sort u_1} {r : α → α → Prop} {C : α → Sort v} {a : α} (n : Acc r a) (m : (x : α) → (∀ (y : α), r y x → Acc r y) → ((y : α) → r y x → C y) → C x) :
C a
A compilable version of Acc.ndrecOn and Acc.ndrecOn'.
Instances For
@[irreducible, specialize #[]]
def WellFounded.fixFC {α : Sort u} {r : α → α → Prop} {C : α → Sort v} (F : (x : α) → ((y : α) → r y x → C y) → C x) (x : α) (a : Acc r x) :
C x
A compilable version of WellFounded.fixF.
Equations
- WellFounded.fixFC F x a = F x fun (y : α) (h : r y x) => WellFounded.fixFC F y ⋯
Instances For
@[irreducible, specialize #[]]
def WellFounded.fixC {α : Sort u} {C : α → Sort v} {r : α → α → Prop} (hwf : WellFounded r) (F : (x : α) → ((y : α) → r y x → C y) → C x) (x : α) :
C x
A compilable version of WellFounded.fix.