arith.thy
author lcp
Wed, 22 Sep 1993 15:43:05 +0200
changeset 2 befa4e9f7c90
parent 0 7949f97df77a
child 21 803ccc4a83bb
permissions -rw-r--r--
Added weak congruence rules to HOL: if_weak_cong, case_weak_cong, split_weak_cong, nat_case_weak_cong, nat_rec_weak_cong. Used in llist.ML to make simplifications faster. HOL/gfp: re-ordered premises to put mono(f) early (first or right after A==gfp(f) in the def_ rules). Renamed some variables in rules, A to X and h to A. Renamed coinduct to weak_coinduct, coinduct2 to coinduct. Strengthened coinduct as suggested by j. Frost, to have the premise X <= f(X Un gfp(f)). HOL/llist: used stronger coinduct rule to strengthen LList_coinduct, LList_equalityI, llist_equalityI, llist_fun_equalityI and to delete the "2" form of those rules. Proved List_Fun_LList_I, LListD_Fun_diag_I and llistD_Fun_range_I to help use the new coinduction rules; most proofs involving them required small changes. Proved prod_fun_range_eq_diag as lemma for llist_equalityI.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/arith.thy
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     5
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     6
Arithmetic operators and their definitions
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     7
*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     8
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     9
Arith = Nat +
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    10
arities nat::plus
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    11
        nat::minus
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    12
        nat::times
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    13
consts
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    14
  div,mod  :: "[nat,nat]=>nat"	(infixl 70)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    15
rules
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    16
  add_def   "m+n == nat_rec(m, n, %u v.Suc(v))"  
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    17
  diff_def  "m-n == nat_rec(n, m, %u v. nat_rec(v, 0, %x y.x))"  
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    18
  mult_def  "m*n == nat_rec(m, 0, %u v. n + v)"  
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    19
  mod_def   "m mod n == wfrec(trancl(pred_nat), m, %j f. if(j<n, j, f(j-n)))"  
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    20
  div_def   "m div n == wfrec(trancl(pred_nat), m, %j f. if(j<n, 0, Suc(f(j-n))))"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    21
end
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    22
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    23
(*"Difference" is subtraction of natural numbers.
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    24
  There are no negative numbers; we have
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    25
     m - n = 0  iff  m<=n   and     m - n = Suc(k) iff m>n.
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    26
  Also, nat_rec(m, 0, %z w.z) is pred(m).   *)