doc-src/TutorialI/Recdef/simplification.thy
changeset 10178 aecb5bf6f76f
parent 10171 59d6633835fa
child 10795 9e888d60d3e5
equal deleted inserted replaced
10177:383b0a1837a9 10178:aecb5bf6f76f
    58 Note that the order of equations is important and hides the side condition
    58 Note that the order of equations is important and hides the side condition
    59 @{prop"n ~= 0"}. Unfortunately, in general the case distinction
    59 @{prop"n ~= 0"}. Unfortunately, in general the case distinction
    60 may not be expressible by pattern matching.
    60 may not be expressible by pattern matching.
    61 
    61 
    62 A very simple alternative is to replace @{text if} by @{text case}, which
    62 A very simple alternative is to replace @{text if} by @{text case}, which
    63 is also available for @{typ"bool"} but is not split automatically:
    63 is also available for @{typ bool} but is not split automatically:
    64 *}
    64 *}
    65 
    65 
    66 consts gcd2 :: "nat\<times>nat \<Rightarrow> nat";
    66 consts gcd2 :: "nat\<times>nat \<Rightarrow> nat";
    67 recdef gcd2 "measure (\<lambda>(m,n).n)"
    67 recdef gcd2 "measure (\<lambda>(m,n).n)"
    68   "gcd2(m,n) = (case n=0 of True \<Rightarrow> m | False \<Rightarrow> gcd2(n,m mod n))";
    68   "gcd2(m,n) = (case n=0 of True \<Rightarrow> m | False \<Rightarrow> gcd2(n,m mod n))";