src/HOL/Real/rat_arith.ML
author nipkow
Tue Oct 23 23:27:23 2007 +0200 (2007-10-23)
changeset 25162 ad4d5365d9d8
parent 24196 f1dbfd7e3223
child 27154 026f3db3f5c6
permissions -rw-r--r--
went back to >0
webertj@20254
     1
(*  Title:      HOL/Real/rat_arith.ML
paulson@14365
     2
    ID:         $Id$
paulson@14365
     3
    Author:     Lawrence C Paulson
paulson@14365
     4
    Copyright   2004 University of Cambridge
paulson@14365
     5
paulson@14365
     6
Simprocs for common factor cancellation & Rational coefficient handling
paulson@14365
     7
paulson@14365
     8
Instantiation of the generic linear arithmetic package for type rat.
paulson@14365
     9
*)
paulson@14365
    10
paulson@14365
    11
local
paulson@14365
    12
paulson@14390
    13
val simprocs = field_cancel_numeral_factors
paulson@14365
    14
haftmann@22548
    15
val simps = [@{thm order_less_irrefl}, @{thm neg_less_iff_less}, @{thm True_implies_equals},
haftmann@22548
    16
             inst "a" "(number_of ?v)" @{thm right_distrib},
haftmann@22548
    17
             @{thm divide_1}, @{thm divide_zero_left},
haftmann@22548
    18
             @{thm times_divide_eq_right}, @{thm times_divide_eq_left},
haftmann@22548
    19
             @{thm minus_divide_left} RS sym, @{thm minus_divide_right} RS sym,
huffman@23346
    20
             @{thm of_int_0}, @{thm of_int_1}, @{thm of_int_add},
huffman@23346
    21
             @{thm of_int_minus}, @{thm of_int_diff},
haftmann@22803
    22
             @{thm of_int_mult}, @{thm of_int_of_nat_eq}]
webertj@20254
    23
haftmann@22803
    24
val nat_inj_thms = [@{thm of_nat_le_iff} RS iffD2,
haftmann@22803
    25
                    @{thm of_nat_eq_iff} RS iffD2]
webertj@20254
    26
(* not needed because x < (y::nat) can be rewritten as Suc x <= y:
webertj@20254
    27
                    of_nat_less_iff RS iffD2 *)
webertj@20254
    28
haftmann@22803
    29
val int_inj_thms = [@{thm of_int_le_iff} RS iffD2,
haftmann@22803
    30
                    @{thm of_int_eq_iff} RS iffD2]
webertj@20254
    31
(* not needed because x < (y::int) can be rewritten as x + 1 <= y:
webertj@20254
    32
                    of_int_less_iff RS iffD2 *)
paulson@14365
    33
paulson@14365
    34
in
paulson@14365
    35
webertj@20254
    36
val ratT = Type ("Rational.rat", [])
paulson@14387
    37
paulson@14365
    38
val rat_arith_setup =
wenzelm@24093
    39
  LinArith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, neqE, simpset} =>
nipkow@15121
    40
   {add_mono_thms = add_mono_thms,
nipkow@15184
    41
    mult_mono_thms = mult_mono_thms,
webertj@20254
    42
    inj_thms = int_inj_thms @ nat_inj_thms @ inj_thms,
wenzelm@24093
    43
    lessD = lessD,  (*Can't change lessD: the rats are dense!*)
nipkow@15923
    44
    neqE =  neqE,
paulson@14387
    45
    simpset = simpset addsimps simps
wenzelm@18708
    46
                      addsimprocs simprocs}) #>
haftmann@24196
    47
  arith_inj_const (@{const_name of_nat}, HOLogic.natT --> ratT) #>
haftmann@24196
    48
  arith_inj_const (@{const_name of_int}, HOLogic.intT --> ratT)
paulson@14365
    49
paulson@14365
    50
end;