src/HOL/Integ/IntDef.thy
author paulson
Thu, 15 Jul 1999 10:34:37 +0200
changeset 7010 63120b6dca50
parent 5594 e4439230af67
child 7127 48e235179ffb
permissions -rw-r--r--
more renaming of theorems from _nat to _int (corresponding to a function that was similarly renamed some time ago Also new theorem zmult_int
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
     1
(*  Title:      IntDef.thy
691c70898518 new files in Integ
paulson
parents:
diff changeset
     2
    ID:         $Id$
691c70898518 new files in Integ
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
691c70898518 new files in Integ
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
691c70898518 new files in Integ
paulson
parents:
diff changeset
     5
691c70898518 new files in Integ
paulson
parents:
diff changeset
     6
The integers as equivalence classes over nat*nat.
691c70898518 new files in Integ
paulson
parents:
diff changeset
     7
*)
691c70898518 new files in Integ
paulson
parents:
diff changeset
     8
691c70898518 new files in Integ
paulson
parents:
diff changeset
     9
IntDef = Equiv + Arith +
691c70898518 new files in Integ
paulson
parents:
diff changeset
    10
constdefs
691c70898518 new files in Integ
paulson
parents:
diff changeset
    11
  intrel      :: "((nat * nat) * (nat * nat)) set"
691c70898518 new files in Integ
paulson
parents:
diff changeset
    12
  "intrel == {p. ? x1 y1 x2 y2. p=((x1::nat,y1),(x2,y2)) & x1+y2 = x2+y1}"
691c70898518 new files in Integ
paulson
parents:
diff changeset
    13
691c70898518 new files in Integ
paulson
parents:
diff changeset
    14
typedef (Integ)
691c70898518 new files in Integ
paulson
parents:
diff changeset
    15
  int = "{x::(nat*nat).True}/intrel"            (Equiv.quotient_def)
691c70898518 new files in Integ
paulson
parents:
diff changeset
    16
691c70898518 new files in Integ
paulson
parents:
diff changeset
    17
instance
691c70898518 new files in Integ
paulson
parents:
diff changeset
    18
  int :: {ord, plus, times, minus}
691c70898518 new files in Integ
paulson
parents:
diff changeset
    19
691c70898518 new files in Integ
paulson
parents:
diff changeset
    20
defs
691c70898518 new files in Integ
paulson
parents:
diff changeset
    21
  zminus_def
691c70898518 new files in Integ
paulson
parents:
diff changeset
    22
    "- Z == Abs_Integ(UN p:Rep_Integ(Z). split (%x y. intrel^^{(y,x)}) p)"
691c70898518 new files in Integ
paulson
parents:
diff changeset
    23
691c70898518 new files in Integ
paulson
parents:
diff changeset
    24
constdefs
691c70898518 new files in Integ
paulson
parents:
diff changeset
    25
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
    26
  int :: nat => int
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
    27
  "int m == Abs_Integ(intrel ^^ {(m,0)})"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    28
5540
0f16c3b66ab4 much renaming and reorganization
paulson
parents: 5508
diff changeset
    29
  neg   :: int => bool
0f16c3b66ab4 much renaming and reorganization
paulson
parents: 5508
diff changeset
    30
  "neg(Z) == EX x y. x<y & (x,y::nat):Rep_Integ(Z)"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    31
691c70898518 new files in Integ
paulson
parents:
diff changeset
    32
  (*For simplifying equalities*)
691c70898518 new files in Integ
paulson
parents:
diff changeset
    33
  iszero :: int => bool
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
    34
  "iszero z == z = int 0"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    35
  
691c70898518 new files in Integ
paulson
parents:
diff changeset
    36
defs
691c70898518 new files in Integ
paulson
parents:
diff changeset
    37
  zadd_def
5594
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    38
   "z + w == 
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    39
       Abs_Integ(UN p1:Rep_Integ(z). UN p2:Rep_Integ(w).   
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    40
           split (%x1 y1. split (%x2 y2. intrel^^{(x1+x2, y1+y2)}) p2) p1)"
691c70898518 new files in Integ
paulson
parents:
diff changeset
    41
5594
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    42
  zdiff_def "z - w == z + -(w::int)"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    43
5594
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    44
  zless_def "z<w == neg(z - w)"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    45
5594
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    46
  zle_def   "z <= (w::int) == ~(w < z)"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    47
691c70898518 new files in Integ
paulson
parents:
diff changeset
    48
  zmult_def
5594
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    49
   "z * w == 
e4439230af67 much tidying
paulson
parents: 5582
diff changeset
    50
       Abs_Integ(UN p1:Rep_Integ(z). UN p2:Rep_Integ(w). split (%x1 y1.   
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    51
           split (%x2 y2. intrel^^{(x1*x2 + y1*y2, x1*y2 + y1*x2)}) p2) p1)"
691c70898518 new files in Integ
paulson
parents:
diff changeset
    52
691c70898518 new files in Integ
paulson
parents:
diff changeset
    53
end