types

declare [[names_short]]

datatype bool = True|False

(if b then t1 else t2)

(let x = t in u)

(case t of pat1=>t1|...|patn=>tn)

A1=>A2=>A3=>...=>An=>A   <==>[|A1;A2;A3;...An|] =>A  <==>(A1 ...An)/A

fun add::"nat=>nat=>nat"where

"add 0 n = n"|"add (Suc m) n = Suc(add m n)"

lemma add_02:"add m 0 =m"

apply(induction m)

apply(auto)

done

datatype 'a list =  Nil|Cons 'a " 'a list "

fun app::" 'a list => 'a list => 'a list" where

"app Nil ys = ys"|" app (Cons x  xs) ys = Cons x(app xs ys)"

fun rev::" 'a list => 'a list" where

"rev Nil = Nil"|"  rev (Cons x xs) = app (rev xs) (Cons x Nil)"

value "rev(Cons True (Cons False Nil))"

value "rev(Cons a (Cons b Nil))"

posted on 2017-11-22 20:51  apple平哥  阅读(339)  评论(0编辑  收藏  举报

导航