diff -r d8549f4d900b -r 791607529f6d src/HOL/Library/Code_Index.thy --- a/src/HOL/Library/Code_Index.thy Tue Jun 10 15:30:06 2008 +0200 +++ b/src/HOL/Library/Code_Index.thy Tue Jun 10 15:30:33 2008 +0200 @@ -10,7 +10,7 @@ text {* Indices are isomorphic to HOL @{typ nat} but - mapped to target-language builtin integers + mapped to target-language builtin integers. *} subsection {* Datatype of indices *} @@ -74,35 +74,23 @@ definition [simp]: "Suc_index k = index_of_nat (Suc (nat_of_index k))" -lemma index_induct: "P 0 \ (\k. P k \ P (Suc_index k)) \ P k" +rep_datatype "0 \ index" Suc_index proof - + fix P :: "index \ bool" + fix k :: index assume "P 0" then have init: "P (index_of_nat 0)" by simp assume "\k. P k \ P (Suc_index k)" - then have "\n. P (index_of_nat n) \ P (Suc_index (index_of_nat (n)))" . + then have "\n. P (index_of_nat n) \ P (Suc_index (index_of_nat n))" . then have step: "\n. P (index_of_nat n) \ P (index_of_nat (Suc n))" by simp from init step have "P (index_of_nat (nat_of_index k))" by (induct "nat_of_index k") simp_all then show "P k" by simp -qed - -lemma Suc_not_Zero_index: "Suc_index k \ 0" - by simp - -lemma Zero_not_Suc_index: "0 \ Suc_index k" - by simp - -lemma Suc_Suc_index_eq: "Suc_index k = Suc_index l \ k = l" - by simp - -rep_datatype index - distinct Suc_not_Zero_index Zero_not_Suc_index - inject Suc_Suc_index_eq - induction index_induct +qed simp_all lemmas [code func del] = index.recs index.cases declare index_case [case_names nat, cases type: index] -declare index_induct [case_names nat, induct type: index] +declare index.induct [case_names nat, induct type: index] lemma [code func]: "index_size = nat_of_index"