open import Relation.Binary
module Induction.WellFounded {a : Set} (_<_ : Rel a) where
open import Induction
WfRec : RecStruct a
WfRec P x = ∀ y → y < x → P y
data Acc (x : a) : Set where
acc : (rs : WfRec Acc x) → Acc x
module Some where
wfRec-builder : SubsetRecursorBuilder Acc WfRec
wfRec-builder P f x (acc rs) = λ y y<x →
f y (wfRec-builder P f y (rs y y<x))
wfRec : SubsetRecursor Acc WfRec
wfRec = subsetBuild wfRec-builder
module All (allAcc : ∀ x → Acc x) where
wfRec-builder : RecursorBuilder WfRec
wfRec-builder P f x = Some.wfRec-builder P f x (allAcc x)
wfRec : Recursor WfRec
wfRec = build wfRec-builder