src/HOL/Divides.thy
changeset 25571 c9e39eafc7a0
parent 25162 ad4d5365d9d8
child 25942 a52309ac4a4d
equal deleted inserted replaced
25570:fdfbbb92dadf 25571:c9e39eafc7a0
    13 
    13 
    14 class div = times +
    14 class div = times +
    15   fixes div :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "div" 70)
    15   fixes div :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "div" 70)
    16   fixes mod :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "mod" 70)
    16   fixes mod :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "mod" 70)
    17 
    17 
    18 instance nat :: Divides.div
    18 instantiation nat :: Divides.div
       
    19 begin
       
    20 
       
    21 definition
    19   div_def: "m div n == wfrec (pred_nat^+)
    22   div_def: "m div n == wfrec (pred_nat^+)
    20                           (%f j. if j<n | n=0 then 0 else Suc (f (j-n))) m"
    23                           (%f j. if j<n | n=0 then 0 else Suc (f (j-n))) m"
       
    24 
       
    25 definition
    21   mod_def: "m mod n == wfrec (pred_nat^+)
    26   mod_def: "m mod n == wfrec (pred_nat^+)
    22                           (%f j. if j<n | n=0 then j else f (j-n)) m" ..
    27                           (%f j. if j<n | n=0 then j else f (j-n)) m"
       
    28 
       
    29 instance ..
       
    30 
       
    31 end
    23 
    32 
    24 definition (in div)
    33 definition (in div)
    25   dvd  :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "dvd" 50)
    34   dvd  :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "dvd" 50)
    26 where
    35 where
    27   [code func del]: "m dvd n \<longleftrightarrow> (\<exists>k. n = m * k)"
    36   [code func del]: "m dvd n \<longleftrightarrow> (\<exists>k. n = m * k)"