src/HOL/Arith.thy
author paulson
Tue May 20 11:38:50 1997 +0200 (1997-05-20)
changeset 3235 351565b7321b
parent 2887 00b8ee790d89
child 3308 da002cef7090
permissions -rw-r--r--
The diff laws must be named: we do "Delsimps [diff_Suc];"
clasohm@923
     1
(*  Title:      HOL/Arith.thy
clasohm@923
     2
    ID:         $Id$
clasohm@923
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1993  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Arithmetic operators and their definitions
clasohm@923
     7
*)
clasohm@923
     8
clasohm@923
     9
Arith = Nat +
clasohm@923
    10
clasohm@923
    11
instance
clasohm@923
    12
  nat :: {plus, minus, times}
clasohm@923
    13
clasohm@923
    14
consts
clasohm@1370
    15
  pred      :: nat => nat
clasohm@1370
    16
  div, mod  :: [nat, nat] => nat  (infixl 70)
clasohm@923
    17
clasohm@923
    18
defs
nipkow@2099
    19
  pred_def  "pred(m) == case m of 0 => 0 | Suc n => n"
paulson@1796
    20
paulson@1796
    21
  mod_def   "m mod n == wfrec (trancl pred_nat)
clasohm@1475
    22
                          (%f j. if j<n then j else f (j-n)) m"
paulson@1796
    23
  div_def   "m div n == wfrec (trancl pred_nat) 
clasohm@1475
    24
                          (%f j. if j<n then 0 else Suc (f (j-n))) m"
pusch@2681
    25
pusch@2681
    26
primrec "op +" nat 
nipkow@2887
    27
  "0 + n = n"
nipkow@2887
    28
  "Suc m + n = Suc(m + n)"
pusch@2681
    29
pusch@2681
    30
primrec "op -" nat 
paulson@3235
    31
  diff_0   "m - 0 = m"
paulson@3235
    32
  diff_Suc "m - Suc n = pred(m - n)"
pusch@2681
    33
pusch@2681
    34
primrec "op *"  nat 
nipkow@2887
    35
  "0 * n = 0"
nipkow@2887
    36
  "Suc m * n = n + (m * n)"
pusch@2681
    37
clasohm@923
    38
end