Skip to content

Instantly share code, notes, and snippets.

@pnlph
Created April 7, 2020 11:09
Show Gist options
  • Save pnlph/bb867bde410aec1441db43de61b0d528 to your computer and use it in GitHub Desktop.
Save pnlph/bb867bde410aec1441db43de61b0d528 to your computer and use it in GitHub Desktop.
ℕ-induction : (A : ℕ → 𝓤 ̇ ) → A 0 → ((n : ℕ) → A n → A (succ n)) → (n : ℕ) → A n
ℕ-induction A a₀ f = h where h : (n : ℕ) → A n
h 0 = a₀
h (succ n) = f n (h n)
ℕ-recursion : (X : 𝓤 ̇ ) → X → (ℕ → X → X) → ℕ → X
ℕ-recursion X = ℕ-induction (λ _ → X)
ℕ-iteration : (X : 𝓤 ̇ ) → X → (X → X) → ℕ → X
ℕ-iteration X x f = ℕ-recursion X x (λ _ x → f x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment