src/HOL/Library/Nonpos_Ints.thy
author wenzelm
Wed Mar 08 10:50:59 2017 +0100 (2017-03-08)
changeset 65151 a7394aa4d21c
parent 63092 a949b2a5f51d
child 67135 1a94352812f4
permissions -rw-r--r--
tuned proofs;
hoelzl@62055
     1
(*  Title:    HOL/Library/Nonpos_Ints.thy
hoelzl@62055
     2
    Author:   Manuel Eberl, TU M√ľnchen
eberlm@62049
     3
*)
hoelzl@62055
     4
paulson@62131
     5
section \<open>Non-negative, non-positive integers and reals\<close>
hoelzl@62055
     6
eberlm@62049
     7
theory Nonpos_Ints
eberlm@62049
     8
imports Complex_Main
eberlm@62049
     9
begin
eberlm@62049
    10
paulson@62131
    11
subsection\<open>Non-positive integers\<close>
hoelzl@62055
    12
text \<open>
hoelzl@62055
    13
  The set of non-positive integers on a ring. (in analogy to the set of non-negative
hoelzl@62055
    14
  integers @{term "\<nat>"}) This is useful e.g. for the Gamma function.
hoelzl@62055
    15
\<close>
eberlm@62049
    16
eberlm@62049
    17
definition nonpos_Ints ("\<int>\<^sub>\<le>\<^sub>0") where "\<int>\<^sub>\<le>\<^sub>0 = {of_int n |n. n \<le> 0}"
eberlm@62049
    18
eberlm@62049
    19
lemma zero_in_nonpos_Ints [simp,intro]: "0 \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    20
  unfolding nonpos_Ints_def by (auto intro!: exI[of _ "0::int"])
eberlm@62049
    21
eberlm@62049
    22
lemma neg_one_in_nonpos_Ints [simp,intro]: "-1 \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    23
  unfolding nonpos_Ints_def by (auto intro!: exI[of _ "-1::int"])
eberlm@62049
    24
eberlm@62049
    25
lemma neg_numeral_in_nonpos_Ints [simp,intro]: "-numeral n \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    26
  unfolding nonpos_Ints_def by (auto intro!: exI[of _ "-numeral n::int"])
eberlm@62049
    27
eberlm@62049
    28
lemma one_notin_nonpos_Ints [simp]: "(1 :: 'a :: ring_char_0) \<notin> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    29
  by (auto simp: nonpos_Ints_def)
eberlm@62049
    30
eberlm@62049
    31
lemma numeral_notin_nonpos_Ints [simp]: "(numeral n :: 'a :: ring_char_0) \<notin> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    32
  by (auto simp: nonpos_Ints_def)
eberlm@62049
    33
eberlm@62049
    34
lemma minus_of_nat_in_nonpos_Ints [simp, intro]: "- of_nat n \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    35
proof -
eberlm@62049
    36
  have "- of_nat n = of_int (-int n)" by simp
eberlm@62049
    37
  also have "-int n \<le> 0" by simp
eberlm@62049
    38
  hence "of_int (-int n) \<in> \<int>\<^sub>\<le>\<^sub>0" unfolding nonpos_Ints_def by blast
eberlm@62049
    39
  finally show ?thesis .
eberlm@62049
    40
qed
eberlm@62049
    41
eberlm@62049
    42
lemma of_nat_in_nonpos_Ints_iff: "(of_nat n :: 'a :: {ring_1,ring_char_0}) \<in> \<int>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> n = 0"
eberlm@62049
    43
proof
eberlm@62049
    44
  assume "(of_nat n :: 'a) \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    45
  then obtain m where "of_nat n = (of_int m :: 'a)" "m \<le> 0" by (auto simp: nonpos_Ints_def)
eberlm@62049
    46
  hence "(of_int m :: 'a) = of_nat n" by simp
eberlm@62049
    47
  also have "... = of_int (int n)" by simp
eberlm@62049
    48
  finally have "m = int n" by (subst (asm) of_int_eq_iff)
wenzelm@62072
    49
  with \<open>m \<le> 0\<close> show "n = 0" by auto
eberlm@62049
    50
qed simp
eberlm@62049
    51
eberlm@62049
    52
lemma nonpos_Ints_of_int: "n \<le> 0 \<Longrightarrow> of_int n \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    53
  unfolding nonpos_Ints_def by blast
eberlm@62049
    54
eberlm@62049
    55
lemma nonpos_IntsI: 
eberlm@62049
    56
  "x \<in> \<int> \<Longrightarrow> x \<le> 0 \<Longrightarrow> (x :: 'a :: linordered_idom) \<in> \<int>\<^sub>\<le>\<^sub>0"
wenzelm@63092
    57
  unfolding nonpos_Ints_def Ints_def by auto
eberlm@62049
    58
eberlm@62049
    59
lemma nonpos_Ints_subset_Ints: "\<int>\<^sub>\<le>\<^sub>0 \<subseteq> \<int>"
eberlm@62049
    60
  unfolding nonpos_Ints_def Ints_def by blast
eberlm@62049
    61
eberlm@62049
    62
lemma nonpos_Ints_nonpos [dest]: "x \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x \<le> (0 :: 'a :: linordered_idom)"
eberlm@62049
    63
  unfolding nonpos_Ints_def by auto
eberlm@62049
    64
eberlm@62049
    65
lemma nonpos_Ints_Int [dest]: "x \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x \<in> \<int>"
eberlm@62049
    66
  unfolding nonpos_Ints_def Ints_def by blast
eberlm@62049
    67
eberlm@62049
    68
lemma nonpos_Ints_cases:
eberlm@62049
    69
  assumes "x \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    70
  obtains n where "x = of_int n" "n \<le> 0"
eberlm@62049
    71
  using assms unfolding nonpos_Ints_def by (auto elim!: Ints_cases)
eberlm@62049
    72
eberlm@62049
    73
lemma nonpos_Ints_cases':
eberlm@62049
    74
  assumes "x \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    75
  obtains n where "x = -of_nat n"
eberlm@62049
    76
proof -
eberlm@62049
    77
  from assms obtain m where "x = of_int m" and m: "m \<le> 0" by (auto elim!: nonpos_Ints_cases)
eberlm@62049
    78
  hence "x = - of_int (-m)" by auto
eberlm@62049
    79
  also from m have "(of_int (-m) :: 'a) = of_nat (nat (-m))" by simp_all
eberlm@62049
    80
  finally show ?thesis by (rule that)
eberlm@62049
    81
qed
eberlm@62049
    82
eberlm@62049
    83
lemma of_real_in_nonpos_Ints_iff: "(of_real x :: 'a :: real_algebra_1) \<in> \<int>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> x \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    84
proof
eberlm@62049
    85
  assume "of_real x \<in> (\<int>\<^sub>\<le>\<^sub>0 :: 'a set)"
eberlm@62049
    86
  then obtain n where "(of_real x :: 'a) = of_int n" "n \<le> 0" by (erule nonpos_Ints_cases)
wenzelm@62072
    87
  note \<open>of_real x = of_int n\<close>
eberlm@62049
    88
  also have "of_int n = of_real (of_int n)" by (rule of_real_of_int_eq [symmetric])
eberlm@62049
    89
  finally have "x = of_int n" by (subst (asm) of_real_eq_iff)
wenzelm@62072
    90
  with \<open>n \<le> 0\<close> show "x \<in> \<int>\<^sub>\<le>\<^sub>0" by (simp add: nonpos_Ints_of_int)
eberlm@62049
    91
qed (auto elim!: nonpos_Ints_cases intro!: nonpos_Ints_of_int)
eberlm@62049
    92
eberlm@62049
    93
lemma nonpos_Ints_altdef: "\<int>\<^sub>\<le>\<^sub>0 = {n \<in> \<int>. (n :: 'a :: linordered_idom) \<le> 0}"
eberlm@62049
    94
  by (auto intro!: nonpos_IntsI elim!: nonpos_Ints_cases)
eberlm@62049
    95
eberlm@62049
    96
lemma uminus_in_Nats_iff: "-x \<in> \<nat> \<longleftrightarrow> x \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
    97
proof
eberlm@62049
    98
  assume "-x \<in> \<nat>"
eberlm@62049
    99
  then obtain n where "n \<ge> 0" "-x = of_int n" by (auto simp: Nats_altdef1)
eberlm@62049
   100
  hence "-n \<le> 0" "x = of_int (-n)" by (simp_all add: eq_commute minus_equation_iff[of x])
eberlm@62049
   101
  thus "x \<in> \<int>\<^sub>\<le>\<^sub>0" unfolding nonpos_Ints_def by blast
eberlm@62049
   102
next
eberlm@62049
   103
  assume "x \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
   104
  then obtain n where "n \<le> 0" "x = of_int n" by (auto simp: nonpos_Ints_def)
eberlm@62049
   105
  hence "-n \<ge> 0" "-x = of_int (-n)" by (simp_all add: eq_commute minus_equation_iff[of x])
eberlm@62049
   106
  thus "-x \<in> \<nat>" unfolding Nats_altdef1 by blast
eberlm@62049
   107
qed
eberlm@62049
   108
eberlm@62049
   109
lemma uminus_in_nonpos_Ints_iff: "-x \<in> \<int>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> x \<in> \<nat>"
eberlm@62049
   110
  using uminus_in_Nats_iff[of "-x"] by simp
eberlm@62049
   111
eberlm@62049
   112
lemma nonpos_Ints_mult: "x \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> y \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x * y \<in> \<nat>"
eberlm@62049
   113
  using Nats_mult[of "-x" "-y"] by (simp add: uminus_in_Nats_iff)
eberlm@62049
   114
eberlm@62049
   115
lemma Nats_mult_nonpos_Ints: "x \<in> \<nat> \<Longrightarrow> y \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x * y \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
   116
  using Nats_mult[of x "-y"] by (simp add: uminus_in_Nats_iff)
eberlm@62049
   117
eberlm@62049
   118
lemma nonpos_Ints_mult_Nats:
eberlm@62049
   119
  "x \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> y \<in> \<nat> \<Longrightarrow> x * y \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
   120
  using Nats_mult[of "-x" y] by (simp add: uminus_in_Nats_iff)
eberlm@62049
   121
eberlm@62049
   122
lemma nonpos_Ints_add:
eberlm@62049
   123
  "x \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> y \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x + y \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
   124
  using Nats_add[of "-x" "-y"] uminus_in_Nats_iff[of "y+x", simplified minus_add] 
eberlm@62049
   125
  by (simp add: uminus_in_Nats_iff add.commute)
eberlm@62049
   126
eberlm@62049
   127
lemma nonpos_Ints_diff_Nats:
eberlm@62049
   128
  "x \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> y \<in> \<nat> \<Longrightarrow> x - y \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
   129
  using Nats_add[of "-x" "y"] uminus_in_Nats_iff[of "x-y", simplified minus_add] 
eberlm@62049
   130
  by (simp add: uminus_in_Nats_iff add.commute)
eberlm@62049
   131
eberlm@62049
   132
lemma Nats_diff_nonpos_Ints:
eberlm@62049
   133
  "x \<in> \<nat> \<Longrightarrow> y \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x - y \<in> \<nat>"
eberlm@62049
   134
  using Nats_add[of "x" "-y"] by (simp add: uminus_in_Nats_iff add.commute)
eberlm@62049
   135
eberlm@62049
   136
lemma plus_of_nat_eq_0_imp: "z + of_nat n = 0 \<Longrightarrow> z \<in> \<int>\<^sub>\<le>\<^sub>0"
eberlm@62049
   137
proof -
eberlm@62049
   138
  assume "z + of_nat n = 0"
eberlm@62049
   139
  hence A: "z = - of_nat n" by (simp add: eq_neg_iff_add_eq_0)
eberlm@62049
   140
  show "z \<in> \<int>\<^sub>\<le>\<^sub>0" by (subst A) simp
eberlm@62049
   141
qed
eberlm@62049
   142
paulson@62131
   143
paulson@62131
   144
subsection\<open>Non-negative reals\<close>
paulson@62131
   145
paulson@62131
   146
definition nonneg_Reals :: "'a::real_algebra_1 set"  ("\<real>\<^sub>\<ge>\<^sub>0")
paulson@62131
   147
  where "\<real>\<^sub>\<ge>\<^sub>0 = {of_real r | r. r \<ge> 0}"
paulson@62131
   148
paulson@62131
   149
lemma nonneg_Reals_of_real_iff [simp]: "of_real r \<in> \<real>\<^sub>\<ge>\<^sub>0 \<longleftrightarrow> r \<ge> 0"
paulson@62131
   150
  by (force simp add: nonneg_Reals_def)
paulson@62131
   151
paulson@62131
   152
lemma nonneg_Reals_subset_Reals: "\<real>\<^sub>\<ge>\<^sub>0 \<subseteq> \<real>"
paulson@62131
   153
  unfolding nonneg_Reals_def Reals_def by blast
paulson@62131
   154
paulson@62131
   155
lemma nonneg_Reals_Real [dest]: "x \<in> \<real>\<^sub>\<ge>\<^sub>0 \<Longrightarrow> x \<in> \<real>"
paulson@62131
   156
  unfolding nonneg_Reals_def Reals_def by blast
paulson@62131
   157
paulson@62131
   158
lemma nonneg_Reals_of_nat_I [simp]: "of_nat n \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   159
  by (metis nonneg_Reals_of_real_iff of_nat_0_le_iff of_real_of_nat_eq)
paulson@62131
   160
paulson@62131
   161
lemma nonneg_Reals_cases:
paulson@62131
   162
  assumes "x \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   163
  obtains r where "x = of_real r" "r \<ge> 0"
paulson@62131
   164
  using assms unfolding nonneg_Reals_def by (auto elim!: Reals_cases)
paulson@62131
   165
paulson@62131
   166
lemma nonneg_Reals_zero_I [simp]: "0 \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   167
  unfolding nonneg_Reals_def by auto
paulson@62131
   168
paulson@62131
   169
lemma nonneg_Reals_one_I [simp]: "1 \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   170
  by (metis (mono_tags, lifting) nonneg_Reals_of_nat_I of_nat_1)
paulson@62131
   171
paulson@62131
   172
lemma nonneg_Reals_minus_one_I [simp]: "-1 \<notin> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   173
  by (metis nonneg_Reals_of_real_iff le_minus_one_simps(3) of_real_1 of_real_def real_vector.scale_minus_left)
paulson@62131
   174
paulson@62131
   175
lemma nonneg_Reals_numeral_I [simp]: "numeral w \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   176
  by (metis (no_types) nonneg_Reals_of_nat_I of_nat_numeral)
paulson@62131
   177
paulson@62131
   178
lemma nonneg_Reals_minus_numeral_I [simp]: "- numeral w \<notin> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   179
  using nonneg_Reals_of_real_iff not_zero_le_neg_numeral by fastforce
paulson@62131
   180
paulson@62131
   181
lemma nonneg_Reals_add_I [simp]: "\<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<ge>\<^sub>0\<rbrakk> \<Longrightarrow> a + b \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   182
apply (simp add: nonneg_Reals_def)
paulson@62131
   183
apply clarify
paulson@62131
   184
apply (rename_tac r s)
paulson@62131
   185
apply (rule_tac x="r+s" in exI, auto)
paulson@62131
   186
done
paulson@62131
   187
paulson@62131
   188
lemma nonneg_Reals_mult_I [simp]: "\<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<ge>\<^sub>0\<rbrakk> \<Longrightarrow> a * b \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   189
  unfolding nonneg_Reals_def  by (auto simp: of_real_def)
paulson@62131
   190
paulson@62131
   191
lemma nonneg_Reals_inverse_I [simp]:
paulson@62131
   192
  fixes a :: "'a::real_div_algebra"
paulson@62131
   193
  shows "a \<in> \<real>\<^sub>\<ge>\<^sub>0 \<Longrightarrow> inverse a \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   194
  by (simp add: nonneg_Reals_def image_iff) (metis inverse_nonnegative_iff_nonnegative of_real_inverse)
paulson@62131
   195
paulson@62131
   196
lemma nonneg_Reals_divide_I [simp]:
paulson@62131
   197
  fixes a :: "'a::real_div_algebra"
paulson@62131
   198
  shows "\<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<ge>\<^sub>0\<rbrakk> \<Longrightarrow> a / b \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   199
  by (simp add: divide_inverse)
paulson@62131
   200
paulson@62131
   201
lemma nonneg_Reals_pow_I [simp]: "a \<in> \<real>\<^sub>\<ge>\<^sub>0 \<Longrightarrow> a^n \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   202
  by (induction n) auto
paulson@62131
   203
paulson@62131
   204
lemma complex_nonneg_Reals_iff: "z \<in> \<real>\<^sub>\<ge>\<^sub>0 \<longleftrightarrow> Re z \<ge> 0 \<and> Im z = 0"
paulson@62131
   205
  by (auto simp: nonneg_Reals_def) (metis complex_of_real_def complex_surj)
paulson@62131
   206
paulson@62131
   207
lemma ii_not_nonneg_Reals [iff]: "\<i> \<notin> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   208
  by (simp add: complex_nonneg_Reals_iff)
paulson@62131
   209
paulson@62131
   210
paulson@62131
   211
subsection\<open>Non-positive reals\<close>
paulson@62131
   212
paulson@62131
   213
definition nonpos_Reals :: "'a::real_algebra_1 set"  ("\<real>\<^sub>\<le>\<^sub>0")
paulson@62131
   214
  where "\<real>\<^sub>\<le>\<^sub>0 = {of_real r | r. r \<le> 0}"
paulson@62131
   215
paulson@62131
   216
lemma nonpos_Reals_of_real_iff [simp]: "of_real r \<in> \<real>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> r \<le> 0"
paulson@62131
   217
  by (force simp add: nonpos_Reals_def)
paulson@62131
   218
paulson@62131
   219
lemma nonpos_Reals_subset_Reals: "\<real>\<^sub>\<le>\<^sub>0 \<subseteq> \<real>"
paulson@62131
   220
  unfolding nonpos_Reals_def Reals_def by blast
paulson@62131
   221
paulson@62131
   222
lemma nonpos_Ints_subset_nonpos_Reals: "\<int>\<^sub>\<le>\<^sub>0 \<subseteq> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   223
  by (metis nonpos_Ints_cases nonpos_Ints_nonpos nonpos_Ints_of_int 
paulson@62131
   224
    nonpos_Reals_of_real_iff of_real_of_int_eq subsetI)
paulson@62131
   225
paulson@62131
   226
lemma nonpos_Reals_of_nat_iff [simp]: "of_nat n \<in> \<real>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> n=0"
paulson@62131
   227
  by (metis nonpos_Reals_of_real_iff of_nat_le_0_iff of_real_of_nat_eq)
paulson@62131
   228
paulson@62131
   229
lemma nonpos_Reals_Real [dest]: "x \<in> \<real>\<^sub>\<le>\<^sub>0 \<Longrightarrow> x \<in> \<real>"
paulson@62131
   230
  unfolding nonpos_Reals_def Reals_def by blast
paulson@62131
   231
paulson@62131
   232
lemma nonpos_Reals_cases:
paulson@62131
   233
  assumes "x \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   234
  obtains r where "x = of_real r" "r \<le> 0"
paulson@62131
   235
  using assms unfolding nonpos_Reals_def by (auto elim!: Reals_cases)
paulson@62131
   236
paulson@62131
   237
lemma uminus_nonneg_Reals_iff [simp]: "-x \<in> \<real>\<^sub>\<ge>\<^sub>0 \<longleftrightarrow> x \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   238
  apply (auto simp: nonpos_Reals_def nonneg_Reals_def)
paulson@62131
   239
  apply (metis nonpos_Reals_of_real_iff minus_minus neg_le_0_iff_le of_real_minus)
paulson@62131
   240
  apply (metis neg_0_le_iff_le of_real_minus)
paulson@62131
   241
  done
paulson@62131
   242
paulson@62131
   243
lemma uminus_nonpos_Reals_iff [simp]: "-x \<in> \<real>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> x \<in> \<real>\<^sub>\<ge>\<^sub>0"
paulson@62131
   244
  by (metis (no_types) minus_minus uminus_nonneg_Reals_iff)
paulson@62131
   245
paulson@62131
   246
lemma nonpos_Reals_zero_I [simp]: "0 \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   247
  unfolding nonpos_Reals_def by force
paulson@62131
   248
paulson@62131
   249
lemma nonpos_Reals_one_I [simp]: "1 \<notin> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   250
  using nonneg_Reals_minus_one_I uminus_nonneg_Reals_iff by blast
paulson@62131
   251
paulson@62131
   252
lemma nonpos_Reals_numeral_I [simp]: "numeral w \<notin> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   253
  using nonneg_Reals_minus_numeral_I uminus_nonneg_Reals_iff by blast
paulson@62131
   254
paulson@62131
   255
lemma nonpos_Reals_add_I [simp]: "\<lbrakk>a \<in> \<real>\<^sub>\<le>\<^sub>0; b \<in> \<real>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> a + b \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   256
  by (metis nonneg_Reals_add_I add_uminus_conv_diff minus_diff_eq minus_minus uminus_nonpos_Reals_iff)
paulson@62131
   257
paulson@62131
   258
lemma nonpos_Reals_mult_I1: "\<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> a * b \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   259
  by (metis nonneg_Reals_mult_I mult_minus_right uminus_nonneg_Reals_iff)
paulson@62131
   260
paulson@62131
   261
lemma nonpos_Reals_mult_I2: "\<lbrakk>a \<in> \<real>\<^sub>\<le>\<^sub>0; b \<in> \<real>\<^sub>\<ge>\<^sub>0\<rbrakk> \<Longrightarrow> a * b \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   262
  by (metis nonneg_Reals_mult_I mult_minus_left uminus_nonneg_Reals_iff)
paulson@62131
   263
paulson@62131
   264
lemma nonpos_Reals_mult_of_nat_iff:
paulson@62131
   265
  fixes a:: "'a :: real_div_algebra" shows "a * of_nat n \<in> \<real>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> a \<in> \<real>\<^sub>\<le>\<^sub>0 \<or> n=0"
paulson@62131
   266
  apply (auto intro: nonpos_Reals_mult_I2)
paulson@62131
   267
  apply (auto simp: nonpos_Reals_def)
paulson@62131
   268
  apply (rule_tac x="r/n" in exI)
paulson@62131
   269
  apply (auto simp: divide_simps)
paulson@62131
   270
  done
paulson@62131
   271
paulson@62131
   272
lemma nonpos_Reals_inverse_I:
paulson@62131
   273
    fixes a :: "'a::real_div_algebra"
paulson@62131
   274
    shows "a \<in> \<real>\<^sub>\<le>\<^sub>0 \<Longrightarrow> inverse a \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   275
  using nonneg_Reals_inverse_I uminus_nonneg_Reals_iff by fastforce
paulson@62131
   276
paulson@62131
   277
lemma nonpos_Reals_divide_I1:
paulson@62131
   278
    fixes a :: "'a::real_div_algebra"
paulson@62131
   279
    shows "\<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> a / b \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   280
  by (simp add: nonpos_Reals_inverse_I nonpos_Reals_mult_I1 divide_inverse)
paulson@62131
   281
paulson@62131
   282
lemma nonpos_Reals_divide_I2:
paulson@62131
   283
    fixes a :: "'a::real_div_algebra"
paulson@62131
   284
    shows "\<lbrakk>a \<in> \<real>\<^sub>\<le>\<^sub>0; b \<in> \<real>\<^sub>\<ge>\<^sub>0\<rbrakk> \<Longrightarrow> a / b \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   285
  by (metis nonneg_Reals_divide_I minus_divide_left uminus_nonneg_Reals_iff)
paulson@62131
   286
paulson@62131
   287
lemma nonpos_Reals_divide_of_nat_iff:
paulson@62131
   288
  fixes a:: "'a :: real_div_algebra" shows "a / of_nat n \<in> \<real>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> a \<in> \<real>\<^sub>\<le>\<^sub>0 \<or> n=0"
paulson@62131
   289
  apply (auto intro: nonpos_Reals_divide_I2)
paulson@62131
   290
  apply (auto simp: nonpos_Reals_def)
paulson@62131
   291
  apply (rule_tac x="r*n" in exI)
paulson@62131
   292
  apply (auto simp: divide_simps mult_le_0_iff)
paulson@62131
   293
  done
paulson@62131
   294
paulson@62131
   295
lemma nonpos_Reals_pow_I: "\<lbrakk>a \<in> \<real>\<^sub>\<le>\<^sub>0; odd n\<rbrakk> \<Longrightarrow> a^n \<in> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   296
  by (metis nonneg_Reals_pow_I power_minus_odd uminus_nonneg_Reals_iff)
paulson@62131
   297
paulson@62131
   298
lemma complex_nonpos_Reals_iff: "z \<in> \<real>\<^sub>\<le>\<^sub>0 \<longleftrightarrow> Re z \<le> 0 \<and> Im z = 0"
paulson@62131
   299
   using complex_is_Real_iff by (force simp add: nonpos_Reals_def)
paulson@62131
   300
paulson@62131
   301
lemma ii_not_nonpos_Reals [iff]: "\<i> \<notin> \<real>\<^sub>\<le>\<^sub>0"
paulson@62131
   302
  by (simp add: complex_nonpos_Reals_iff)
paulson@62131
   303
nipkow@62390
   304
end