30 lines
719 B
Agda
30 lines
719 B
Agda
|
{-# OPTIONS --prop #-}
|
|||
|
|
|||
|
module Zdancewic.Day1 where
|
|||
|
|
|||
|
open import Data.Bool
|
|||
|
open import Data.Nat
|
|||
|
open import Data.String
|
|||
|
|
|||
|
mem = String -> ℕ
|
|||
|
|
|||
|
infixl 20 _∙_
|
|||
|
|
|||
|
data aexp : Set where
|
|||
|
data bexp : Set where
|
|||
|
data com : Set where
|
|||
|
`_:=_ : String → ℕ → com
|
|||
|
`if_then_else_ : bexp → com → com → com
|
|||
|
`skip : com
|
|||
|
_∙_ : com → com → com
|
|||
|
|
|||
|
beval : mem → bexp → Bool
|
|||
|
|
|||
|
denote : com → mem → mem
|
|||
|
denote `skip st = st
|
|||
|
denote (`if x then c else c₁) st = if beval st x then denote c st else denote c₁ st
|
|||
|
denote (` x := n) st = λ y → if x == y then n else st x
|
|||
|
denote (c ∙ c₁) st = denote c₁ (denote c st)
|
|||
|
|
|||
|
data ceval : com → mem → mem → Prop where
|
|||
|
E_skip : ∀ {st} → ceval `skip st st
|