mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
gf-book web page index and toc
This commit is contained in:
30
gf-book/examples/chapter6/Arithm.gf
Normal file
30
gf-book/examples/chapter6/Arithm.gf
Normal 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) ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user