{-# OPTIONS --exact-split #-}
{-# OPTIONS --guardedness #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --safe #-}
{-# OPTIONS --warning=all #-}
{-# OPTIONS --warning=error #-}
{-# OPTIONS --without-K #-}
module Extra.Data.Nat.Induction.WellFounded where
open import Data.Nat renaming (suc to succ)
open import Extra.Data.Nat.Properties
<-wfind : (P : ℕ → Set) →
(∀ n → (∀ m → m < n → P m) → P n) →
∀ n → P n
<-wfind P ih n = ih n (helper n)
where
helper : ∀ n m → m < n → P m
helper zero m ()
helper (succ n) zero _ = ih zero (λ _ ())
helper (succ n) (succ m) (s≤s Sm≤n) =
ih (succ m) (λ m' Sm'≤Sm → helper n m' (≤-trans Sm'≤Sm Sm≤n))
<′-wfind : (P : ℕ → Set) →
(∀ n → (∀ m → m <′ n → P m) → P n) →
∀ n → P n
<′-wfind P ih n = ih n (helper n)
where
helper : ∀ n m → m <′ n → P m
helper .(succ m) m ≤′-refl = ih m (helper m)
helper .(succ n) m (≤′-step {n} Sm≤′n) = helper n m Sm≤′n