{-# OPTIONS --allow-unsolved-metas #-}
data _≡_ {X : Set} : X → X → Set where
refl : {x : X} → x ≡ x
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
half : ℕ → ℕ
half zero = zero
half (succ zero) = zero
half (succ (succ n)) = succ (half n)
_ : half (succ (succ (succ zero))) ≡ succ zero
_ = refl
data _<_ : ℕ → ℕ → Set where
base : {n : ℕ} → n < succ n
step : {a b : ℕ} → a < b → a < succ b
_ : zero < succ (succ (succ zero))
_ = step (step base)
lemma-succ-mon : {a b : ℕ} → a < b → succ a < succ b
lemma-succ-mon base = base
lemma-succ-mon (step p) = step (lemma-succ-mon p)
lemma-succ-step : (a : ℕ) → a < succ a
lemma-succ-step a = {!!}
<-trans : {a b c : ℕ} → a < b → b < c → a < c
<-trans p q = {!!}
half< : (n : ℕ) → half (succ n) < succ n
half< zero = base
half< (succ zero) = base
half< (succ (succ n)) = lemma-succ-mon (<-trans (half< n) (lemma-succ-step (succ n)))
data Acc : ℕ → Set where
acc : {x : ℕ} → ({y : ℕ} → y < x → Acc y) → Acc x
data BinaryTree : Set where
leaf : BinaryTree
fork : BinaryTree → BinaryTree → BinaryTree
data CountablyBranchingTree : Set where
leaf : CountablyBranchingTree
fork : (ℕ → CountablyBranchingTree) → CountablyBranchingTree
data ExtremelyBranchingTree : Set₁ where
leaf : ExtremelyBranchingTree
fork : (Set → ExtremelyBranchingTree) → ExtremelyBranchingTree
open import Agda.Primitive
ex : Setω
ex = (n : Level) → Set n
ex' : Setω₁
ex' = Setω
exampleTree : BinaryTree
exampleTree = fork leaf (fork leaf leaf)
lemma-zero-is-accessible : Acc zero
lemma-zero-is-accessible = acc (λ ())
lemma-one-is-accessible : Acc (succ zero)
lemma-one-is-accessible = acc (λ { base → lemma-zero-is-accessible })
ℕ-is-wellfounded : (n : ℕ) → Acc n
ℕ-is-wellfounded n = {!!}
go : (n : ℕ) → Acc n → ℕ
go zero g = zero
go (succ n) (acc f) = succ (go (half (succ n)) (f (half< n)))
digits : ℕ → ℕ
digits n = go n (ℕ-is-wellfounded n)