doc-src/TutorialI/Recdef/Nested2.thy
changeset 11277 a2bff98d6e5d
parent 11196 bb4ede27fcb7
child 11428 332347b9b942
equal deleted inserted replaced
11276:f8353c722d4e 11277:a2bff98d6e5d
     1 (*<*)
     1 (*<*)
     2 theory Nested2 = Nested0:
     2 theory Nested2 = Nested0:
     3 (*>*)
     3 (*>*)
     4 
     4 
     5 text{*The termintion condition is easily proved by induction:*}
     5 text{*The termination condition is easily proved by induction:*}
     6 
     6 
     7 lemma [simp]: "t \<in> set ts \<longrightarrow> size t < Suc(term_list_size ts)"
     7 lemma [simp]: "t \<in> set ts \<longrightarrow> size t < Suc(term_list_size ts)"
     8 by(induct_tac ts, auto)
     8 by(induct_tac ts, auto)
     9 (*<*)
     9 (*<*)
    10 recdef trev "measure size"
    10 recdef trev "measure size"
    59 \isacommand{recdef} would try to prove the unprovable @{term"size t < Suc
    59 \isacommand{recdef} would try to prove the unprovable @{term"size t < Suc
    60 (term_list_size ts)"}, without any assumption about @{term"t"}.  Therefore
    60 (term_list_size ts)"}, without any assumption about @{term"t"}.  Therefore
    61 \isacommand{recdef} has been supplied with the congruence theorem
    61 \isacommand{recdef} has been supplied with the congruence theorem
    62 @{thm[source]map_cong}:
    62 @{thm[source]map_cong}:
    63 @{thm[display,margin=50]"map_cong"[no_vars]}
    63 @{thm[display,margin=50]"map_cong"[no_vars]}
    64 Its second premise expresses (indirectly) that the second argument of
    64 Its second premise expresses (indirectly) that the first argument of
    65 @{term"map"} is only applied to elements of its third argument. Congruence
    65 @{term"map"} is only applied to elements of its second argument. Congruence
    66 rules for other higher-order functions on lists look very similar. If you get
    66 rules for other higher-order functions on lists look very similar. If you get
    67 into a situation where you need to supply \isacommand{recdef} with new
    67 into a situation where you need to supply \isacommand{recdef} with new
    68 congruence rules, you can either append a hint locally
    68 congruence rules, you can either append a hint after the end of
    69 to the specific occurrence of \isacommand{recdef}
    69 the recursion equations
    70 *}
    70 *}
    71 (*<*)
    71 (*<*)
    72 consts dummy :: "nat => nat"
    72 consts dummy :: "nat => nat"
    73 recdef dummy "{}"
    73 recdef dummy "{}"
    74 "dummy n = n"
    74 "dummy n = n"