src/HOL/Real/RealArith0.ML
author paulson
Wed, 10 Dec 2003 15:59:34 +0100
changeset 14288 d149e3cbdb39
parent 14284 f1abe67c448a
permissions -rw-r--r--
Moving some theorems from Real/RealArith0.ML
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Real/RealArith.ML
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     2
    ID:         $Id$
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     4
    Copyright   1999  University of Cambridge
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     5
14275
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
     6
Common factor cancellation
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     7
*)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
     8
14275
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
     9
val real_inverse_eq_divide = thm"real_inverse_eq_divide";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    10
val real_mult_less_cancel2 = thm"real_mult_less_cancel2";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    11
val real_mult_le_cancel2 = thm"real_mult_le_cancel2";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    12
val real_mult_less_cancel1 = thm"real_mult_less_cancel1";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    13
val real_mult_le_cancel1 = thm"real_mult_le_cancel1";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    14
val real_mult_eq_cancel1 = thm"real_mult_eq_cancel1";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    15
val real_mult_eq_cancel2 = thm"real_mult_eq_cancel2";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    16
val real_mult_div_cancel1 = thm"real_mult_div_cancel1";
031a5a051bb4 Converting more of the "real" development to Isar scripts
paulson
parents: 14268
diff changeset
    17
val real_mult_div_cancel_disj = thm"real_mult_div_cancel_disj";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    18
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    19
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    20
local
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    21
  open Real_Numeral_Simprocs
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    22
in
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    23
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    24
val rel_real_number_of = [eq_real_number_of, less_real_number_of,
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
    25
                          le_real_number_of_eq_not_less]
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    26
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    27
structure CancelNumeralFactorCommon =
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    28
  struct
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    29
  val mk_coeff          = mk_coeff
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    30
  val dest_coeff        = dest_coeff 1
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    31
  val trans_tac         = trans_tac
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    32
  val norm_tac =
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
    33
     ALLGOALS (simp_tac (HOL_ss addsimps real_minus_from_mult_simps @ mult_1s))
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    34
     THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@real_mult_minus_simps))
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
    35
     THEN ALLGOALS (simp_tac (HOL_ss addsimps real_mult_ac))
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    36
  val numeral_simp_tac  =
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    37
         ALLGOALS (simp_tac (HOL_ss addsimps rel_real_number_of@bin_simps))
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    38
  val simplify_meta_eq  = simplify_meta_eq
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    39
  end
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    40
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    41
structure DivCancelNumeralFactor = CancelNumeralFactorFun
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    42
 (open CancelNumeralFactorCommon
13485
acf39e924091 tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents: 13462
diff changeset
    43
  val prove_conv = Bin_Simprocs.prove_conv
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    44
  val mk_bal   = HOLogic.mk_binop "HOL.divide"
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    45
  val dest_bal = HOLogic.dest_bin "HOL.divide" HOLogic.realT
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    46
  val cancel = real_mult_div_cancel1 RS trans
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    47
  val neg_exchanges = false
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    48
)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    49
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    50
structure EqCancelNumeralFactor = CancelNumeralFactorFun
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    51
 (open CancelNumeralFactorCommon
13485
acf39e924091 tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents: 13462
diff changeset
    52
  val prove_conv = Bin_Simprocs.prove_conv
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    53
  val mk_bal   = HOLogic.mk_eq
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    54
  val dest_bal = HOLogic.dest_bin "op =" HOLogic.realT
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    55
  val cancel = real_mult_eq_cancel1 RS trans
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    56
  val neg_exchanges = false
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    57
)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    58
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    59
structure LessCancelNumeralFactor = CancelNumeralFactorFun
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    60
 (open CancelNumeralFactorCommon
13485
acf39e924091 tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents: 13462
diff changeset
    61
  val prove_conv = Bin_Simprocs.prove_conv
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    62
  val mk_bal   = HOLogic.mk_binrel "op <"
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    63
  val dest_bal = HOLogic.dest_bin "op <" HOLogic.realT
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    64
  val cancel = real_mult_less_cancel1 RS trans
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    65
  val neg_exchanges = true
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    66
)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    67
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    68
structure LeCancelNumeralFactor = CancelNumeralFactorFun
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    69
 (open CancelNumeralFactorCommon
13485
acf39e924091 tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents: 13462
diff changeset
    70
  val prove_conv = Bin_Simprocs.prove_conv
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    71
  val mk_bal   = HOLogic.mk_binrel "op <="
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    72
  val dest_bal = HOLogic.dest_bin "op <=" HOLogic.realT
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    73
  val cancel = real_mult_le_cancel1 RS trans
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    74
  val neg_exchanges = true
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    75
)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    76
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    77
val real_cancel_numeral_factors_relations =
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    78
  map prep_simproc
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    79
   [("realeq_cancel_numeral_factor",
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    80
     ["(l::real) * m = n", "(l::real) = m * n"],
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    81
     EqCancelNumeralFactor.proc),
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    82
    ("realless_cancel_numeral_factor",
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    83
     ["(l::real) * m < n", "(l::real) < m * n"],
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    84
     LessCancelNumeralFactor.proc),
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    85
    ("realle_cancel_numeral_factor",
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    86
     ["(l::real) * m <= n", "(l::real) <= m * n"],
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
    87
     LeCancelNumeralFactor.proc)]
10752
c4f1bf2acf4c tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents: 10722
diff changeset
    88
c4f1bf2acf4c tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents: 10722
diff changeset
    89
val real_cancel_numeral_factors_divide = prep_simproc
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    90
        ("realdiv_cancel_numeral_factor",
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    91
         ["((l::real) * m) / n", "(l::real) / (m * n)",
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    92
          "((number_of v)::real) / (number_of w)"],
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    93
         DivCancelNumeralFactor.proc)
10752
c4f1bf2acf4c tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents: 10722
diff changeset
    94
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    95
val real_cancel_numeral_factors =
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
    96
    real_cancel_numeral_factors_relations @
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
    97
    [real_cancel_numeral_factors_divide]
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    98
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
    99
end;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   100
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   101
Addsimprocs real_cancel_numeral_factors;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   102
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   103
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   104
(*examples:
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   105
print_depth 22;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   106
set timing;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   107
set trace_simp;
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   108
fun test s = (Goal s; by (Simp_tac 1));
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   109
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
   110
test "0 <= (y::real) * -2";
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   111
test "9*x = 12 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   112
test "(9*x) / (12 * (y::real)) = z";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   113
test "9*x < 12 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   114
test "9*x <= 12 * (y::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   115
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   116
test "-99*x = 132 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   117
test "(-99*x) / (132 * (y::real)) = z";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   118
test "-99*x < 132 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   119
test "-99*x <= 132 * (y::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   120
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   121
test "999*x = -396 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   122
test "(999*x) / (-396 * (y::real)) = z";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   123
test "999*x < -396 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   124
test "999*x <= -396 * (y::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   125
12018
ec054019c910 Numerals and simprocs for types real and hypreal. The abstract
paulson
parents: 11704
diff changeset
   126
test  "(- ((2::real) * x) <= 2 * y)";
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   127
test "-99*x = -81 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   128
test "(-99*x) / (-81 * (y::real)) = z";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   129
test "-99*x <= -81 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   130
test "-99*x < -81 * (y::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   131
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   132
test "-2 * x = -1 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   133
test "-2 * x = -(y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   134
test "(-2 * x) / (-1 * (y::real)) = z";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   135
test "-2 * x < -(y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   136
test "-2 * x <= -1 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   137
test "-x < -23 * (y::real)";
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   138
test "-x <= -23 * (y::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   139
*)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   140
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   141
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   142
(** Declarations for ExtractCommonTerm **)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   143
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   144
local
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   145
  open Real_Numeral_Simprocs
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   146
in
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   147
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   148
structure CancelFactorCommon =
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   149
  struct
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   150
  val mk_sum            = long_mk_prod
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   151
  val dest_sum          = dest_prod
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   152
  val mk_coeff          = mk_coeff
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   153
  val dest_coeff        = dest_coeff
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   154
  val find_first        = find_first []
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   155
  val trans_tac         = trans_tac
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   156
  val norm_tac = ALLGOALS (simp_tac (HOL_ss addsimps mult_1s@real_mult_ac))
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   157
  end;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   158
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   159
structure EqCancelFactor = ExtractCommonTermFun
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   160
 (open CancelFactorCommon
13485
acf39e924091 tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents: 13462
diff changeset
   161
  val prove_conv = Bin_Simprocs.prove_conv
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   162
  val mk_bal   = HOLogic.mk_eq
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   163
  val dest_bal = HOLogic.dest_bin "op =" HOLogic.realT
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   164
  val simplify_meta_eq  = cancel_simplify_meta_eq real_mult_eq_cancel1
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   165
);
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   166
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   167
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   168
structure DivideCancelFactor = ExtractCommonTermFun
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   169
 (open CancelFactorCommon
13485
acf39e924091 tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents: 13462
diff changeset
   170
  val prove_conv = Bin_Simprocs.prove_conv
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   171
  val mk_bal   = HOLogic.mk_binop "HOL.divide"
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   172
  val dest_bal = HOLogic.dest_bin "HOL.divide" HOLogic.realT
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   173
  val simplify_meta_eq  = cancel_simplify_meta_eq real_mult_div_cancel_disj
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   174
);
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   175
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   176
val real_cancel_factor =
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   177
  map prep_simproc
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   178
   [("real_eq_cancel_factor", ["(l::real) * m = n", "(l::real) = m * n"], EqCancelFactor.proc),
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   179
    ("real_divide_cancel_factor", ["((l::real) * m) / n", "(l::real) / (m * n)"],
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   180
     DivideCancelFactor.proc)];
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   181
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   182
end;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   183
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   184
Addsimprocs real_cancel_factor;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   185
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   186
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   187
(*examples:
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   188
print_depth 22;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   189
set timing;
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   190
set trace_simp;
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   191
fun test s = (Goal s; by (Asm_simp_tac 1));
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   192
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   193
test "x*k = k*(y::real)";
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   194
test "k = k*(y::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   195
test "a*(b*c) = (b::real)";
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   196
test "a*(b*c) = d*(b::real)*(x*a)";
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   197
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   198
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   199
test "(x*k) / (k*(y::real)) = (uu::real)";
13462
56610e2ba220 sane interface for simprocs;
wenzelm
parents: 12483
diff changeset
   200
test "(k) / (k*(y::real)) = (uu::real)";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   201
test "(a*(b*c)) / ((b::real)) = (uu::real)";
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   202
test "(a*(b*c)) / (d*(b::real)*(x*a)) = (uu::real)";
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   203
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   204
(*FIXME: what do we do about this?*)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   205
test "a*(b*c)/(y*z) = d*(b::real)*(x*a)/z";
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   206
*)
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   207
14284
f1abe67c448a re-organisation of Real/RealArith0.ML; more `Isar scripts
paulson
parents: 14277
diff changeset
   208
val real_inverse_less_iff = thm"real_inverse_less_iff";
f1abe67c448a re-organisation of Real/RealArith0.ML; more `Isar scripts
paulson
parents: 14277
diff changeset
   209
val real_inverse_le_iff = thm"real_inverse_le_iff";
10722
55c8367bab05 rational linear arithmetic
nipkow
parents:
diff changeset
   210
14288
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
   211
val pos_real_less_divide_eq = thm"pos_less_divide_eq";
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
   212
val pos_real_divide_less_eq = thm"pos_divide_less_eq";
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
   213
val pos_real_le_divide_eq = thm"pos_le_divide_eq";
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
   214
val pos_real_divide_le_eq = thm"pos_divide_le_eq";