Theory Recs_alt_Ex
section ‹Examples for recursive functions using the alternative definitions›
theory Recs_alt_Ex
imports Recs_alt_Def
begin
definition plus_2 :: "recf"
where
"plus_2 = (CN S [S])"
lemma "rec_eval S [0] = Suc 0"
by auto
lemma "rec_eval plus_2 [0] = rec_eval (Cn 8 S [S]) [0]"
unfolding plus_2_def
by auto
lemma "Cn 1 S [S] = CN S [S]"
by auto
lemma "rec_eval plus_2 [0] = 2"
unfolding plus_2_def
by auto
lemma "rec_eval plus_2 [2] = 4"
unfolding plus_2_def
by auto
lemma "rec_eval plus_2 [0,4] = 2"
unfolding plus_2_def
by auto
lemma add_lemma_more_args:
"rec_eval rec_add ([x, y] @ z) = x + y"
by (induct x) (simp_all add: rec_add_def)
lemma "rec_eval (Pr v va vb) [] = undefined"
by auto
lemma add_lemma_no_args:
"rec_eval rec_add [] = undefined"
by (simp_all add: rec_add_def)
lemma add_lemma_one_arg:
"rec_eval rec_add [x] = undefined"
proof (induct x)
case 0
oops
lemma "[]!0 = undefined"
oops
end