completed book examples

This commit is contained in:
aarne
2010-11-22 15:48:52 +00:00
parent 46137ab6a6
commit b8f81b1a20
11 changed files with 110 additions and 9 deletions

View File

@@ -0,0 +1,30 @@
abstract Arithm = {
cat
Prop ; -- proposition
Nat ; -- natural number
data
Zero : Nat ; -- 0
Succ : Nat -> Nat ; -- the successor of x
fun
Even : Nat -> Prop ; -- x is even
And : Prop -> Prop -> Prop ; -- A and B
cat Less Nat Nat ;
data LessZ : (y : Nat) -> Less Zero (Succ y) ;
data LessS : (x,y : Nat) -> Less x y -> Less (Succ x) (Succ y) ;
cat Span ;
data FromTo : (m,n : Nat) -> Less m n -> Span ;
fun one : Nat ;
def one = Succ Zero ;
fun twice : Nat -> Nat ;
def twice x = plus x x ;
fun plus : Nat -> Nat -> Nat ;
def
plus x Zero = x ;
plus x (Succ y) = Succ (plus x y) ;
}

View File

@@ -18,8 +18,8 @@ lin
Fan = mkCN (mkN "fan") ;
Switchable, Dimmable = <> ;
SwitchOn = mkV2 (mkV "on" (mkV "switch")) ;
SwitchOff = mkV2 (mkV "off" (mkV "switch")) ;
SwitchOn = mkV2 (partV (mkV "switch") "on") ;
SwitchOff = mkV2 (partV (mkV "switch") "off") ;
Dim = mkV2 (mkV "dim") ;
switchable_Light = <> ;

View File

@@ -0,0 +1,16 @@
abstract Smart = {
cat
Command ;
Kind ;
Device Kind ;
Action Kind ;
fun
Act : (k : Kind) -> Action k -> Device k -> Command ;
The : (k : Kind) -> Device k ; -- the light
Light, Fan : Kind ;
Dim : Action Light ;
SwitchOn, SwitchOff : (k : Kind) -> Action k ;
}