src/HOL/Fields.thy
author Fabian Huch <huch@in.tum.de>
Fri, 22 Jul 2022 14:39:56 +0200
changeset 75669 43f5dfb7fa35
parent 73411 1f1366966296
child 75878 fcd118d9242f
permissions -rw-r--r--
tuned (some HOL lints, by Yecine Megdiche);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35050
9f841f20dca6 renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
haftmann
parents: 35043
diff changeset
     1
(*  Title:      HOL/Fields.thy
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30961
diff changeset
     2
    Author:     Gertrud Bauer
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30961
diff changeset
     3
    Author:     Steven Obua
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30961
diff changeset
     4
    Author:     Tobias Nipkow
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30961
diff changeset
     5
    Author:     Lawrence C Paulson
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30961
diff changeset
     6
    Author:     Markus Wenzel
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30961
diff changeset
     7
    Author:     Jeremy Avigad
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff changeset
     8
*)
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff changeset
     9
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
    10
section \<open>Fields\<close>
25152
bfde2f8c0f63 partially localized
haftmann
parents: 25078
diff changeset
    11
35050
9f841f20dca6 renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
haftmann
parents: 35043
diff changeset
    12
theory Fields
62481
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    13
imports Nat
25186
f4d1ebffd025 localized further
haftmann
parents: 25152
diff changeset
    14
begin
14421
ee97b6463cb4 new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents: 14398
diff changeset
    15
69502
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    16
context idom
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    17
begin
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    18
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    19
lemma inj_mult_left [simp]: \<open>inj ((*) a) \<longleftrightarrow> a \<noteq> 0\<close> (is \<open>?P \<longleftrightarrow> ?Q\<close>)
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    20
proof
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    21
  assume ?P
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    22
  show ?Q
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    23
  proof
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    24
    assume \<open>a = 0\<close>
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    25
    with \<open>?P\<close> have "inj ((*) 0)"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    26
      by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    27
    moreover have "0 * 0 = 0 * 1"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    28
      by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    29
    ultimately have "0 = 1"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    30
      by (rule injD)
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    31
    then show False
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    32
      by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    33
  qed
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    34
next
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    35
  assume ?Q then show ?P
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    36
    by (auto intro: injI)
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    37
qed
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    38
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    39
end
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    40
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
    41
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
    42
subsection \<open>Division rings\<close>
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    43
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
    44
text \<open>
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    45
  A division ring is like a field, but without the commutativity requirement.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
    46
\<close>
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    47
60352
d46de31a50c4 separate class for division operator, with particular syntax added in more specific classes
haftmann
parents: 59867
diff changeset
    48
class inverse = divide +
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    49
  fixes inverse :: "'a \<Rightarrow> 'a"
58776
95e58e04e534 use NO_MATCH-simproc for distribution rules in field_simps, otherwise field_simps on '(a / (c + d)) * (e + f)' can be non-terminating
hoelzl
parents: 58512
diff changeset
    50
begin
60352
d46de31a50c4 separate class for division operator, with particular syntax added in more specific classes
haftmann
parents: 59867
diff changeset
    51
  
d46de31a50c4 separate class for division operator, with particular syntax added in more specific classes
haftmann
parents: 59867
diff changeset
    52
abbreviation inverse_divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "'/" 70)
d46de31a50c4 separate class for division operator, with particular syntax added in more specific classes
haftmann
parents: 59867
diff changeset
    53
where
d46de31a50c4 separate class for division operator, with particular syntax added in more specific classes
haftmann
parents: 59867
diff changeset
    54
  "inverse_divide \<equiv> divide"
58776
95e58e04e534 use NO_MATCH-simproc for distribution rules in field_simps, otherwise field_simps on '(a / (c + d)) * (e + f)' can be non-terminating
hoelzl
parents: 58512
diff changeset
    55
95e58e04e534 use NO_MATCH-simproc for distribution rules in field_simps, otherwise field_simps on '(a / (c + d)) * (e + f)' can be non-terminating
hoelzl
parents: 58512
diff changeset
    56
end
95e58e04e534 use NO_MATCH-simproc for distribution rules in field_simps, otherwise field_simps on '(a / (c + d)) * (e + f)' can be non-terminating
hoelzl
parents: 58512
diff changeset
    57
62481
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    58
text \<open>Setup for linear arithmetic prover\<close>
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    59
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69593
diff changeset
    60
ML_file \<open>~~/src/Provers/Arith/fast_lin_arith.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69593
diff changeset
    61
ML_file \<open>Tools/lin_arith.ML\<close>
62481
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    62
setup \<open>Lin_Arith.global_setup\<close>
70356
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    63
declaration \<open>K (
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    64
  Lin_Arith.init_arith_data
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    65
  #> Lin_Arith.add_discrete_type \<^type_name>\<open>nat\<close>
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    66
  #> Lin_Arith.add_lessD @{thm Suc_leI}
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    67
  #> Lin_Arith.add_simps @{thms simp_thms ring_distribs if_True if_False
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    68
      minus_diff_eq
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    69
      add_0_left add_0_right order_less_irrefl
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    70
      zero_neq_one zero_less_one zero_le_one
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    71
      zero_neq_one [THEN not_sym] not_one_le_zero not_one_less_zero
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    72
      add_Suc add_Suc_right nat.inject
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    73
      Suc_le_mono Suc_less_eq Zero_not_Suc
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    74
      Suc_not_Zero le_0_eq One_nat_def}
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    75
  #> Lin_Arith.add_simprocs [\<^simproc>\<open>group_cancel_add\<close>, \<^simproc>\<open>group_cancel_diff\<close>,
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    76
      \<^simproc>\<open>group_cancel_eq\<close>, \<^simproc>\<open>group_cancel_le\<close>,
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    77
      \<^simproc>\<open>group_cancel_less\<close>,
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    78
      \<^simproc>\<open>nateq_cancel_sums\<close>,\<^simproc>\<open>natless_cancel_sums\<close>,
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    79
      \<^simproc>\<open>natle_cancel_sums\<close>])\<close>
62481
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    80
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    81
simproc_setup fast_arith_nat ("(m::nat) < n" | "(m::nat) \<le> n" | "(m::nat) = n") =
70356
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    82
  \<open>K Lin_Arith.simproc\<close> \<comment> \<open>Because of this simproc, the arithmetic solver is
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    83
   really only useful to detect inconsistencies among the premises for subgoals which are
70357
4d0b789e4e21 made LaTeX happy
haftmann
parents: 70356
diff changeset
    84
   \<^emph>\<open>not\<close> themselves (in)equalities, because the latter activate
4d0b789e4e21 made LaTeX happy
haftmann
parents: 70356
diff changeset
    85
   \<^text>\<open>fast_nat_arith_simproc\<close> anyway. However, it seems cheaper to activate the
70356
4a327c061870 streamlined setup for linear algebra, particularly removed redundant rule declarations
haftmann
parents: 70344
diff changeset
    86
   solver all the time rather than add the additional check.\<close>
62481
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    87
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    88
lemmas [arith_split] = nat_diff_split split_min split_max
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
    89
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61238
diff changeset
    90
text\<open>Lemmas \<open>divide_simps\<close> move division to the outside and eliminates them on (in)equalities.\<close>
56481
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
    91
57950
59c17b0b870d updated to named_theorems;
wenzelm
parents: 57514
diff changeset
    92
named_theorems divide_simps "rewrite rules to eliminate divisions"
56481
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
    93
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    94
class division_ring = ring_1 + inverse +
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    95
  assumes left_inverse [simp]:  "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    96
  assumes right_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> a * inverse a = 1"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    97
  assumes divide_inverse: "a / b = a * inverse b"
59867
58043346ca64 given up separate type classes demanding `inverse 0 = 0`
haftmann
parents: 59779
diff changeset
    98
  assumes inverse_zero [simp]: "inverse 0 = 0"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
    99
begin
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   100
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   101
subclass ring_1_no_zero_divisors
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   102
proof
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   103
  fix a b :: 'a
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   104
  assume a: "a \<noteq> 0" and b: "b \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   105
  show "a * b \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   106
  proof
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   107
    assume ab: "a * b = 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   108
    hence "0 = inverse a * (a * b) * inverse b" by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   109
    also have "\<dots> = (inverse a * a) * (b * inverse b)"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   110
      by (simp only: mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   111
    also have "\<dots> = 1" using a b by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   112
    finally show False by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   113
  qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   114
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   115
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   116
lemma nonzero_imp_inverse_nonzero:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   117
  "a \<noteq> 0 \<Longrightarrow> inverse a \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   118
proof
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   119
  assume ianz: "inverse a = 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   120
  assume "a \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   121
  hence "1 = a * inverse a" by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   122
  also have "... = 0" by (simp add: ianz)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   123
  finally have "1 = 0" .
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   124
  thus False by (simp add: eq_commute)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   125
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   126
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   127
lemma inverse_zero_imp_zero:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   128
  assumes "inverse a = 0" shows "a = 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   129
proof (rule ccontr)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   130
  assume "a \<noteq> 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   131
  then have "inverse a \<noteq> 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   132
    by (simp add: nonzero_imp_inverse_nonzero)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   133
  with assms show False
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   134
    by auto
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   135
qed
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   136
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   137
lemma inverse_unique:
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   138
  assumes ab: "a * b = 1"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   139
  shows "inverse a = b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   140
proof -
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   141
  have "a \<noteq> 0" using ab by (cases "a = 0") simp_all
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   142
  moreover have "inverse a * (a * b) = inverse a" by (simp add: ab)
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   143
  ultimately show ?thesis by (simp add: mult.assoc [symmetric])
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   144
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   145
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   146
lemma nonzero_inverse_minus_eq:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   147
  "a \<noteq> 0 \<Longrightarrow> inverse (- a) = - inverse a"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   148
by (rule inverse_unique) simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   149
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   150
lemma nonzero_inverse_inverse_eq:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   151
  "a \<noteq> 0 \<Longrightarrow> inverse (inverse a) = a"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   152
by (rule inverse_unique) simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   153
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   154
lemma nonzero_inverse_eq_imp_eq:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   155
  assumes "inverse a = inverse b" and "a \<noteq> 0" and "b \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   156
  shows "a = b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   157
proof -
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   158
  from \<open>inverse a = inverse b\<close>
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   159
  have "inverse (inverse a) = inverse (inverse b)" by (rule arg_cong)
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   160
  with \<open>a \<noteq> 0\<close> and \<open>b \<noteq> 0\<close> show "a = b"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   161
    by (simp add: nonzero_inverse_inverse_eq)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   162
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   163
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   164
lemma inverse_1 [simp]: "inverse 1 = 1"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   165
by (rule inverse_unique) simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   166
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   167
lemma nonzero_inverse_mult_distrib:
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   168
  assumes "a \<noteq> 0" and "b \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   169
  shows "inverse (a * b) = inverse b * inverse a"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   170
proof -
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   171
  have "a * (b * inverse b) * inverse a = 1" using assms by simp
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   172
  hence "a * b * (inverse b * inverse a) = 1" by (simp only: mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   173
  thus ?thesis by (rule inverse_unique)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   174
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   175
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   176
lemma division_ring_inverse_add:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   177
  "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a + inverse b = inverse a * (a + b) * inverse b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   178
by (simp add: algebra_simps)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   179
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   180
lemma division_ring_inverse_diff:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   181
  "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a - inverse b = inverse a * (b - a) * inverse b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   182
by (simp add: algebra_simps)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   183
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   184
lemma right_inverse_eq: "b \<noteq> 0 \<Longrightarrow> a / b = 1 \<longleftrightarrow> a = b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   185
proof
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   186
  assume neq: "b \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   187
  {
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   188
    hence "a = (a / b) * b" by (simp add: divide_inverse mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   189
    also assume "a / b = 1"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   190
    finally show "a = b" by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   191
  next
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   192
    assume "a = b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   193
    with neq show "a / b = 1" by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   194
  }
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   195
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   196
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   197
lemma nonzero_inverse_eq_divide: "a \<noteq> 0 \<Longrightarrow> inverse a = 1 / a"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   198
by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   199
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   200
lemma divide_self [simp]: "a \<noteq> 0 \<Longrightarrow> a / a = 1"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   201
by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   202
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
   203
lemma inverse_eq_divide [field_simps, field_split_simps, divide_simps]: "inverse a = 1 / a"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   204
by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   205
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   206
lemma add_divide_distrib: "(a+b) / c = a/c + b/c"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   207
by (simp add: divide_inverse algebra_simps)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   208
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   209
lemma times_divide_eq_right [simp]: "a * (b / c) = (a * b) / c"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   210
  by (simp add: divide_inverse mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   211
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   212
lemma minus_divide_left: "- (a / b) = (-a) / b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   213
  by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   214
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   215
lemma nonzero_minus_divide_right: "b \<noteq> 0 \<Longrightarrow> - (a / b) = a / (- b)"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   216
  by (simp add: divide_inverse nonzero_inverse_minus_eq)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   217
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   218
lemma nonzero_minus_divide_divide: "b \<noteq> 0 \<Longrightarrow> (-a) / (-b) = a / b"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   219
  by (simp add: divide_inverse nonzero_inverse_minus_eq)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   220
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56445
diff changeset
   221
lemma divide_minus_left [simp]: "(-a) / b = - (a / b)"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   222
  by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   223
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   224
lemma diff_divide_distrib: "(a - b) / c = a / c - b / c"
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56445
diff changeset
   225
  using add_divide_distrib [of a "- b" c] by simp
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   226
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   227
lemma nonzero_eq_divide_eq [field_simps]: "c \<noteq> 0 \<Longrightarrow> a = b / c \<longleftrightarrow> a * c = b"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   228
proof -
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   229
  assume [simp]: "c \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   230
  have "a = b / c \<longleftrightarrow> a * c = (b / c) * c" by simp
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   231
  also have "... \<longleftrightarrow> a * c = b" by (simp add: divide_inverse mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   232
  finally show ?thesis .
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   233
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   234
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   235
lemma nonzero_divide_eq_eq [field_simps]: "c \<noteq> 0 \<Longrightarrow> b / c = a \<longleftrightarrow> b = a * c"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   236
proof -
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   237
  assume [simp]: "c \<noteq> 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   238
  have "b / c = a \<longleftrightarrow> (b / c) * c = a * c" by simp
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   239
  also have "... \<longleftrightarrow> b = a * c" by (simp add: divide_inverse mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   240
  finally show ?thesis .
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   241
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   242
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   243
lemma nonzero_neg_divide_eq_eq [field_simps]: "b \<noteq> 0 \<Longrightarrow> - (a / b) = c \<longleftrightarrow> - a = c * b"
59535
9e7467829db5 less warnings
haftmann
parents: 58889
diff changeset
   244
  using nonzero_divide_eq_eq[of b "-a" c] by simp
56441
49e95c9ebb59 made field_simps "more complete"
nipkow
parents: 56414
diff changeset
   245
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   246
lemma nonzero_neg_divide_eq_eq2 [field_simps]: "b \<noteq> 0 \<Longrightarrow> c = - (a / b) \<longleftrightarrow> c * b = - a"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   247
  using nonzero_neg_divide_eq_eq[of b a c] by auto
56441
49e95c9ebb59 made field_simps "more complete"
nipkow
parents: 56414
diff changeset
   248
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   249
lemma divide_eq_imp: "c \<noteq> 0 \<Longrightarrow> b = a * c \<Longrightarrow> b / c = a"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   250
  by (simp add: divide_inverse mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   251
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   252
lemma eq_divide_imp: "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   253
  by (drule sym) (simp add: divide_inverse mult.assoc)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   254
56445
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   255
lemma add_divide_eq_iff [field_simps]:
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   256
  "z \<noteq> 0 \<Longrightarrow> x + y / z = (x * z + y) / z"
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   257
  by (simp add: add_divide_distrib nonzero_eq_divide_eq)
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   258
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   259
lemma divide_add_eq_iff [field_simps]:
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   260
  "z \<noteq> 0 \<Longrightarrow> x / z + y = (x + y * z) / z"
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   261
  by (simp add: add_divide_distrib nonzero_eq_divide_eq)
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   262
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   263
lemma diff_divide_eq_iff [field_simps]:
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   264
  "z \<noteq> 0 \<Longrightarrow> x - y / z = (x * z - y) / z"
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   265
  by (simp add: diff_divide_distrib nonzero_eq_divide_eq eq_diff_eq)
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   266
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   267
lemma minus_divide_add_eq_iff [field_simps]:
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   268
  "z \<noteq> 0 \<Longrightarrow> - (x / z) + y = (- x + y * z) / z"
59535
9e7467829db5 less warnings
haftmann
parents: 58889
diff changeset
   269
  by (simp add: add_divide_distrib diff_divide_eq_iff)
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   270
56445
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   271
lemma divide_diff_eq_iff [field_simps]:
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   272
  "z \<noteq> 0 \<Longrightarrow> x / z - y = (x - y * z) / z"
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   273
  by (simp add: field_simps)
82ce19612fe8 tuned lemmas: more general class
nipkow
parents: 56441
diff changeset
   274
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   275
lemma minus_divide_diff_eq_iff [field_simps]:
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   276
  "z \<noteq> 0 \<Longrightarrow> - (x / z) - y = (- x - y * z) / z"
59535
9e7467829db5 less warnings
haftmann
parents: 58889
diff changeset
   277
  by (simp add: divide_diff_eq_iff[symmetric])
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   278
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   279
lemma division_ring_divide_zero [simp]:
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   280
  "a / 0 = 0"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   281
  by (simp add: divide_inverse)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   282
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   283
lemma divide_self_if [simp]:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   284
  "a / a = (if a = 0 then 0 else 1)"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   285
  by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   286
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   287
lemma inverse_nonzero_iff_nonzero [simp]:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   288
  "inverse a = 0 \<longleftrightarrow> a = 0"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 73411
diff changeset
   289
  by (rule iffI) (fact inverse_zero_imp_zero, simp)
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   290
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   291
lemma inverse_minus_eq [simp]:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   292
  "inverse (- a) = - inverse a"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   293
proof cases
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   294
  assume "a=0" thus ?thesis by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   295
next
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   296
  assume "a\<noteq>0"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   297
  thus ?thesis by (simp add: nonzero_inverse_minus_eq)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   298
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   299
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   300
lemma inverse_inverse_eq [simp]:
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   301
  "inverse (inverse a) = a"
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   302
proof cases
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   303
  assume "a=0" thus ?thesis by simp
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   304
next
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   305
  assume "a\<noteq>0"
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   306
  thus ?thesis by (simp add: nonzero_inverse_inverse_eq)
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   307
qed
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   308
44680
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   309
lemma inverse_eq_imp_eq:
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   310
  "inverse a = inverse b \<Longrightarrow> a = b"
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   311
  by (drule arg_cong [where f="inverse"], simp)
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   312
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   313
lemma inverse_eq_iff_eq [simp]:
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   314
  "inverse a = inverse b \<longleftrightarrow> a = b"
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   315
  by (force dest!: inverse_eq_imp_eq)
761f427ef1ab simplify proof
huffman
parents: 44064
diff changeset
   316
69791
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   317
lemma mult_commute_imp_mult_inverse_commute:
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   318
  assumes "y * x = x * y"
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   319
  shows   "inverse y * x = x * inverse y"
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   320
proof (cases "y=0")
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   321
  case False
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   322
  hence "x * inverse y = inverse y * y * x * inverse y"
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   323
    by simp
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   324
  also have "\<dots> = inverse y * (x * y * inverse y)"
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   325
    by (simp add: mult.assoc assms)
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   326
  finally show ?thesis by (simp add: mult.assoc False)
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   327
qed simp
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   328
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   329
lemmas mult_inverse_of_nat_commute =
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   330
  mult_commute_imp_mult_inverse_commute[OF mult_of_nat_commute]
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   331
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   332
lemma divide_divide_eq_left':
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   333
  "(a / b) / c = a / (c * b)"
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   334
  by (cases "b = 0 \<or> c = 0")
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   335
     (auto simp: divide_inverse mult.assoc nonzero_inverse_mult_distrib)
195aeee8b30a Formal Laurent series and overhaul of Formal power series (due to Jeremy Sylvestre)
Manuel Eberl <eberlm@in.tum.de>
parents: 69605
diff changeset
   336
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
   337
lemma add_divide_eq_if_simps [field_split_simps, divide_simps]:
56481
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   338
    "a + b / z = (if z = 0 then a else (a * z + b) / z)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   339
    "a / z + b = (if z = 0 then b else (a + b * z) / z)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   340
    "- (a / z) + b = (if z = 0 then b else (-a + b * z) / z)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   341
    "a - b / z = (if z = 0 then a else (a * z - b) / z)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   342
    "a / z - b = (if z = 0 then -b else (a - b * z) / z)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   343
    "- (a / z) - b = (if z = 0 then -b else (- a - b * z) / z)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   344
  by (simp_all add: add_divide_eq_iff divide_add_eq_iff diff_divide_eq_iff divide_diff_eq_iff
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   345
      minus_divide_diff_eq_iff)
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   346
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
   347
lemma [field_split_simps, divide_simps]:
56481
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   348
  shows divide_eq_eq: "b / c = a \<longleftrightarrow> (if c \<noteq> 0 then b = a * c else a = 0)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   349
    and eq_divide_eq: "a = b / c \<longleftrightarrow> (if c \<noteq> 0 then a * c = b else a = 0)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   350
    and minus_divide_eq_eq: "- (b / c) = a \<longleftrightarrow> (if c \<noteq> 0 then - b = a * c else a = 0)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   351
    and eq_minus_divide_eq: "a = - (b / c) \<longleftrightarrow> (if c \<noteq> 0 then a * c = - b else a = 0)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   352
  by (auto simp add:  field_simps)
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
   353
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   354
end
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   355
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   356
subsection \<open>Fields\<close>
44064
5bce8ff0d9ae moved division ring stuff from Rings.thy to Fields.thy
huffman
parents: 42904
diff changeset
   357
22987
550709aa8e66 instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents: 22842
diff changeset
   358
class field = comm_ring_1 + inverse +
35084
e25eedfc15ce moved constants inverse and divide to Ring.thy
haftmann
parents: 35050
diff changeset
   359
  assumes field_inverse: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1"
e25eedfc15ce moved constants inverse and divide to Ring.thy
haftmann
parents: 35050
diff changeset
   360
  assumes field_divide_inverse: "a / b = a * inverse b"
59867
58043346ca64 given up separate type classes demanding `inverse 0 = 0`
haftmann
parents: 59779
diff changeset
   361
  assumes field_inverse_zero: "inverse 0 = 0"
25267
1f745c599b5c proper reinitialisation after subclass
haftmann
parents: 25238
diff changeset
   362
begin
20496
23eb6034c06d added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents: 19404
diff changeset
   363
25267
1f745c599b5c proper reinitialisation after subclass
haftmann
parents: 25238
diff changeset
   364
subclass division_ring
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28559
diff changeset
   365
proof
22987
550709aa8e66 instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents: 22842
diff changeset
   366
  fix a :: 'a
550709aa8e66 instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents: 22842
diff changeset
   367
  assume "a \<noteq> 0"
550709aa8e66 instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents: 22842
diff changeset
   368
  thus "inverse a * a = 1" by (rule field_inverse)
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   369
  thus "a * inverse a = 1" by (simp only: mult.commute)
35084
e25eedfc15ce moved constants inverse and divide to Ring.thy
haftmann
parents: 35050
diff changeset
   370
next
e25eedfc15ce moved constants inverse and divide to Ring.thy
haftmann
parents: 35050
diff changeset
   371
  fix a b :: 'a
e25eedfc15ce moved constants inverse and divide to Ring.thy
haftmann
parents: 35050
diff changeset
   372
  show "a / b = a * inverse b" by (rule field_divide_inverse)
59867
58043346ca64 given up separate type classes demanding `inverse 0 = 0`
haftmann
parents: 59779
diff changeset
   373
next
58043346ca64 given up separate type classes demanding `inverse 0 = 0`
haftmann
parents: 59779
diff changeset
   374
  show "inverse 0 = 0"
58043346ca64 given up separate type classes demanding `inverse 0 = 0`
haftmann
parents: 59779
diff changeset
   375
    by (fact field_inverse_zero) 
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 14603
diff changeset
   376
qed
25230
022029099a83 continued localization
haftmann
parents: 25193
diff changeset
   377
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   378
subclass idom_divide
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   379
proof
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   380
  fix b a
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   381
  assume "b \<noteq> 0"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   382
  then show "a * b / b = a"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   383
    by (simp add: divide_inverse ac_simps)
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   384
next
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   385
  fix a
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   386
  show "a / 0 = 0"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   387
    by (simp add: divide_inverse)
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   388
qed
25230
022029099a83 continued localization
haftmann
parents: 25193
diff changeset
   389
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   390
text\<open>There is no slick version using division by zero.\<close>
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   391
lemma inverse_add:
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   392
  "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a + inverse b = (a + b) * inverse a * inverse b"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   393
  by (simp add: division_ring_inverse_add ac_simps)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   394
70147
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   395
lemma nonzero_mult_divide_mult_cancel_left [simp]:
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   396
  assumes [simp]: "c \<noteq> 0"
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   397
  shows "(c * a) / (c * b) = a / b"
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   398
proof (cases "b = 0")
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   399
  case True then show ?thesis by simp
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   400
next
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   401
  case False
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   402
  then have "(c*a)/(c*b) = c * a * (inverse b * inverse c)"
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   403
    by (simp add: divide_inverse nonzero_inverse_mult_distrib)
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   404
  also have "... =  a * inverse b * (inverse c * c)"
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   405
    by (simp only: ac_simps)
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   406
  also have "... =  a * inverse b" by simp
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   407
    finally show ?thesis by (simp add: divide_inverse)
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   408
qed
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   409
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   410
lemma nonzero_mult_divide_mult_cancel_right [simp]:
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   411
  "c \<noteq> 0 \<Longrightarrow> (a * c) / (b * c) = a / b"
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   412
  using nonzero_mult_divide_mult_cancel_left [of c a b] by (simp add: ac_simps)
1657688a6406 backed out a93e6472ac9c, which does not bring anything substantial: division_ring is not commutative in multiplication but semidom_divide is
haftmann
parents: 70094
diff changeset
   413
36304
6984744e6b34 less special treatment of times_divide_eq [simp]
haftmann
parents: 36301
diff changeset
   414
lemma times_divide_eq_left [simp]: "(b / c) * a = (b * a) / c"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   415
  by (simp add: divide_inverse ac_simps)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   416
61238
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
   417
lemma divide_inverse_commute: "a / b = inverse b * a"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
   418
  by (simp add: divide_inverse mult.commute)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
   419
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   420
lemma add_frac_eq:
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   421
  assumes "y \<noteq> 0" and "z \<noteq> 0"
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   422
  shows "x / y + w / z = (x * z + w * y) / (y * z)"
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   423
proof -
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   424
  have "x / y + w / z = (x * z) / (y * z) + (y * w) / (y * z)"
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   425
    using assms by simp
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   426
  also have "\<dots> = (x * z + y * w) / (y * z)"
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   427
    by (simp only: add_divide_distrib)
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   428
  finally show ?thesis
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   429
    by (simp only: mult.commute)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   430
qed
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   431
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   432
text\<open>Special Cancellation Simprules for Division\<close>
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   433
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   434
lemma nonzero_divide_mult_cancel_right [simp]:
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   435
  "b \<noteq> 0 \<Longrightarrow> b / (a * b) = 1 / a"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   436
  using nonzero_mult_divide_mult_cancel_right [of b 1 a] by simp
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   437
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   438
lemma nonzero_divide_mult_cancel_left [simp]:
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   439
  "a \<noteq> 0 \<Longrightarrow> a / (a * b) = 1 / b"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   440
  using nonzero_mult_divide_mult_cancel_left [of a 1 b] by simp
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   441
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   442
lemma nonzero_mult_divide_mult_cancel_left2 [simp]:
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   443
  "c \<noteq> 0 \<Longrightarrow> (c * a) / (b * c) = a / b"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   444
  using nonzero_mult_divide_mult_cancel_left [of c a b] by (simp add: ac_simps)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   445
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   446
lemma nonzero_mult_divide_mult_cancel_right2 [simp]:
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   447
  "c \<noteq> 0 \<Longrightarrow> (a * c) / (c * b) = a / b"
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   448
  using nonzero_mult_divide_mult_cancel_right [of b c a] by (simp add: ac_simps)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   449
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   450
lemma diff_frac_eq:
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   451
  "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y - w / z = (x * z - w * y) / (y * z)"
36348
89c54f51f55a dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents: 36343
diff changeset
   452
  by (simp add: field_simps)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   453
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   454
lemma frac_eq_eq:
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   455
  "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> (x / y = w / z) = (x * z = w * y)"
36348
89c54f51f55a dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents: 36343
diff changeset
   456
  by (simp add: field_simps)
89c54f51f55a dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents: 36343
diff changeset
   457
58512
dc4d76dfa8f0 moved lemmas out of Int.thy which have nothing to do with int
haftmann
parents: 57950
diff changeset
   458
lemma divide_minus1 [simp]: "x / - 1 = - x"
dc4d76dfa8f0 moved lemmas out of Int.thy which have nothing to do with int
haftmann
parents: 57950
diff changeset
   459
  using nonzero_minus_divide_right [of "1" x] by simp
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   460
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   461
text\<open>This version builds in division by zero while also re-orienting
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   462
      the right-hand side.\<close>
14270
342451d763f9 More re-organising of numerical theorems
paulson
parents: 14269
diff changeset
   463
lemma inverse_mult_distrib [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   464
  "inverse (a * b) = inverse a * inverse b"
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   465
proof cases
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
   466
  assume "a \<noteq> 0 \<and> b \<noteq> 0"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   467
  thus ?thesis by (simp add: nonzero_inverse_mult_distrib ac_simps)
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   468
next
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
   469
  assume "\<not> (a \<noteq> 0 \<and> b \<noteq> 0)"
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   470
  thus ?thesis by force
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   471
qed
14270
342451d763f9 More re-organising of numerical theorems
paulson
parents: 14269
diff changeset
   472
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14353
diff changeset
   473
lemma inverse_divide [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   474
  "inverse (a / b) = b / a"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   475
  by (simp add: divide_inverse mult.commute)
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14353
diff changeset
   476
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   477
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   478
text \<open>Calculations with fractions\<close>
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
   479
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61238
diff changeset
   480
text\<open>There is a whole bunch of simp-rules just for class \<open>field\<close> but none for class \<open>field\<close> and \<open>nonzero_divides\<close>
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   481
because the latter are covered by a simproc.\<close>
23413
5caa2710dd5b tuned laws for cancellation in divisions for fields.
nipkow
parents: 23406
diff changeset
   482
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   483
lemmas mult_divide_mult_cancel_left = nonzero_mult_divide_mult_cancel_left
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
   484
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   485
lemmas mult_divide_mult_cancel_right = nonzero_mult_divide_mult_cancel_right
23413
5caa2710dd5b tuned laws for cancellation in divisions for fields.
nipkow
parents: 23406
diff changeset
   486
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   487
lemma divide_divide_eq_right [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   488
  "a / (b / c) = (a * c) / b"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   489
  by (simp add: divide_inverse ac_simps)
14288
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
   490
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   491
lemma divide_divide_eq_left [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   492
  "(a / b) / c = a / (b * c)"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   493
  by (simp add: divide_inverse mult.assoc)
14288
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
   494
56365
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   495
lemma divide_divide_times_eq:
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   496
  "(x / y) / (z / w) = (x * w) / (y * z)"
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   497
  by simp
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   498
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   499
text \<open>Special Cancellation Simprules for Division\<close>
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   500
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   501
lemma mult_divide_mult_cancel_left_if [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   502
  shows "(c * a) / (c * b) = (if c = 0 then 0 else a / b)"
60353
838025c6e278 implicit partial divison operation in integral domains
haftmann
parents: 60352
diff changeset
   503
  by simp
23413
5caa2710dd5b tuned laws for cancellation in divisions for fields.
nipkow
parents: 23406
diff changeset
   504
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   505
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   506
text \<open>Division and Unary Minus\<close>
14293
22542982bffd moving some division theorems to Ring_and_Field
paulson
parents: 14288
diff changeset
   507
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   508
lemma minus_divide_right:
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   509
  "- (a / b) = a / - b"
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   510
  by (simp add: divide_inverse)
14430
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   511
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56445
diff changeset
   512
lemma divide_minus_right [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   513
  "a / - b = - (a / b)"
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   514
  by (simp add: divide_inverse)
30630
4fbe1401bac2 move field lemmas into class locale context
huffman
parents: 30242
diff changeset
   515
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56445
diff changeset
   516
lemma minus_divide_divide:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   517
  "(- a) / (- b) = a / b"
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   518
  by (cases "b=0") (simp_all add: nonzero_minus_divide_divide)
14293
22542982bffd moving some division theorems to Ring_and_Field
paulson
parents: 14288
diff changeset
   519
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   520
lemma inverse_eq_1_iff [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   521
  "inverse x = 1 \<longleftrightarrow> x = 1"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 73411
diff changeset
   522
  using inverse_eq_iff_eq [of x 1] by simp
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   523
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   524
lemma divide_eq_0_iff [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   525
  "a / b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   526
  by (simp add: divide_inverse)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   527
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   528
lemma divide_cancel_right [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   529
  "a / c = b / c \<longleftrightarrow> c = 0 \<or> a = b"
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   530
  by (cases "c=0") (simp_all add: divide_inverse)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   531
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   532
lemma divide_cancel_left [simp]:
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   533
  "c / a = c / b \<longleftrightarrow> c = 0 \<or> a = b"
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   534
  by (cases "c=0") (simp_all add: divide_inverse)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   535
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   536
lemma divide_eq_1_iff [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   537
  "a / b = 1 \<longleftrightarrow> b \<noteq> 0 \<and> a = b"
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   538
  by (cases "b=0") (simp_all add: right_inverse_eq)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   539
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   540
lemma one_eq_divide_iff [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   541
  "1 = a / b \<longleftrightarrow> b \<noteq> 0 \<and> a = b"
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   542
  by (simp add: eq_commute [of 1])
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   543
65057
799bbbb3a395 Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
paulson <lp15@cam.ac.uk>
parents: 64591
diff changeset
   544
lemma divide_eq_minus_1_iff:
799bbbb3a395 Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
paulson <lp15@cam.ac.uk>
parents: 64591
diff changeset
   545
   "(a / b = - 1) \<longleftrightarrow> b \<noteq> 0 \<and> a = - b"
799bbbb3a395 Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
paulson <lp15@cam.ac.uk>
parents: 64591
diff changeset
   546
using divide_eq_1_iff by fastforce
799bbbb3a395 Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
paulson <lp15@cam.ac.uk>
parents: 64591
diff changeset
   547
36719
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   548
lemma times_divide_times_eq:
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   549
  "(x / y) * (z / w) = (x * z) / (y * w)"
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   550
  by simp
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   551
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   552
lemma add_frac_num:
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   553
  "y \<noteq> 0 \<Longrightarrow> x / y + z = (x + z * y) / y"
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   554
  by (simp add: add_divide_distrib)
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   555
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   556
lemma add_num_frac:
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   557
  "y \<noteq> 0 \<Longrightarrow> z + x / y = (x + z * y) / y"
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   558
  by (simp add: add_divide_distrib add.commute)
d396f6f63d94 moved some lemmas from Groebner_Basis here
haftmann
parents: 36425
diff changeset
   559
64591
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   560
lemma dvd_field_iff:
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   561
  "a dvd b \<longleftrightarrow> (a = 0 \<longrightarrow> b = 0)"
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   562
proof (cases "a = 0")
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   563
  case False
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   564
  then have "b = a * (b / a)"
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   565
    by (simp add: field_simps)
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   566
  then have "a dvd b" ..
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   567
  with False show ?thesis
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   568
    by simp
68527
2f4e2aab190a Generalising and renaming some basic results
paulson <lp15@cam.ac.uk>
parents: 67969
diff changeset
   569
qed simp
64591
240a39af9ec4 restructured matter on polynomials and normalized fractions
haftmann
parents: 64329
diff changeset
   570
69502
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   571
lemma inj_divide_right [simp]:
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   572
  "inj (\<lambda>b. b / a) \<longleftrightarrow> a \<noteq> 0"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   573
proof -
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   574
  have "(\<lambda>b. b / a) = (*) (inverse a)"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   575
    by (simp add: field_simps fun_eq_iff)
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   576
  then have "inj (\<lambda>y. y / a) \<longleftrightarrow> inj ((*) (inverse a))"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   577
    by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   578
  also have "\<dots> \<longleftrightarrow> inverse a \<noteq> 0"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   579
    by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   580
  also have "\<dots> \<longleftrightarrow> a \<noteq> 0"
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   581
    by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   582
  finally show ?thesis
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   583
    by simp
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   584
qed
0cf906072e20 more rules
haftmann
parents: 68547
diff changeset
   585
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
   586
end
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   587
62481
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
   588
class field_char_0 = field + ring_char_0
b5d8e57826df tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents: 62347
diff changeset
   589
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   590
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   591
subsection \<open>Ordered fields\<close>
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   592
64290
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   593
class field_abs_sgn = field + idom_abs_sgn
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   594
begin
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   595
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   596
lemma sgn_inverse [simp]:
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   597
  "sgn (inverse a) = inverse (sgn a)"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   598
proof (cases "a = 0")
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   599
  case True then show ?thesis by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   600
next
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   601
  case False
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   602
  then have "a * inverse a = 1"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   603
    by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   604
  then have "sgn (a * inverse a) = sgn 1"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   605
    by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   606
  then have "sgn a * sgn (inverse a) = 1"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   607
    by (simp add: sgn_mult)
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   608
  then have "inverse (sgn a) * (sgn a * sgn (inverse a)) = inverse (sgn a) * 1"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   609
    by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   610
  then have "(inverse (sgn a) * sgn a) * sgn (inverse a) = inverse (sgn a)"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   611
    by (simp add: ac_simps)
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   612
  with False show ?thesis
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   613
    by (simp add: sgn_eq_0_iff)
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   614
qed
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   615
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   616
lemma abs_inverse [simp]:
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   617
  "\<bar>inverse a\<bar> = inverse \<bar>a\<bar>"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   618
proof -
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   619
  from sgn_mult_abs [of "inverse a"] sgn_mult_abs [of a]
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   620
  have "inverse (sgn a) * \<bar>inverse a\<bar> = inverse (sgn a * \<bar>a\<bar>)"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   621
    by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   622
  then show ?thesis by (auto simp add: sgn_eq_0_iff)
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   623
qed
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   624
    
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   625
lemma sgn_divide [simp]:
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   626
  "sgn (a / b) = sgn a / sgn b"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   627
  unfolding divide_inverse sgn_mult by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   628
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   629
lemma abs_divide [simp]:
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   630
  "\<bar>a / b\<bar> = \<bar>a\<bar> / \<bar>b\<bar>"
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   631
  unfolding divide_inverse abs_mult by simp
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   632
  
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   633
end
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
   634
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   635
class linordered_field = field + linordered_idom
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   636
begin
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   637
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   638
lemma positive_imp_inverse_positive:
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   639
  assumes a_gt_0: "0 < a"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   640
  shows "0 < inverse a"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   641
proof -
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   642
  have "0 < a * inverse a"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   643
    by (simp add: a_gt_0 [THEN less_imp_not_eq2])
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   644
  thus "0 < inverse a"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   645
    by (simp add: a_gt_0 [THEN less_not_sym] zero_less_mult_iff)
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   646
qed
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   647
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
   648
lemma negative_imp_inverse_negative:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   649
  "a < 0 \<Longrightarrow> inverse a < 0"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 73411
diff changeset
   650
  using positive_imp_inverse_positive [of "-a"]
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 73411
diff changeset
   651
  by (simp add: nonzero_inverse_minus_eq less_imp_not_eq)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   652
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   653
lemma inverse_le_imp_le:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   654
  assumes invle: "inverse a \<le> inverse b" and apos: "0 < a"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   655
  shows "b \<le> a"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   656
proof (rule classical)
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
   657
  assume "\<not> b \<le> a"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   658
  hence "a < b"  by (simp add: linorder_not_le)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   659
  hence bpos: "0 < b"  by (blast intro: apos less_trans)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   660
  hence "a * inverse a \<le> a * inverse b"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   661
    by (simp add: apos invle less_imp_le mult_left_mono)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   662
  hence "(a * inverse a) * b \<le> (a * inverse b) * b"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   663
    by (simp add: bpos less_imp_le mult_right_mono)
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56571
diff changeset
   664
  thus "b \<le> a"  by (simp add: mult.assoc apos bpos less_imp_not_eq2)
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   665
qed
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14267
diff changeset
   666
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
   667
lemma inverse_positive_imp_positive:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   668
  assumes inv_gt_0: "0 < inverse a" and nz: "a \<noteq> 0"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   669
  shows "0 < a"
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   670
proof -
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
   671
  have "0 < inverse (inverse a)"
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   672
    using inv_gt_0 by (rule positive_imp_inverse_positive)
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
   673
  thus "0 < a"
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   674
    using nz by (simp add: nonzero_inverse_inverse_eq)
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
   675
qed
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
   676
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   677
lemma inverse_negative_imp_negative:
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   678
  assumes inv_less_0: "inverse a < 0" and nz: "a \<noteq> 0"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   679
  shows "a < 0"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   680
proof -
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   681
  have "inverse (inverse a) < 0"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   682
    using inv_less_0 by (rule negative_imp_inverse_negative)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   683
  thus "a < 0" using nz by (simp add: nonzero_inverse_inverse_eq)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   684
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   685
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   686
lemma linordered_field_no_lb:
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   687
  "\<forall>x. \<exists>y. y < x"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   688
proof
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   689
  fix x::'a
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   690
  have m1: "- (1::'a) < 0" by simp
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   691
  from add_strict_right_mono[OF m1, where c=x]
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   692
  have "(- 1) + x < x" by simp
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   693
  thus "\<exists>y. y < x" by blast
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   694
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   695
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   696
lemma linordered_field_no_ub:
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   697
  "\<forall> x. \<exists>y. y > x"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   698
proof
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   699
  fix x::'a
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   700
  have m1: " (1::'a) > 0" by simp
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   701
  from add_strict_right_mono[OF m1, where c=x]
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   702
  have "1 + x > x" by simp
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   703
  thus "\<exists>y. y > x" by blast
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   704
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   705
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   706
lemma less_imp_inverse_less:
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   707
  assumes less: "a < b" and apos:  "0 < a"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   708
  shows "inverse b < inverse a"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   709
proof (rule ccontr)
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
   710
  assume "\<not> inverse b < inverse a"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   711
  hence "inverse a \<le> inverse b" by simp
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
   712
  hence "\<not> (a < b)"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   713
    by (simp add: not_less inverse_le_imp_le [OF _ apos])
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   714
  thus False by (rule notE [OF _ less])
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   715
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   716
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   717
lemma inverse_less_imp_less:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   718
  assumes "inverse a < inverse b" "0 < a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   719
  shows "b < a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   720
proof -
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   721
  have "a \<noteq> b"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   722
    using assms by (simp add: less_le)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   723
  moreover have "b \<le> a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   724
    using assms by (force simp: less_le dest: inverse_le_imp_le)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   725
  ultimately show ?thesis
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   726
    by (simp add: less_le)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   727
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   728
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   729
text\<open>Both premises are essential. Consider -1 and 1.\<close>
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   730
lemma inverse_less_iff_less [simp]:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   731
  "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> inverse a < inverse b \<longleftrightarrow> b < a"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   732
  by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   733
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   734
lemma le_imp_inverse_le:
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   735
  "a \<le> b \<Longrightarrow> 0 < a \<Longrightarrow> inverse b \<le> inverse a"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   736
  by (force simp add: le_less less_imp_inverse_less)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   737
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   738
lemma inverse_le_iff_le [simp]:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   739
  "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> inverse a \<le> inverse b \<longleftrightarrow> b \<le> a"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   740
  by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   741
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   742
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   743
text\<open>These results refer to both operands being negative.  The opposite-sign
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   744
case is trivial, since inverse preserves signs.\<close>
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   745
lemma inverse_le_imp_le_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   746
  assumes "inverse a \<le> inverse b" "b < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   747
  shows "b \<le> a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   748
proof (rule classical)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   749
  assume "\<not> b \<le> a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   750
  with \<open>b < 0\<close> have "a < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   751
    by force
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   752
  with assms show "b \<le> a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   753
    using inverse_le_imp_le [of "-b" "-a"] by (simp add: nonzero_inverse_minus_eq)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   754
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   755
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   756
lemma less_imp_inverse_less_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   757
  assumes "a < b" "b < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   758
  shows "inverse b < inverse a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   759
proof -
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   760
  have "a < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   761
    using assms by (blast intro: less_trans)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   762
  with less_imp_inverse_less [of "-b" "-a"] show ?thesis
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   763
    by (simp add: nonzero_inverse_minus_eq assms)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   764
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   765
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   766
lemma inverse_less_imp_less_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   767
  assumes "inverse a < inverse b" "b < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   768
  shows "b < a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   769
proof (rule classical)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   770
  assume "\<not> b < a"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   771
  with \<open>b < 0\<close> have "a < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   772
    by force
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   773
  with inverse_less_imp_less [of "-b" "-a"] show ?thesis
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   774
    by (simp add: nonzero_inverse_minus_eq assms)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   775
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   776
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   777
lemma inverse_less_iff_less_neg [simp]:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   778
  "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> inverse a < inverse b \<longleftrightarrow> b < a"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   779
  using inverse_less_iff_less [of "-b" "-a"]
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   780
  by (simp del: inverse_less_iff_less add: nonzero_inverse_minus_eq)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   781
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   782
lemma le_imp_inverse_le_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   783
  "a \<le> b \<Longrightarrow> b < 0 \<Longrightarrow> inverse b \<le> inverse a"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   784
  by (force simp add: le_less less_imp_inverse_less_neg)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   785
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
   786
lemma inverse_le_iff_le_neg [simp]:
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   787
  "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> inverse a \<le> inverse b \<longleftrightarrow> b \<le> a"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   788
  by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   789
36774
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   790
lemma one_less_inverse:
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   791
  "0 < a \<Longrightarrow> a < 1 \<Longrightarrow> 1 < inverse a"
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   792
  using less_imp_inverse_less [of a 1, unfolded inverse_1] .
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   793
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   794
lemma one_le_inverse:
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   795
  "0 < a \<Longrightarrow> a \<le> 1 \<Longrightarrow> 1 \<le> inverse a"
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   796
  using le_imp_inverse_le [of a 1, unfolded inverse_1] .
9e444b09fbef add lemmas one_less_inverse and one_le_inverse
huffman
parents: 36719
diff changeset
   797
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   798
lemma pos_le_divide_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   799
  assumes "0 < c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   800
  shows "a \<le> b / c \<longleftrightarrow> a * c \<le> b"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   801
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   802
  from assms have "a \<le> b / c \<longleftrightarrow> a * c \<le> (b / c) * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   803
    using mult_le_cancel_right [of a c "b * inverse c"] by (auto simp add: field_simps)
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   804
  also have "... \<longleftrightarrow> a * c \<le> b"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   805
    by (simp add: less_imp_not_eq2 [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   806
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   807
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   808
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   809
lemma pos_less_divide_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   810
  assumes "0 < c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   811
  shows "a < b / c \<longleftrightarrow> a * c < b"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   812
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   813
  from assms have "a < b / c \<longleftrightarrow> a * c < (b / c) * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   814
    using mult_less_cancel_right [of a c "b / c"] by auto
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   815
  also have "... = (a*c < b)"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   816
    by (simp add: less_imp_not_eq2 [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   817
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   818
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   819
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   820
lemma neg_less_divide_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   821
  assumes "c < 0"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   822
  shows "a < b / c \<longleftrightarrow> b < a * c"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   823
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   824
  from assms have "a < b / c \<longleftrightarrow> (b / c) * c < a * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   825
    using mult_less_cancel_right [of "b / c" c a] by auto
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   826
  also have "... \<longleftrightarrow> b < a * c"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   827
    by (simp add: less_imp_not_eq [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   828
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   829
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   830
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   831
lemma neg_le_divide_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   832
  assumes "c < 0"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   833
  shows "a \<le> b / c \<longleftrightarrow> b \<le> a * c"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   834
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   835
  from assms have "a \<le> b / c \<longleftrightarrow> (b / c) * c \<le> a * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   836
    using mult_le_cancel_right [of "b * inverse c" c a] by (auto simp add: field_simps)
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   837
  also have "... \<longleftrightarrow> b \<le> a * c"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   838
    by (simp add: less_imp_not_eq [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   839
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   840
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   841
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   842
lemma pos_divide_le_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   843
  assumes "0 < c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   844
  shows "b / c \<le> a \<longleftrightarrow> b \<le> a * c"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   845
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   846
  from assms have "b / c \<le> a \<longleftrightarrow> (b / c) * c \<le> a * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   847
    using mult_le_cancel_right [of "b / c" c a] by auto
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   848
  also have "... \<longleftrightarrow> b \<le> a * c"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   849
    by (simp add: less_imp_not_eq2 [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   850
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   851
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   852
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   853
lemma pos_divide_less_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   854
  assumes "0 < c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   855
  shows "b / c < a \<longleftrightarrow> b < a * c"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   856
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   857
  from assms have "b / c < a \<longleftrightarrow> (b / c) * c < a * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   858
    using mult_less_cancel_right [of "b / c" c a] by auto
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   859
  also have "... \<longleftrightarrow> b < a * c"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   860
    by (simp add: less_imp_not_eq2 [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   861
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   862
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   863
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   864
lemma neg_divide_le_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   865
  assumes "c < 0"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   866
  shows "b / c \<le> a \<longleftrightarrow> a * c \<le> b"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   867
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   868
  from assms have "b / c \<le> a \<longleftrightarrow> a * c \<le> (b / c) * c"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   869
    using mult_le_cancel_right [of a c "b / c"] by auto
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   870
  also have "... \<longleftrightarrow> a * c \<le> b"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   871
    by (simp add: less_imp_not_eq [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   872
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   873
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   874
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   875
lemma neg_divide_less_eq [field_simps]:
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   876
  assumes "c < 0"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   877
  shows "b / c < a \<longleftrightarrow> a * c < b"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   878
proof -
59546
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   879
  from assms have "b / c < a \<longleftrightarrow> a * c < b / c * c"
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   880
    using mult_less_cancel_right [of a c "b / c"] by auto
3850a2d20f19 times_divide_eq rules are already [simp] despite of comment
haftmann
parents: 59535
diff changeset
   881
  also have "... \<longleftrightarrow> a * c < b"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
   882
    by (simp add: less_imp_not_eq [OF assms] divide_inverse mult.assoc)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   883
  finally show ?thesis .
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   884
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   885
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61238
diff changeset
   886
text\<open>The following \<open>field_simps\<close> rules are necessary, as minus is always moved atop of
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   887
division but we want to get rid of division.\<close>
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   888
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   889
lemma pos_le_minus_divide_eq [field_simps]: "0 < c \<Longrightarrow> a \<le> - (b / c) \<longleftrightarrow> a * c \<le> - b"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   890
  unfolding minus_divide_left by (rule pos_le_divide_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   891
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   892
lemma neg_le_minus_divide_eq [field_simps]: "c < 0 \<Longrightarrow> a \<le> - (b / c) \<longleftrightarrow> - b \<le> a * c"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   893
  unfolding minus_divide_left by (rule neg_le_divide_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   894
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   895
lemma pos_less_minus_divide_eq [field_simps]: "0 < c \<Longrightarrow> a < - (b / c) \<longleftrightarrow> a * c < - b"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   896
  unfolding minus_divide_left by (rule pos_less_divide_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   897
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   898
lemma neg_less_minus_divide_eq [field_simps]: "c < 0 \<Longrightarrow> a < - (b / c) \<longleftrightarrow> - b < a * c"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   899
  unfolding minus_divide_left by (rule neg_less_divide_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   900
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   901
lemma pos_minus_divide_less_eq [field_simps]: "0 < c \<Longrightarrow> - (b / c) < a \<longleftrightarrow> - b < a * c"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   902
  unfolding minus_divide_left by (rule pos_divide_less_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   903
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   904
lemma neg_minus_divide_less_eq [field_simps]: "c < 0 \<Longrightarrow> - (b / c) < a \<longleftrightarrow> a * c < - b"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   905
  unfolding minus_divide_left by (rule neg_divide_less_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   906
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   907
lemma pos_minus_divide_le_eq [field_simps]: "0 < c \<Longrightarrow> - (b / c) \<le> a \<longleftrightarrow> - b \<le> a * c"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   908
  unfolding minus_divide_left by (rule pos_divide_le_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   909
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   910
lemma neg_minus_divide_le_eq [field_simps]: "c < 0 \<Longrightarrow> - (b / c) \<le> a \<longleftrightarrow> a * c \<le> - b"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   911
  unfolding minus_divide_left by (rule neg_divide_le_eq)
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
   912
56365
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   913
lemma frac_less_eq:
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   914
  "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y < w / z \<longleftrightarrow> (x * z - w * y) / (y * z) < 0"
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   915
  by (subst less_iff_diff_less_0) (simp add: diff_frac_eq )
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   916
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   917
lemma frac_le_eq:
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   918
  "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y \<le> w / z \<longleftrightarrow> (x * z - w * y) / (y * z) \<le> 0"
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   919
  by (subst le_iff_diff_le_0) (simp add: diff_frac_eq )
713f9b9a7e51 New theorems for extracting quotients
paulson <lp15@cam.ac.uk>
parents: 55718
diff changeset
   920
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56481
diff changeset
   921
lemma divide_pos_pos[simp]:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   922
  "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> 0 < x / y"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   923
by(simp add:field_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   924
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   925
lemma divide_nonneg_pos:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   926
  "0 \<le> x \<Longrightarrow> 0 < y \<Longrightarrow> 0 \<le> x / y"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   927
by(simp add:field_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   928
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   929
lemma divide_neg_pos:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   930
  "x < 0 \<Longrightarrow> 0 < y \<Longrightarrow> x / y < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   931
  by(simp add:field_simps)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   932
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   933
lemma divide_nonpos_pos:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   934
  "x \<le> 0 \<Longrightarrow> 0 < y \<Longrightarrow> x / y \<le> 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   935
  by(simp add:field_simps)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   936
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   937
lemma divide_pos_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   938
  "0 < x \<Longrightarrow> y < 0 \<Longrightarrow> x / y < 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   939
  by(simp add:field_simps)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   940
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   941
lemma divide_nonneg_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   942
  "0 \<le> x \<Longrightarrow> y < 0 \<Longrightarrow> x / y \<le> 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   943
  by(simp add:field_simps)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   944
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   945
lemma divide_neg_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   946
  "x < 0 \<Longrightarrow> y < 0 \<Longrightarrow> 0 < x / y"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   947
  by(simp add:field_simps)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   948
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   949
lemma divide_nonpos_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   950
  "x \<le> 0 \<Longrightarrow> y < 0 \<Longrightarrow> 0 \<le> x / y"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   951
  by(simp add:field_simps)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   952
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   953
lemma divide_strict_right_mono:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   954
  "\<lbrakk>a < b; 0 < c\<rbrakk> \<Longrightarrow> a / c < b / c"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   955
  by (simp add: less_imp_not_eq2 divide_inverse mult_strict_right_mono
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   956
      positive_imp_inverse_positive)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   957
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   958
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   959
lemma divide_strict_right_mono_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   960
  assumes "b < a" "c < 0" shows "a / c < b / c"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   961
proof -
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   962
  have "b / - c < a / - c"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   963
    by (rule divide_strict_right_mono) (use assms in auto)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   964
  then show ?thesis
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   965
    by (simp add: less_imp_not_eq)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   966
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   967
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69502
diff changeset
   968
text\<open>The last premise ensures that \<^term>\<open>a\<close> and \<^term>\<open>b\<close>
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
   969
      have the same sign\<close>
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   970
lemma divide_strict_left_mono:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   971
  "\<lbrakk>b < a; 0 < c; 0 < a*b\<rbrakk> \<Longrightarrow> c / a < c / b"
44921
58eef4843641 tuned proofs
huffman
parents: 44680
diff changeset
   972
  by (auto simp: field_simps zero_less_mult_iff mult_strict_right_mono)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   973
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   974
lemma divide_left_mono:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   975
  "\<lbrakk>b \<le> a; 0 \<le> c; 0 < a*b\<rbrakk> \<Longrightarrow> c / a \<le> c / b"
44921
58eef4843641 tuned proofs
huffman
parents: 44680
diff changeset
   976
  by (auto simp: field_simps zero_less_mult_iff mult_right_mono)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   977
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   978
lemma divide_strict_left_mono_neg:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   979
  "\<lbrakk>a < b; c < 0; 0 < a*b\<rbrakk> \<Longrightarrow> c / a < c / b"
44921
58eef4843641 tuned proofs
huffman
parents: 44680
diff changeset
   980
  by (auto simp: field_simps zero_less_mult_iff mult_strict_right_mono_neg)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   981
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   982
lemma mult_imp_div_pos_le: "0 < y \<Longrightarrow> x \<le> z * y \<Longrightarrow> x / y \<le> z"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   983
by (subst pos_divide_le_eq, assumption+)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   984
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   985
lemma mult_imp_le_div_pos: "0 < y \<Longrightarrow> z * y \<le> x \<Longrightarrow> z \<le> x / y"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   986
by(simp add:field_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   987
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   988
lemma mult_imp_div_pos_less: "0 < y \<Longrightarrow> x < z * y \<Longrightarrow> x / y < z"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   989
by(simp add:field_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   990
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   991
lemma mult_imp_less_div_pos: "0 < y \<Longrightarrow> z * y < x \<Longrightarrow> z < x / y"
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   992
by(simp add:field_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
   993
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   994
lemma frac_le:
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   995
  assumes "0 \<le> y" "x \<le> y" "0 < w" "w \<le> z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   996
  shows "x / z \<le> y / w"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   997
proof (rule mult_imp_div_pos_le)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   998
  show "z > 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
   999
    using assms by simp
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1000
  have "x \<le> y * z / w"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1001
  proof (rule mult_imp_le_div_pos [OF \<open>0 < w\<close>])
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1002
    show "x * w \<le> y * z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1003
      using assms by (auto intro: mult_mono)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1004
  qed
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1005
  also have "... = y / w * z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1006
    by simp
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1007
  finally show "x \<le> y / w * z" .
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1008
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1009
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1010
lemma frac_less:
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1011
  assumes "0 \<le> x" "x < y" "0 < w" "w \<le> z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1012
  shows "x / z < y / w"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1013
proof (rule mult_imp_div_pos_less)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1014
  show "z > 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1015
    using assms by simp
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1016
  have "x < y * z / w"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1017
  proof (rule mult_imp_less_div_pos [OF \<open>0 < w\<close>])
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1018
    show "x * w < y * z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1019
      using assms by (auto intro: mult_less_le_imp_less)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1020
  qed
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1021
  also have "... = y / w * z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1022
    by simp
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1023
  finally show "x < y / w * z" .
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1024
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1025
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1026
lemma frac_less2:
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1027
  assumes "0 < x" "x \<le> y" "0 < w" "w < z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1028
  shows "x / z < y / w"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1029
proof (rule mult_imp_div_pos_less)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1030
  show "z > 0"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1031
    using assms by simp
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1032
  show "x < y / w * z"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1033
    using assms by (force intro: mult_imp_less_div_pos mult_le_less_imp_less)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1034
qed
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1035
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1036
lemma less_half_sum: "a < b \<Longrightarrow> a < (a+b) / (1+1)"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1037
  by (simp add: field_simps zero_less_two)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1038
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1039
lemma gt_half_sum: "a < b \<Longrightarrow> (a+b)/(1+1) < b"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1040
  by (simp add: field_simps zero_less_two)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1041
53215
5e47c31c6f7c renamed typeclass dense_linorder to unbounded_dense_linorder
hoelzl
parents: 52435
diff changeset
  1042
subclass unbounded_dense_linorder
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1043
proof
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1044
  fix x y :: 'a
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
  1045
  from less_add_one show "\<exists>y. x < y" ..
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1046
  from less_add_one have "x + (- 1) < (x + 1) + (- 1)" by (rule add_strict_right_mono)
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 54147
diff changeset
  1047
  then have "x - 1 < x + 1 - 1" by simp
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1048
  then have "x - 1 < x" by (simp add: algebra_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1049
  then show "\<exists>y. y < x" ..
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1050
  show "x < y \<Longrightarrow> \<exists>z>x. z < y" by (blast intro!: less_half_sum gt_half_sum)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1051
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1052
64290
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
  1053
subclass field_abs_sgn ..
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
  1054
64329
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1055
lemma inverse_sgn [simp]:
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1056
  "inverse (sgn a) = sgn a"
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1057
  by (cases a 0 rule: linorder_cases) simp_all
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1058
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1059
lemma divide_sgn [simp]:
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1060
  "a / sgn b = a * sgn b"
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1061
  by (cases b 0 rule: linorder_cases) simp_all
8f9d27c89241 more on sgn in linear ordered fields
haftmann
parents: 64290
diff changeset
  1062
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1063
lemma nonzero_abs_inverse:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1064
  "a \<noteq> 0 \<Longrightarrow> \<bar>inverse a\<bar> = inverse \<bar>a\<bar>"
64290
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
  1065
  by (rule abs_inverse)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1066
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1067
lemma nonzero_abs_divide:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1068
  "b \<noteq> 0 \<Longrightarrow> \<bar>a / b\<bar> = \<bar>a\<bar> / \<bar>b\<bar>"
64290
fb5c74a58796 suitable logical type class for abs, sgn
haftmann
parents: 63952
diff changeset
  1069
  by (rule abs_divide)
36301
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1070
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1071
lemma field_le_epsilon:
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1072
  assumes e: "\<And>e. 0 < e \<Longrightarrow> x \<le> y + e"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1073
  shows "x \<le> y"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1074
proof (rule dense_le)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1075
  fix t assume "t < x"
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1076
  hence "0 < x - t" by (simp add: less_diff_eq)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1077
  from e [OF this] have "x + 0 \<le> x + (y - t)" by (simp add: algebra_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1078
  then have "0 \<le> y - t" by (simp only: add_le_cancel_left)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1079
  then show "t \<le> y" by (simp add: algebra_simps)
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1080
qed
72f4d079ebf8 more localization; factored out lemmas for division_ring
haftmann
parents: 35828
diff changeset
  1081
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1082
lemma inverse_positive_iff_positive [simp]: "(0 < inverse a) = (0 < a)"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1083
proof (cases "a = 0")
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1084
  case False
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1085
  then show ?thesis
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1086
    by (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1087
qed auto
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
  1088
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1089
lemma inverse_negative_iff_negative [simp]: "(inverse a < 0) = (a < 0)"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1090
proof (cases "a = 0")
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1091
  case False
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1092
  then show ?thesis
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1093
    by (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative)
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1094
qed auto
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
  1095
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1096
lemma inverse_nonnegative_iff_nonnegative [simp]: "0 \<le> inverse a \<longleftrightarrow> 0 \<le> a"
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1097
  by (simp add: not_less [symmetric])
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
  1098
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1099
lemma inverse_nonpositive_iff_nonpositive [simp]: "inverse a \<le> 0 \<longleftrightarrow> a \<le> 0"
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1100
  by (simp add: not_less [symmetric])
14277
ad66687ece6e more field division lemmas transferred from Real to Ring_and_Field
paulson
parents: 14272
diff changeset
  1101
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1102
lemma one_less_inverse_iff: "1 < inverse x \<longleftrightarrow> 0 < x \<and> x < 1"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1103
  using less_trans[of 1 x 0 for x]
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1104
  by (cases x 0 rule: linorder_cases) (auto simp add: field_simps)
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14353
diff changeset
  1105
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1106
lemma one_le_inverse_iff: "1 \<le> inverse x \<longleftrightarrow> 0 < x \<and> x \<le> 1"
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1107
proof (cases "x = 1")
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1108
  case True then show ?thesis by simp
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1109
next
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1110
  case False then have "inverse x \<noteq> 1" by simp
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1111
  then have "1 \<noteq> inverse x" by blast
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1112
  then have "1 \<le> inverse x \<longleftrightarrow> 1 < inverse x" by (simp add: le_less)
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1113
  with False show ?thesis by (auto simp add: one_less_inverse_iff)
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1114
qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14353
diff changeset
  1115
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1116
lemma inverse_less_1_iff: "inverse x < 1 \<longleftrightarrow> x \<le> 0 \<or> 1 < x"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
  1117
  by (simp add: not_le [symmetric] one_le_inverse_iff)
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14353
diff changeset
  1118
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1119
lemma inverse_le_1_iff: "inverse x \<le> 1 \<longleftrightarrow> x \<le> 0 \<or> 1 \<le> x"
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
  1120
  by (simp add: not_less [symmetric] one_less_inverse_iff)
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14353
diff changeset
  1121
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
  1122
lemma [field_split_simps, divide_simps]:
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1123
  shows le_divide_eq: "a \<le> b / c \<longleftrightarrow> (if 0 < c then a * c \<le> b else if c < 0 then b \<le> a * c else a \<le> 0)"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1124
    and divide_le_eq: "b / c \<le> a \<longleftrightarrow> (if 0 < c then b \<le> a * c else if c < 0 then a * c \<le> b else 0 \<le> a)"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1125
    and less_divide_eq: "a < b / c \<longleftrightarrow> (if 0 < c then a * c < b else if c < 0 then b < a * c else a < 0)"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1126
    and divide_less_eq: "b / c < a \<longleftrightarrow> (if 0 < c then b < a * c else if c < 0 then a * c < b else 0 < a)"
56481
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
  1127
    and le_minus_divide_eq: "a \<le> - (b / c) \<longleftrightarrow> (if 0 < c then a * c \<le> - b else if c < 0 then - b \<le> a * c else a \<le> 0)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
  1128
    and minus_divide_le_eq: "- (b / c) \<le> a \<longleftrightarrow> (if 0 < c then - b \<le> a * c else if c < 0 then a * c \<le> - b else 0 \<le> a)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
  1129
    and less_minus_divide_eq: "a < - (b / c) \<longleftrightarrow> (if 0 < c then a * c < - b else if c < 0 then - b < a * c else  a < 0)"
47500d0881f9 add divide_simps
hoelzl
parents: 56480
diff changeset
  1130
    and minus_divide_less_eq: "- (b / c) < a \<longleftrightarrow> (if 0 < c then - b < a * c else if c < 0 then a * c < - b else 0 < a)"
73411
1f1366966296 avoid name clash
haftmann
parents: 71695
diff changeset
  1131
  by (auto simp: field_simps not_less dest: order.antisym)
14288
d149e3cbdb39 Moving some theorems from Real/RealArith0.ML
paulson
parents: 14284
diff changeset
  1132
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1133
text \<open>Division and Signs\<close>
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1134
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1135
lemma
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1136
  shows zero_less_divide_iff: "0 < a / b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1137
    and divide_less_0_iff: "a / b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1138
    and zero_le_divide_iff: "0 \<le> a / b \<longleftrightarrow> 0 \<le> a \<and> 0 \<le> b \<or> a \<le> 0 \<and> b \<le> 0"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1139
    and divide_le_0_iff: "a / b \<le> 0 \<longleftrightarrow> 0 \<le> a \<and> b \<le> 0 \<or> a \<le> 0 \<and> 0 \<le> b"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
  1140
  by (auto simp add: field_split_simps)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1141
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1142
text \<open>Division and the Number One\<close>
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
  1143
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1144
text\<open>Simplify expressions equated with 1\<close>
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
  1145
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1146
lemma zero_eq_1_divide_iff [simp]: "0 = 1 / a \<longleftrightarrow> a = 0"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1147
  by (cases "a = 0") (auto simp: field_simps)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
  1148
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1149
lemma one_divide_eq_0_iff [simp]: "1 / a = 0 \<longleftrightarrow> a = 0"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1150
  using zero_eq_1_divide_iff[of a] by simp
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
  1151
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61238
diff changeset
  1152
text\<open>Simplify expressions such as \<open>0 < 1/x\<close> to \<open>0 < x\<close>\<close>
36423
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1153
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1154
lemma zero_le_divide_1_iff [simp]:
36423
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1155
  "0 \<le> 1 / a \<longleftrightarrow> 0 \<le> a"
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1156
  by (simp add: zero_le_divide_iff)
17085
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1157
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1158
lemma zero_less_divide_1_iff [simp]:
36423
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1159
  "0 < 1 / a \<longleftrightarrow> 0 < a"
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1160
  by (simp add: zero_less_divide_iff)
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1161
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1162
lemma divide_le_0_1_iff [simp]:
36423
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1163
  "1 / a \<le> 0 \<longleftrightarrow> a \<le> 0"
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1164
  by (simp add: divide_le_0_iff)
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1165
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1166
lemma divide_less_0_1_iff [simp]:
36423
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1167
  "1 / a < 0 \<longleftrightarrow> a < 0"
63fc238a7430 got rid of [simplified]
haftmann
parents: 36414
diff changeset
  1168
  by (simp add: divide_less_0_iff)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
  1169
14293
22542982bffd moving some division theorems to Ring_and_Field
paulson
parents: 14288
diff changeset
  1170
lemma divide_right_mono:
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1171
  "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> a/c \<le> b/c"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1172
  by (force simp add: divide_strict_right_mono le_less)
14293
22542982bffd moving some division theorems to Ring_and_Field
paulson
parents: 14288
diff changeset
  1173
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1174
lemma divide_right_mono_neg: "a \<le> b \<Longrightarrow> c \<le> 0 \<Longrightarrow> b / c \<le> a / c"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1175
  by (auto dest: divide_right_mono [of _ _ "- c"])
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1176
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1177
lemma divide_left_mono_neg: "a \<le> b \<Longrightarrow> c \<le> 0 \<Longrightarrow> 0 < a * b \<Longrightarrow> c / a \<le> c / b"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1178
  by (auto simp add: mult.commute dest: divide_left_mono [of _ _ "- c"])
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1179
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1180
lemma inverse_le_iff: "inverse a \<le> inverse b \<longleftrightarrow> (0 < a * b \<longrightarrow> b \<le> a) \<and> (a * b \<le> 0 \<longrightarrow> a \<le> b)"
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1181
  by (cases a 0 b 0 rule: linorder_cases[case_product linorder_cases])
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1182
     (auto simp add: field_simps zero_less_mult_iff mult_le_0_iff)
42904
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1183
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1184
lemma inverse_less_iff: "inverse a < inverse b \<longleftrightarrow> (0 < a * b \<longrightarrow> b < a) \<and> (a * b \<le> 0 \<longrightarrow> a < b)"
42904
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1185
  by (subst less_le) (auto simp: inverse_le_iff)
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1186
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1187
lemma divide_le_cancel: "a / c \<le> b / c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
42904
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1188
  by (simp add: divide_inverse mult_le_cancel_right)
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1189
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  1190
lemma divide_less_cancel: "a / c < b / c \<longleftrightarrow> (0 < c \<longrightarrow> a < b) \<and> (c < 0 \<longrightarrow> b < a) \<and> c \<noteq> 0"
42904
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1191
  by (auto simp add: divide_inverse mult_less_cancel_right)
4aedcff42de6 add divide_.._cancel, inverse_.._iff
hoelzl
parents: 36774
diff changeset
  1192
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1193
text\<open>Simplify quotients that are compared with the value 1.\<close>
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1194
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1195
lemma le_divide_eq_1:
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1196
  "(1 \<le> b / a) = ((0 < a \<and> a \<le> b) \<or> (a < 0 \<and> b \<le> a))"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1197
  by (auto simp add: le_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1198
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1199
lemma divide_le_eq_1:
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1200
  "(b / a \<le> 1) = ((0 < a \<and> b \<le> a) \<or> (a < 0 \<and> a \<le> b) \<or> a=0)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1201
  by (auto simp add: divide_le_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1202
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1203
lemma less_divide_eq_1:
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1204
  "(1 < b / a) = ((0 < a \<and> a < b) \<or> (a < 0 \<and> b < a))"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1205
  by (auto simp add: less_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1206
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1207
lemma divide_less_eq_1:
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1208
  "(b / a < 1) = ((0 < a \<and> b < a) \<or> (a < 0 \<and> a < b) \<or> a=0)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1209
  by (auto simp add: divide_less_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1210
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1211
lemma divide_nonneg_nonneg [simp]:
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1212
  "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x / y"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
  1213
  by (auto simp add: field_split_simps)
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1214
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1215
lemma divide_nonpos_nonpos:
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1216
  "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> 0 \<le> x / y"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
  1217
  by (auto simp add: field_split_simps)
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1218
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1219
lemma divide_nonneg_nonpos:
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1220
  "0 \<le> x \<Longrightarrow> y \<le> 0 \<Longrightarrow> x / y \<le> 0"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
  1221
  by (auto simp add: field_split_simps)
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1222
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1223
lemma divide_nonpos_nonneg:
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56541
diff changeset
  1224
  "x \<le> 0 \<Longrightarrow> 0 \<le> y \<Longrightarrow> x / y \<le> 0"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70357
diff changeset
  1225
  by (auto simp add: field_split_simps)
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23326
diff changeset
  1226
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1227
text \<open>Conditional Simplification Rules: No Case Splits\<close>
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1228
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1229
lemma le_divide_eq_1_pos [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1230
  "0 < a \<Longrightarrow> (1 \<le> b/a) = (a \<le> b)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1231
  by (auto simp add: le_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1232
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1233
lemma le_divide_eq_1_neg [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1234
  "a < 0 \<Longrightarrow> (1 \<le> b/a) = (b \<le> a)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1235
  by (auto simp add: le_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1236
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1237
lemma divide_le_eq_1_pos [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1238
  "0 < a \<Longrightarrow> (b/a \<le> 1) = (b \<le> a)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1239
  by (auto simp add: divide_le_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1240
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1241
lemma divide_le_eq_1_neg [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1242
  "a < 0 \<Longrightarrow> (b/a \<le> 1) = (a \<le> b)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1243
  by (auto simp add: divide_le_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1244
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1245
lemma less_divide_eq_1_pos [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1246
  "0 < a \<Longrightarrow> (1 < b/a) = (a < b)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1247
  by (auto simp add: less_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1248
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1249
lemma less_divide_eq_1_neg [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1250
  "a < 0 \<Longrightarrow> (1 < b/a) = (b < a)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1251
  by (auto simp add: less_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1252
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1253
lemma divide_less_eq_1_pos [simp]:
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1254
  "0 < a \<Longrightarrow> (b/a < 1) = (b < a)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1255
  by (auto simp add: divide_less_eq)
18649
bb99c2e705ca tidied, and added missing thm divide_less_eq_1_neg
paulson
parents: 18623
diff changeset
  1256
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1257
lemma divide_less_eq_1_neg [simp]:
61941
31f2105521ee discontinued ASCII replacement syntax <->;
wenzelm
parents: 61799
diff changeset
  1258
  "a < 0 \<Longrightarrow> b/a < 1 \<longleftrightarrow> a < b"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1259
  by (auto simp add: divide_less_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1260
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1261
lemma eq_divide_eq_1 [simp]:
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1262
  "(1 = b/a) = ((a \<noteq> 0 \<and> a = b))"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1263
  by (auto simp add: eq_divide_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1264
54147
97a8ff4e4ac9 killed most "no_atp", to make Sledgehammer more complete
blanchet
parents: 53374
diff changeset
  1265
lemma divide_eq_eq_1 [simp]:
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1266
  "(b/a = 1) = ((a \<noteq> 0 \<and> a = b))"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1267
  by (auto simp add: divide_eq_eq)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1268
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1269
lemma abs_div_pos: "0 < y \<Longrightarrow> \<bar>x\<bar> / y = \<bar>x / y\<bar>"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1270
  by (simp add: order_less_imp_le)
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16568
diff changeset
  1271
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1272
lemma zero_le_divide_abs_iff [simp]: "(0 \<le> a / \<bar>b\<bar>) = (0 \<le> a \<or> b = 0)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1273
  by (auto simp: zero_le_divide_iff)
55718
34618f031ba9 A few lemmas about summations, etc.
paulson <lp15@cam.ac.uk>
parents: 54230
diff changeset
  1274
67091
1393c2340eec more symbols;
wenzelm
parents: 65057
diff changeset
  1275
lemma divide_le_0_abs_iff [simp]: "(a / \<bar>b\<bar> \<le> 0) = (a \<le> 0 \<or> b = 0)"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1276
  by (auto simp: divide_le_0_iff)
55718
34618f031ba9 A few lemmas about summations, etc.
paulson <lp15@cam.ac.uk>
parents: 54230
diff changeset
  1277
35579
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1278
lemma field_le_mult_one_interval:
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1279
  assumes *: "\<And>z. \<lbrakk> 0 < z ; z < 1 \<rbrakk> \<Longrightarrow> z * x \<le> y"
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1280
  shows "x \<le> y"
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1281
proof (cases "0 < x")
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1282
  assume "0 < x"
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1283
  thus ?thesis
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1284
    using dense_le_bounded[of 0 1 "y/x"] *
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1285
    unfolding le_divide_eq if_P[OF \<open>0 < x\<close>] by simp
35579
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1286
next
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1287
  assume "\<not>0 < x" hence "x \<le> 0" by simp
61076
bdc1e2f0a86a eliminated \<Colon>;
wenzelm
parents: 60758
diff changeset
  1288
  obtain s::'a where s: "0 < s" "s < 1" using dense[of 0 "1::'a"] by auto
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60690
diff changeset
  1289
  hence "x \<le> s * x" using mult_le_cancel_right[of 1 x s] \<open>x \<le> 0\<close> by auto
35579
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1290
  also note *[OF s]
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1291
  finally show ?thesis .
cc9a5a0ab5ea Add dense_le, dense_le_bounded, field_le_mult_one_interval.
hoelzl
parents: 35216
diff changeset
  1292
qed
35090
88cc65ae046e moved lemma field_le_epsilon from Real.thy to Fields.thy
haftmann
parents: 35084
diff changeset
  1293
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69502
diff changeset
  1294
text\<open>For creating values between \<^term>\<open>u\<close> and \<^term>\<open>v\<close>.\<close>
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1295
lemma scaling_mono:
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1296
  assumes "u \<le> v" "0 \<le> r" "r \<le> s"
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1297
  shows "u + r * (v - u) / s \<le> v"
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1298
proof -
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1299
  have "r/s \<le> 1" using assms
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1300
    using divide_le_eq_1 by fastforce
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1301
  moreover have "0 \<le> v - u"
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1302
    using assms by simp
71695
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1303
  ultimately have "(r/s) * (v - u) \<le> 1 * (v - u)"
65489718f4dc Tidied up more ancient, horrible proofs. Liberalised frac_le
paulson <lp15@cam.ac.uk>
parents: 70817
diff changeset
  1304
    by (rule mult_right_mono)
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1305
  then show ?thesis
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1306
    by (simp add: field_simps)
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1307
qed
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 62481
diff changeset
  1308
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1309
end
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36348
diff changeset
  1310
61238
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1311
text \<open>Min/max Simplification Rules\<close>
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1312
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1313
lemma min_mult_distrib_left:
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1314
  fixes x::"'a::linordered_idom" 
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1315
  shows "p * min x y = (if 0 \<le> p then min (p*x) (p*y) else max (p*x) (p*y))"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1316
by (auto simp add: min_def max_def mult_le_cancel_left)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1317
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1318
lemma min_mult_distrib_right:
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1319
  fixes x::"'a::linordered_idom" 
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1320
  shows "min x y * p = (if 0 \<le> p then min (x*p) (y*p) else max (x*p) (y*p))"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1321
by (auto simp add: min_def max_def mult_le_cancel_right)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1322
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1323
lemma min_divide_distrib_right:
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1324
  fixes x::"'a::linordered_field" 
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1325
  shows "min x y / p = (if 0 \<le> p then min (x/p) (y/p) else max (x/p) (y/p))"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1326
by (simp add: min_mult_distrib_right divide_inverse)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1327
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1328
lemma max_mult_distrib_left:
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1329
  fixes x::"'a::linordered_idom" 
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1330
  shows "p * max x y = (if 0 \<le> p then max (p*x) (p*y) else min (p*x) (p*y))"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1331
by (auto simp add: min_def max_def mult_le_cancel_left)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1332
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1333
lemma max_mult_distrib_right:
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1334
  fixes x::"'a::linordered_idom" 
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1335
  shows "max x y * p = (if 0 \<le> p then max (x*p) (y*p) else min (x*p) (y*p))"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1336
by (auto simp add: min_def max_def mult_le_cancel_right)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1337
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1338
lemma max_divide_distrib_right:
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1339
  fixes x::"'a::linordered_field" 
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1340
  shows "max x y / p = (if 0 \<le> p then max (x/p) (y/p) else min (x/p) (y/p))"
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1341
by (simp add: max_mult_distrib_right divide_inverse)
e3d8a313a649 Useful facts about min/max, etc.
paulson <lp15@cam.ac.uk>
parents: 61076
diff changeset
  1342
59557
ebd8ecacfba6 establish unique preferred fact names
haftmann
parents: 59546
diff changeset
  1343
hide_fact (open) field_inverse field_divide_inverse field_inverse_zero
ebd8ecacfba6 establish unique preferred fact names
haftmann
parents: 59546
diff changeset
  1344
52435
6646bb548c6b migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents: 44921
diff changeset
  1345
code_identifier
6646bb548c6b migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents: 44921
diff changeset
  1346
  code_module Fields \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith
59667
651ea265d568 Removal of the file HOL/Number_Theory/Binomial!! And class field_char_0 now declared in Int.thy
paulson <lp15@cam.ac.uk>
parents: 59557
diff changeset
  1347
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff changeset
  1348
end