theory Exercises2 = Main: subsection "primitive recursion and induction" datatype 'a tree = Tip | Node "'a tree" 'a "'a tree" text {* define a function that converts a tree into a list in post order by primitive recursion *} consts postorder :: "'a tree \ 'a list" text {* define another function that does the same, but with tail recursion (recursive call at top level only) *} consts postorder_it :: "['a tree, 'a list] \ 'a list" lemma "postorder_it t [] = postorder t" oops subsection "inductively defined sets" consts Ev :: "nat set" inductive Ev intros ZeroI: "0 \ Ev" Add2I: "n \ Ev \ Suc(Suc n) \ Ev" lemma "\ n \ Ev; m \ Ev \ \ m+n \ Ev" oops text {* use method arith to solve linear arithmetic problems *} lemma "n \ Ev \ \k. n = 2*k" oops lemma "n = 2*k \ n \ Ev" oops text {* Solve in Isar: *} lemma "A \ B \ B \ A" oops lemma "A \ (B \ C) \ (A \ B) \ (A \ C)" oops end