(* Title: HOL/Divides.thy
ID: $Id$
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
Copyright 1999 University of Cambridge
The division operators div, mod and the divides relation "dvd"
*)
Divides = NatArith +
(*We use the same class for div and mod;
moreover, dvd is defined whenever multiplication is*)
axclass
div < term
instance nat :: div
instance nat :: plus_ac0 (add_commute,add_assoc,add_0)
consts
div :: ['a::div, 'a] => 'a (infixl 70)
mod :: ['a::div, 'a] => 'a (infixl 70)
dvd :: ['a::times, 'a] => bool (infixl 50)
(*Remainder and quotient are defined here by algorithms and later proved to
satisfy the traditional definition (theorem mod_div_equality)
*)
defs
mod_def "m mod n == wfrec (trancl pred_nat)
(%f j. if j bool"
"quorem == %((a,b), (q,r)).
a = b*q + r &
(if 0