src/HOL/Integ/IntDef.thy
author paulson
Fri, 27 Aug 1999 15:42:10 +0200
changeset 7375 2cb340e66d15
parent 7127 48e235179ffb
child 8937 7328d7c8d201
permissions -rw-r--r--
tidied, allowing pattern-matching in defs of zadd and zmult
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)
7375
2cb340e66d15 tidied, allowing pattern-matching in defs of zadd and zmult
paulson
parents: 7127
diff changeset
    15
  int = "UNIV/intrel"            (Equiv.quotient_def)
5508
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
7375
2cb340e66d15 tidied, allowing pattern-matching in defs of zadd and zmult
paulson
parents: 7127
diff changeset
    22
    "- Z == Abs_Integ(UN (x,y):Rep_Integ(Z). intrel^^{(y,x)})"
5508
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 == 
7375
2cb340e66d15 tidied, allowing pattern-matching in defs of zadd and zmult
paulson
parents: 7127
diff changeset
    39
       Abs_Integ(UN (x1,y1):Rep_Integ(z). UN (x2,y2):Rep_Integ(w).   
2cb340e66d15 tidied, allowing pattern-matching in defs of zadd and zmult
paulson
parents: 7127
diff changeset
    40
		 intrel^^{(x1+x2, y1+y2)})"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    41
7127
48e235179ffb added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents: 5594
diff changeset
    42
  zdiff_def "z - (w::int) == z + (-w)"
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 == 
7375
2cb340e66d15 tidied, allowing pattern-matching in defs of zadd and zmult
paulson
parents: 7127
diff changeset
    50
       Abs_Integ(UN (x1,y1):Rep_Integ(z). UN (x2,y2):Rep_Integ(w).   
2cb340e66d15 tidied, allowing pattern-matching in defs of zadd and zmult
paulson
parents: 7127
diff changeset
    51
		 intrel^^{(x1*x2 + y1*y2, x1*y2 + y1*x2)})"
5508
691c70898518 new files in Integ
paulson
parents:
diff changeset
    52
691c70898518 new files in Integ
paulson
parents:
diff changeset
    53
end