diff options
author | funemy | 2022-10-24 02:21:57 +0000 |
---|---|---|
committer | funemy | 2022-10-24 02:21:57 +0000 |
commit | 95f14a976eda122d8f58ed1ff6ee4f16f1f81b77 (patch) | |
tree | 35650c8d04f2745d9ea233948cf6c81ba9b4cda6 /entries/ionathanch/agda | |
parent | 201f9e290b59838ed249b7d1be03e5b8230bef3e (diff) | |
parent | 46a659c983911b87b38b20cd4b28ab9176e4fdb3 (diff) |
Merge branch 'main' of github.com:braxtonhall/fib
Diffstat (limited to 'entries/ionathanch/agda')
-rw-r--r-- | entries/ionathanch/agda/Fib.agda | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/entries/ionathanch/agda/Fib.agda b/entries/ionathanch/agda/Fib.agda new file mode 100644 index 0000000..a12b0a5 --- /dev/null +++ b/entries/ionathanch/agda/Fib.agda @@ -0,0 +1,19 @@ + +open import Agda.Builtin.Nat +open import Agda.Builtin.List +open import Agda.Builtin.Reflection + +data Fib : Nat → Nat → Set where + instance F0 : Fib 0 0 + instance F1 : Fib 1 1 + instance Fk : ∀ {k n m} → ⦃ Fib k n ⦄ → ⦃ Fib (suc k) m ⦄ → Fib (suc (suc k)) (n + m) + +fib' : ∀ k {n} → ⦃ Fib k n ⦄ → Nat +fib' k {n} ⦃ fib ⦄ = n + +macro + fib : Term → Term → TC _ + fib t hole = unify hole (def (quote fib') (arg i t ∷ [])) + where i = arg-info visible (modality relevant quantity-ω) + +{- Get the [n]th Fibonacci number by normalization via C-n `fib [n]`. -} |