section‹Programs defined over the natural numbers›
theory Nat imports"../Wfd" begin
definition not :: "i→i" where"not(b) == if b then false else true"
definition add :: "[i,i]→i" (infixr‹#+›60) where"a #+ b == nrec(a, b, λx g. succ(g))"
definition mult :: "[i,i]→i" (infixr‹#*›60) where"a #* b == nrec(a, zero, λx g. b #+ g)"
definition sub :: "[i,i]→i" (infixr‹#-›60) where "a #- b == letrec sub x y be ncase(y, x, λyy. ncase(x, zero, λxx. sub(xx,yy))) in sub(a,b)"
definition le :: "[i,i]→i" (infixr‹#<=\›60) where "a #<= b == letrec le x y be ncase(x, true, λxx. ncase(y, false, λyy. le(xx,yy))) in le(a,b)"
definition lt :: "[i,i]→i" (infixr‹#<\<close> 60)
where "a #< b == not(b #<= a)"
div :: "[i,i]→i" (infixr ‹##› 60)
where
"a ## b ==
letrec div x y be if x #< y then zero else succ(div(x#-y,y))
in div(a,b)"
ackermann :: "[i,i]→i"
where
"ackermann(a,b) ==
letrec ack n m be ncase(n, succ(m), λx.
ncase(m,ack(x,succ(zero)), λy. ack(x,ack(succ(x),y))))
in ack(a,b)"
addT: "[a:Nat; b:Nat]==> a #+ b : Nat"
apply (unfold add_def)
apply typechk
done
multT: "[a:Nat; b:Nat]==> a #* b : Nat"
apply (unfold add_def mult_def)
apply typechk
done
(* Defined to return zero if a<b *) lemma subT: "[a:Nat; b:Nat]==> a #- b : Nat" apply (unfold sub_def) apply typechk apply clean_ccs apply (erule NatPRI [THEN wfstI, THEN NatPR_wf [THEN wmap_wf, THEN wfI]]) done
lemmaleT: "[a:Nat; b:Nat]==> a #<= b : Bool" apply (unfold le_def) apply typechk apply clean_ccs apply (erule NatPRI [THEN wfstI, THEN NatPR_wf [THEN wmap_wf, THEN wfI]]) done
lemma ltT: "[a:Nat; b:Nat]==> a #< b : Bool" apply (unfold not_def lt_def) apply (typechk leT) done
subsection‹Termination Conditions for Ackermann's Function›
lemmas relI = NatPR_wf [THEN NatPR_wf [THEN lex_wf, THEN wfI]]
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.