equal
deleted
inserted
replaced
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))"; |