reorganize and add plfa

This commit is contained in:
2020-06-05 09:18:15 +02:00
parent 5bf71e63e7
commit d425272d94
5 changed files with 72 additions and 0 deletions

68
plfa/Naturals.agda Normal file
View File

@@ -0,0 +1,68 @@
module Naturals where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)
data : Set where
zero :
suc :
{-# BUILTIN NATURAL #-}
_+_ :
zero + n = n
suc m + n = suc (m + n)
_*_ :
zero * n = zero
suc m * n = n + (m * n)
_^_ :
n ^ 0 = 1
n ^ suc m = n * (n ^ m)
_∸_ :
m zero = m
zero suc n = zero
suc m suc n = m n
infixl 6 _+_ _∸_
infixl 7 _*_
{-# BUILTIN NATPLUS _+_ #-}
{-# BUILTIN NATTIMES _*_ #-}
{-# BUILTIN NATMINUS _∸_ #-}
-- Bin stretch exercise
data Bin : Set where
⟨⟩ : Bin
_O : Bin Bin
_I : Bin Bin
inc : Bin Bin
inc ⟨⟩ = ⟨⟩ I
inc (m O) = m I
inc (m I) = (inc m) O
_ : inc (⟨⟩ I O I I) ⟨⟩ I I O O
_ = refl
_ : inc (⟨⟩ I) ⟨⟩ I O
_ = refl
to : -> Bin
to 0 = ⟨⟩
to (suc n) = inc (to n)
_ : to 11 ⟨⟩ I O I I
_ = refl
from : Bin ->
from ⟨⟩ = 0
from (m O) = 2 * from m
from (m I) = 1 + 2 * from m
_ : from (⟨⟩ I O I I) 11
_ = refl

4
plfa/README.md Normal file
View File

@@ -0,0 +1,4 @@
# PLFA
Im following along [PLFA](https://plfa.github.io/). This repo only contains the
stretch exercises and supporting materials.