src/HOL/Integ/Integ.thy
author oheimb
Wed, 12 Nov 1997 12:34:43 +0100
changeset 4206 688050e83d89
parent 2618 15451c558a32
child 5491 22f8331cdf47
permissions -rw-r--r--
restored last version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1374
diff changeset
     1
(*  Title:      Integ.thy
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
2224
4fc4b465be5b New material from Norbert Voelker for efficient binary comparisons
paulson
parents: 2215
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
2215
ebf910e7ec87 Tidied up some proofs, ...
paulson
parents: 1559
diff changeset
     4
    Copyright   1996  University of Cambridge
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     5
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     6
The integers as equivalence classes over nat*nat.
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     7
*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     8
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     9
Integ = Equiv + Arith +
1559
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    10
constdefs
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    11
  intrel      :: "((nat * nat) * (nat * nat)) set"
1559
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    12
  "intrel == {p. ? x1 y1 x2 y2. p=((x1::nat,y1),(x2,y2)) & x1+y2 = x2+y1}"
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    13
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1374
diff changeset
    14
typedef (Integ)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1374
diff changeset
    15
  int = "{x::(nat*nat).True}/intrel"            (Equiv.quotient_def)
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    16
994
b5e3fa9664fe replaced 'arities' by 'instance';
wenzelm
parents: 972
diff changeset
    17
instance
b5e3fa9664fe replaced 'arities' by 'instance';
wenzelm
parents: 972
diff changeset
    18
  int :: {ord, plus, times, minus}
b5e3fa9664fe replaced 'arities' by 'instance';
wenzelm
parents: 972
diff changeset
    19
1559
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    20
constdefs
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    21
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    22
  znat        :: nat => int                                  ("$# _" [80] 80)
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    23
  "$# m == Abs_Integ(intrel ^^ {(m,0)})"
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    24
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    25
  zminus      :: int => int                                  ("$~ _" [80] 80)
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    26
  "$~ Z == Abs_Integ(UN p:Rep_Integ(Z). split (%x y. intrel^^{(y,x)}) p)"
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    27
1374
5e407f2a3323 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    28
  znegative   :: int => bool
1559
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    29
  "znegative(Z) == EX x y. x<y & (x,y::nat):Rep_Integ(Z)"
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    30
1374
5e407f2a3323 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    31
  zmagnitude  :: int => int
1559
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    32
  "zmagnitude(Z) == Abs_Integ(UN p:Rep_Integ(Z).
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    33
                              split (%x y. intrel^^{((y-x) + (x-y),0)}) p)"
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    34
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    35
  zpred       :: int=>int
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    36
  "zpred(Z) == Z - $# Suc(0)"
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    37
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    38
  zsuc        :: int=>int
9ba0906aa60d added constdefs section
clasohm
parents: 1476
diff changeset
    39
  "zsuc(Z) == Z + $# Suc(0)"
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    40
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    41
defs
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    42
  zadd_def
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 994
diff changeset
    43
   "Z1 + Z2 == 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 994
diff changeset
    44
       Abs_Integ(UN p1:Rep_Integ(Z1). UN p2:Rep_Integ(Z2).   
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 994
diff changeset
    45
           split (%x1 y1. split (%x2 y2. intrel^^{(x1+x2, y1+y2)}) p2) p1)"
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    46
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    47
  zdiff_def "Z1 - Z2 == Z1 + zminus(Z2)"
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    48
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    49
  zless_def "Z1<Z2 == znegative(Z1 - Z2)"
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    50
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    51
  zle_def   "Z1 <= (Z2::int) == ~(Z2 < Z1)"
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    52
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    53
  zmult_def
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 994
diff changeset
    54
   "Z1 * Z2 == 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 994
diff changeset
    55
       Abs_Integ(UN p1:Rep_Integ(Z1). UN p2:Rep_Integ(Z2). split (%x1 y1.   
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 994
diff changeset
    56
           split (%x2 y2. intrel^^{(x1*x2 + y1*y2, x1*y2 + y1*x2)}) p2) p1)"
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    57
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    58
end