Integ/Integ.thy
author wenzelm
Fri, 31 Mar 1995 15:09:21 +0200
changeset 237 46532a866823
parent 217 b6c0407f203e
child 249 492493334e0f
permissions -rw-r--r--
replaced 'arities' by 'instance';
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
217
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     1
(*  Title: 	Integ.thy
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     2
    ID:         $Id$
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     3
    Authors: 	Riccardo Mattolini, Dip. Sistemi e Informatica
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     4
        	Lawrence C Paulson, Cambridge University Computer Laboratory
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     5
    Copyright   1994 Universita' di Firenze
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     6
    Copyright   1993  University of Cambridge
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     7
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     8
The integers as equivalence classes over nat*nat.
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
     9
*)
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    10
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    11
Integ = Equiv + Arith +
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    12
consts
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    13
  intrel      :: "((nat * nat) * (nat * nat)) set"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    14
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    15
defs
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    16
  intrel_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    17
   "intrel == {p. ? x1 y1 x2 y2. p=<<x1::nat,y1>,<x2,y2>> & x1+y2 = x2+y1}"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    18
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    19
subtype (Integ)
237
46532a866823 replaced 'arities' by 'instance';
wenzelm
parents: 217
diff changeset
    20
  int = "{x::(nat*nat).True}/intrel"		(Equiv.quotient_def)
217
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    21
237
46532a866823 replaced 'arities' by 'instance';
wenzelm
parents: 217
diff changeset
    22
instance
46532a866823 replaced 'arities' by 'instance';
wenzelm
parents: 217
diff changeset
    23
  int :: {ord, plus, times, minus}
46532a866823 replaced 'arities' by 'instance';
wenzelm
parents: 217
diff changeset
    24
217
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    25
consts
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    26
  zNat        :: "nat set"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    27
  znat	      :: "nat => int"	   ("$# _" [80] 80)
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    28
  zminus      :: "int => int"	   ("$~ _" [80] 80)
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    29
  znegative   :: "int => bool"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    30
  zmagnitude  :: "int => int"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    31
  zdiv,zmod   :: "[int,int]=>int"  (infixl 70)
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    32
  zpred,zsuc  :: "int=>int"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    33
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    34
defs
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    35
  zNat_def    "zNat == {x::nat. True}"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    36
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    37
  znat_def    "$# m == Abs_Integ(intrel ^^ {<m,0>})"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    38
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    39
  zminus_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    40
	"$~ Z == Abs_Integ(UN p:Rep_Integ(Z). split(%x y. intrel^^{<y,x>},p))"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    41
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    42
  znegative_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    43
      "znegative(Z) == EX x y. x<y & <x,y::nat>:Rep_Integ(Z)"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    44
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    45
  zmagnitude_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    46
      "zmagnitude(Z) == Abs_Integ(UN p:Rep_Integ(Z).split(%x y. intrel^^{<(y-x) + (x-y),0>},p))"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    47
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    48
  zadd_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    49
   "Z1 + Z2 == \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    50
\       Abs_Integ(UN p1:Rep_Integ(Z1). UN p2:Rep_Integ(Z2).   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    51
\           split(%x1 y1. split(%x2 y2. intrel^^{<x1+x2, y1+y2>},p2),p1))"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    52
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    53
  zdiff_def "Z1 - Z2 == Z1 + zminus(Z2)"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    54
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    55
  zless_def "Z1<Z2 == znegative(Z1 - Z2)"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    56
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    57
  zle_def   "Z1 <= (Z2::int) == ~(Z2 < Z1)"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    58
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    59
  zmult_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    60
   "Z1 * Z2 == \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    61
\       Abs_Integ(UN p1:Rep_Integ(Z1). UN p2:Rep_Integ(Z2). split(%x1 y1.   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    62
\           split(%x2 y2. intrel^^{<x1*x2 + y1*y2, x1*y2 + y1*x2>},p2),p1))"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    63
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    64
  zdiv_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    65
   "Z1 zdiv Z2 ==   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    66
\       Abs_Integ(UN p1:Rep_Integ(Z1). UN p2:Rep_Integ(Z2). split(%x1 y1.   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    67
\           split(%x2 y2. intrel^^{<(x1-y1)div(x2-y2)+(y1-x1)div(y2-x2),   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    68
\           (x1-y1)div(y2-x2)+(y1-x1)div(x2-y2)>},p2),p1))"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    69
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    70
  zmod_def
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    71
   "Z1 zmod Z2 ==   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    72
\       Abs_Integ(UN p1:Rep_Integ(Z1).UN p2:Rep_Integ(Z2).split(%x1 y1.   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    73
\           split(%x2 y2. intrel^^{<(x1-y1)mod((x2-y2)+(y2-x2)),   \
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    74
\           (x1-y1)mod((x2-y2)+(x2-y2))>},p2),p1))"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    75
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    76
  zsuc_def     "zsuc(Z) == Z + $# Suc(0)"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    77
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    78
  zpred_def    "zpred(Z) == Z - $# Suc(0)"
b6c0407f203e Installation of Integ (ported from ZF by Mattolini)
lcp
parents:
diff changeset
    79
end