src/HOL/Real/RealDef.thy
author paulson
Fri, 02 Nov 2001 17:55:24 +0100
changeset 12018 ec054019c910
parent 11713 883d559b0b8c
child 12114 a8e860c86252
permissions -rw-r--r--
Numerals and simprocs for types real and hypreal. The abstract
constants 0, 1 and binary numerals work harmoniously.
     1 (*  Title       : Real/RealDef.thy
     2     ID          : $Id$
     3     Author      : Jacques D. Fleuriot
     4     Copyright   : 1998  University of Cambridge
     5     Description : The reals
     6 *) 
     7 
     8 RealDef = PReal +
     9 
    10 instance preal :: order (preal_le_refl,preal_le_trans,preal_le_anti_sym,
    11                          preal_less_le)
    12 
    13 constdefs
    14   realrel   ::  "((preal * preal) * (preal * preal)) set"
    15   "realrel == {p. EX x1 y1 x2 y2. p = ((x1,y1),(x2,y2)) & x1+y2 = x2+y1}" 
    16 
    17 typedef (REAL)
    18   real = "UNIV//realrel"  (Equiv.quotient_def)
    19 
    20 
    21 instance
    22    real  :: {ord, zero, one, plus, times, minus, inverse}
    23 
    24 consts 
    25    (*Overloaded constants denoting the Nat and Real subsets of enclosing
    26      types such as hypreal and complex*)
    27    Nats, Reals :: "'a set"
    28   
    29    (*overloaded constant for injecting other types into "real"*)
    30    real :: 'a => real
    31 
    32 
    33 defs
    34 
    35   real_zero_def  
    36   "0 == Abs_REAL(realrel``{(preal_of_prat(prat_of_pnat 1),
    37 			    preal_of_prat(prat_of_pnat 1))})"
    38 
    39   real_one_def   
    40   "1 == Abs_REAL(realrel``
    41                {(preal_of_prat(prat_of_pnat 1) + preal_of_prat(prat_of_pnat 1),
    42 		 preal_of_prat(prat_of_pnat 1))})"
    43 
    44   real_minus_def
    45   "- R ==  Abs_REAL(UN (x,y):Rep_REAL(R). realrel``{(y,x)})"
    46 
    47   real_diff_def
    48   "R - (S::real) == R + - S"
    49 
    50   real_inverse_def
    51   "inverse (R::real) == (SOME S. (R = 0 & S = 0) | S * R = 1)"
    52 
    53   real_divide_def
    54   "R / (S::real) == R * inverse S"
    55   
    56 constdefs
    57 
    58   (** these don't use the overloaded "real" function: users don't see them **)
    59   
    60   real_of_preal :: preal => real            
    61   "real_of_preal m     ==
    62            Abs_REAL(realrel``{(m + preal_of_prat(prat_of_pnat 1),
    63                                preal_of_prat(prat_of_pnat 1))})"
    64 
    65   real_of_posnat :: nat => real             
    66   "real_of_posnat n == real_of_preal(preal_of_prat(prat_of_pnat(pnat_of_nat n)))"
    67 
    68 
    69 defs
    70 
    71   (*overloaded*)
    72   real_of_nat_def   "real n == real_of_posnat n + (- 1)"
    73 
    74   real_add_def  
    75   "P+Q == Abs_REAL(UN p1:Rep_REAL(P). UN p2:Rep_REAL(Q).
    76                    (%(x1,y1). (%(x2,y2). realrel``{(x1+x2, y1+y2)}) p2) p1)"
    77   
    78   real_mult_def  
    79   "P*Q == Abs_REAL(UN p1:Rep_REAL(P). UN p2:Rep_REAL(Q).
    80                    (%(x1,y1). (%(x2,y2). realrel``{(x1*x2+y1*y2,x1*y2+x2*y1)})
    81 		   p2) p1)"
    82 
    83   real_less_def
    84   "P<Q == EX x1 y1 x2 y2. x1 + y2 < x2 + y1 & 
    85                             (x1,y1):Rep_REAL(P) & (x2,y2):Rep_REAL(Q)" 
    86   real_le_def
    87   "P <= (Q::real) == ~(Q < P)"
    88 
    89 syntax (symbols)
    90   Reals     :: "'a set"                   ("\\<real>")
    91   Nats      :: "'a set"                   ("\\<nat>")
    92 
    93 end