src/HOL/Analysis/Extended_Real_Limits.thy
author immler
Mon, 26 Feb 2018 07:34:05 +0100
changeset 67727 ce3e87a51488
parent 67613 ce654b0e6d69
child 68610 4fdc9f681479
permissions -rw-r--r--
moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63627
6ddb43c6b711 rename HOL-Multivariate_Analysis to HOL-Analysis.
hoelzl
parents: 62843
diff changeset
     1
(*  Title:      HOL/Analysis/Extended_Real_Limits.thy
41983
2dc6e382a58b standardized headers;
wenzelm
parents: 41981
diff changeset
     2
    Author:     Johannes Hölzl, TU München
2dc6e382a58b standardized headers;
wenzelm
parents: 41981
diff changeset
     3
    Author:     Robert Himmelmann, TU München
2dc6e382a58b standardized headers;
wenzelm
parents: 41981
diff changeset
     4
    Author:     Armin Heller, TU München
2dc6e382a58b standardized headers;
wenzelm
parents: 41981
diff changeset
     5
    Author:     Bogdan Grechuk, University of Edinburgh
2dc6e382a58b standardized headers;
wenzelm
parents: 41981
diff changeset
     6
*)
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
     7
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
     8
section \<open>Limits on the Extended real number line\<close>
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
     9
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
    10
theory Extended_Real_Limits
61560
7c985fd653c5 tuned imports;
wenzelm
parents: 61245
diff changeset
    11
imports
7c985fd653c5 tuned imports;
wenzelm
parents: 61245
diff changeset
    12
  Topology_Euclidean_Space
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 64320
diff changeset
    13
  "HOL-Library.Extended_Real"
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 64320
diff changeset
    14
  "HOL-Library.Extended_Nonnegative_Real"
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 64320
diff changeset
    15
  "HOL-Library.Indicator_Function"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
    16
begin
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
    17
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    18
lemma compact_UNIV:
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    19
  "compact (UNIV :: 'a::{complete_linorder,linorder_topology,second_countable_topology} set)"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    20
  using compact_complete_linorder
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    21
  by (auto simp: seq_compact_eq_compact[symmetric] seq_compact_def)
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    22
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    23
lemma compact_eq_closed:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    24
  fixes S :: "'a::{complete_linorder,linorder_topology,second_countable_topology} set"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    25
  shows "compact S \<longleftrightarrow> closed S"
62843
313d3b697c9a Mostly renaming (from HOL Light to Isabelle conventions), with a couple of new results
paulson <lp15@cam.ac.uk>
parents: 62375
diff changeset
    26
  using closed_Int_compact[of S, OF _ compact_UNIV] compact_imp_closed
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    27
  by auto
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    28
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    29
lemma closed_contains_Sup_cl:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    30
  fixes S :: "'a::{complete_linorder,linorder_topology,second_countable_topology} set"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    31
  assumes "closed S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    32
    and "S \<noteq> {}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    33
  shows "Sup S \<in> S"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    34
proof -
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    35
  from compact_eq_closed[of S] compact_attains_sup[of S] assms
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    36
  obtain s where S: "s \<in> S" "\<forall>t\<in>S. t \<le> s"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    37
    by auto
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51641
diff changeset
    38
  then have "Sup S = s"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    39
    by (auto intro!: Sup_eqI)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51641
diff changeset
    40
  with S show ?thesis
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    41
    by simp
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    42
qed
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    43
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    44
lemma closed_contains_Inf_cl:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    45
  fixes S :: "'a::{complete_linorder,linorder_topology,second_countable_topology} set"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    46
  assumes "closed S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    47
    and "S \<noteq> {}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    48
  shows "Inf S \<in> S"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    49
proof -
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    50
  from compact_eq_closed[of S] compact_attains_inf[of S] assms
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    51
  obtain s where S: "s \<in> S" "\<forall>t\<in>S. s \<le> t"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    52
    by auto
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51641
diff changeset
    53
  then have "Inf S = s"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    54
    by (auto intro!: Inf_eqI)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51641
diff changeset
    55
  with S show ?thesis
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    56
    by simp
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    57
qed
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    58
64320
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    59
instance enat :: second_countable_topology
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    60
proof
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    61
  show "\<exists>B::enat set set. countable B \<and> open = generate_topology B"
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    62
  proof (intro exI conjI)
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    63
    show "countable (range lessThan \<union> range greaterThan::enat set set)"
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    64
      by auto
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    65
  qed (simp add: open_enat_def)
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    66
qed
ba194424b895 HOL-Probability: move stopping time from AFP/Markov_Models
hoelzl
parents: 63627
diff changeset
    67
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    68
instance ereal :: second_countable_topology
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60771
diff changeset
    69
proof (standard, intro exI conjI)
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    70
  let ?B = "(\<Union>r\<in>\<rat>. {{..< r}, {r <..}} :: ereal set set)"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    71
  show "countable ?B"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    72
    by (auto intro: countable_rat)
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    73
  show "open = generate_topology ?B"
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    74
  proof (intro ext iffI)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    75
    fix S :: "ereal set"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    76
    assume "open S"
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    77
    then show "generate_topology ?B S"
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    78
      unfolding open_generated_order
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    79
    proof induct
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    80
      case (Basis b)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    81
      then obtain e where "b = {..<e} \<or> b = {e<..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    82
        by auto
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    83
      moreover have "{..<e} = \<Union>{{..<x}|x. x \<in> \<rat> \<and> x < e}" "{e<..} = \<Union>{{x<..}|x. x \<in> \<rat> \<and> e < x}"
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    84
        by (auto dest: ereal_dense3
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    85
                 simp del: ex_simps
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    86
                 simp add: ex_simps[symmetric] conj_commute Rats_def image_iff)
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    87
      ultimately show ?case
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    88
        by (auto intro: generate_topology.intros)
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    89
    qed (auto intro: generate_topology.intros)
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    90
  next
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    91
    fix S
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    92
    assume "generate_topology ?B S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    93
    then show "open S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
    94
      by induct auto
51351
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    95
  qed
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    96
qed
dd1dd470690b generalized lemmas in Extended_Real_Limits
hoelzl
parents: 51340
diff changeset
    97
62375
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
    98
text \<open>This is a copy from \<open>ereal :: second_countable_topology\<close>. Maybe find a common super class of
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
    99
topological spaces where the rational numbers are densely embedded ?\<close>
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   100
instance ennreal :: second_countable_topology
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   101
proof (standard, intro exI conjI)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   102
  let ?B = "(\<Union>r\<in>\<rat>. {{..< r}, {r <..}} :: ennreal set set)"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   103
  show "countable ?B"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   104
    by (auto intro: countable_rat)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   105
  show "open = generate_topology ?B"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   106
  proof (intro ext iffI)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   107
    fix S :: "ennreal set"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   108
    assume "open S"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   109
    then show "generate_topology ?B S"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   110
      unfolding open_generated_order
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   111
    proof induct
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   112
      case (Basis b)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   113
      then obtain e where "b = {..<e} \<or> b = {e<..}"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   114
        by auto
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   115
      moreover have "{..<e} = \<Union>{{..<x}|x. x \<in> \<rat> \<and> x < e}" "{e<..} = \<Union>{{x<..}|x. x \<in> \<rat> \<and> e < x}"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   116
        by (auto dest: ennreal_rat_dense
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   117
                 simp del: ex_simps
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   118
                 simp add: ex_simps[symmetric] conj_commute Rats_def image_iff)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   119
      ultimately show ?case
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   120
        by (auto intro: generate_topology.intros)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   121
    qed (auto intro: generate_topology.intros)
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   122
  next
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   123
    fix S
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   124
    assume "generate_topology ?B S"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   125
    then show "open S"
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   126
      by induct auto
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   127
  qed
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   128
qed
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   129
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 42950
diff changeset
   130
lemma ereal_open_closed_aux:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 42950
diff changeset
   131
  fixes S :: "ereal set"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   132
  assumes "open S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   133
    and "closed S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   134
    and S: "(-\<infinity>) \<notin> S"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   135
  shows "S = {}"
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   136
proof (rule ccontr)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   137
  assume "\<not> ?thesis"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   138
  then have *: "Inf S \<in> S"
62375
670063003ad3 add extended nonnegative real numbers
hoelzl
parents: 62049
diff changeset
   139
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   140
    by (metis assms(2) closed_contains_Inf_cl)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   141
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   142
    assume "Inf S = -\<infinity>"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   143
    then have False
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   144
      using * assms(3) by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   145
  }
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   146
  moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   147
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   148
    assume "Inf S = \<infinity>"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   149
    then have "S = {\<infinity>}"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
   150
      by (metis Inf_eq_PInfty \<open>S \<noteq> {}\<close>)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   151
    then have False
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   152
      by (metis assms(1) not_open_singleton)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   153
  }
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   154
  moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   155
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   156
    assume fin: "\<bar>Inf S\<bar> \<noteq> \<infinity>"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   157
    from ereal_open_cont_interval[OF assms(1) * fin]
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   158
    obtain e where e: "e > 0" "{Inf S - e<..<Inf S + e} \<subseteq> S" .
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   159
    then obtain b where b: "Inf S - e < b" "b < Inf S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   160
      using fin ereal_between[of "Inf S" e] dense[of "Inf S - e"]
44918
6a80fbc4e72c tune simpset for Complete_Lattices
noschinl
parents: 44571
diff changeset
   161
      by auto
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 66456
diff changeset
   162
    then have "b \<in> {Inf S - e <..< Inf S + e}"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   163
      using e fin ereal_between[of "Inf S" e]
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   164
      by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   165
    then have "b \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   166
      using e by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   167
    then have False
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   168
      using b by (metis complete_lattice_class.Inf_lower leD)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   169
  }
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   170
  ultimately show False
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   171
    by auto
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   172
qed
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   173
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 42950
diff changeset
   174
lemma ereal_open_closed:
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 42950
diff changeset
   175
  fixes S :: "ereal set"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   176
  shows "open S \<and> closed S \<longleftrightarrow> S = {} \<or> S = UNIV"
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   177
proof -
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   178
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   179
    assume lhs: "open S \<and> closed S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   180
    {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   181
      assume "-\<infinity> \<notin> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   182
      then have "S = {}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   183
        using lhs ereal_open_closed_aux by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   184
    }
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   185
    moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   186
    {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   187
      assume "-\<infinity> \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   188
      then have "- S = {}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   189
        using lhs ereal_open_closed_aux[of "-S"] by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   190
    }
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   191
    ultimately have "S = {} \<or> S = UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   192
      by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   193
  }
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   194
  then show ?thesis
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   195
    by auto
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   196
qed
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   197
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   198
lemma ereal_open_atLeast:
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   199
  fixes x :: ereal
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   200
  shows "open {x..} \<longleftrightarrow> x = -\<infinity>"
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   201
proof
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   202
  assume "x = -\<infinity>"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   203
  then have "{x..} = UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   204
    by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   205
  then show "open {x..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   206
    by auto
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   207
next
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   208
  assume "open {x..}"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   209
  then have "open {x..} \<and> closed {x..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   210
    by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   211
  then have "{x..} = UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   212
    unfolding ereal_open_closed by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   213
  then show "x = -\<infinity>"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   214
    by (simp add: bot_ereal_def atLeast_eq_UNIV_iff)
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   215
qed
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   216
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   217
lemma mono_closed_real:
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   218
  fixes S :: "real set"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   219
  assumes mono: "\<forall>y z. y \<in> S \<and> y \<le> z \<longrightarrow> z \<in> S"
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   220
    and "closed S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   221
  shows "S = {} \<or> S = UNIV \<or> (\<exists>a. S = {a..})"
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   222
proof -
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   223
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   224
    assume "S \<noteq> {}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   225
    { assume ex: "\<exists>B. \<forall>x\<in>S. B \<le> x"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   226
      then have *: "\<forall>x\<in>S. Inf S \<le> x"
54258
adfc759263ab use bdd_above and bdd_below for conditionally complete lattices
hoelzl
parents: 54257
diff changeset
   227
        using cInf_lower[of _ S] ex by (metis bdd_below_def)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   228
      then have "Inf S \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   229
        apply (subst closed_contains_Inf)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
   230
        using ex \<open>S \<noteq> {}\<close> \<open>closed S\<close>
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   231
        apply auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   232
        done
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   233
      then have "\<forall>x. Inf S \<le> x \<longleftrightarrow> x \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   234
        using mono[rule_format, of "Inf S"] *
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   235
        by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   236
      then have "S = {Inf S ..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   237
        by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   238
      then have "\<exists>a. S = {a ..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   239
        by auto
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   240
    }
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   241
    moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   242
    {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   243
      assume "\<not> (\<exists>B. \<forall>x\<in>S. B \<le> x)"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   244
      then have nex: "\<forall>B. \<exists>x\<in>S. x < B"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   245
        by (simp add: not_le)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   246
      {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   247
        fix y
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   248
        obtain x where "x\<in>S" and "x < y"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   249
          using nex by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   250
        then have "y \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   251
          using mono[rule_format, of x y] by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   252
      }
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   253
      then have "S = UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   254
        by auto
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   255
    }
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   256
    ultimately have "S = UNIV \<or> (\<exists>a. S = {a ..})"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   257
      by blast
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   258
  }
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   259
  then show ?thesis
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   260
    by blast
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   261
qed
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   262
43920
cedb5cb948fd Rename extreal => ereal
hoelzl
parents: 42950
diff changeset
   263
lemma mono_closed_ereal:
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   264
  fixes S :: "real set"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   265
  assumes mono: "\<forall>y z. y \<in> S \<and> y \<le> z \<longrightarrow> z \<in> S"
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   266
    and "closed S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   267
  shows "\<exists>a. S = {x. a \<le> ereal x}"
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   268
proof -
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   269
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   270
    assume "S = {}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   271
    then have ?thesis
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   272
      apply (rule_tac x=PInfty in exI)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   273
      apply auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   274
      done
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   275
  }
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   276
  moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   277
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   278
    assume "S = UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   279
    then have ?thesis
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   280
      apply (rule_tac x="-\<infinity>" in exI)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   281
      apply auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   282
      done
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   283
  }
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   284
  moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   285
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   286
    assume "\<exists>a. S = {a ..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   287
    then obtain a where "S = {a ..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   288
      by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   289
    then have ?thesis
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   290
      apply (rule_tac x="ereal a" in exI)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   291
      apply auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   292
      done
49664
f099b8006a3c tuned proofs;
wenzelm
parents: 47761
diff changeset
   293
  }
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   294
  ultimately show ?thesis
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   295
    using mono_closed_real[of S] assms by auto
41980
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   296
qed
28b51effc5ed split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
diff changeset
   297
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   298
lemma Liminf_within:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   299
  fixes f :: "'a::metric_space \<Rightarrow> 'b::complete_lattice"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   300
  shows "Liminf (at x within S) f = (SUP e:{0<..}. INF y:(S \<inter> ball x e - {x}). f y)"
51641
cd05e9fcc63d remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
hoelzl
parents: 51530
diff changeset
   301
  unfolding Liminf_def eventually_at
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
   302
proof (rule SUP_eq, simp_all add: Ball_def Bex_def, safe)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   303
  fix P d
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   304
  assume "0 < d" and "\<forall>y. y \<in> S \<longrightarrow> y \<noteq> x \<and> dist y x < d \<longrightarrow> P y"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   305
  then have "S \<inter> ball x d - {x} \<subseteq> {x. P x}"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   306
    by (auto simp: zero_less_dist_iff dist_commute)
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
   307
  then show "\<exists>r>0. INFIMUM (Collect P) f \<le> INFIMUM (S \<inter> ball x r - {x}) f"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
   308
    by (intro exI[of _ d] INF_mono conjI \<open>0 < d\<close>) auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   309
next
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   310
  fix d :: real
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   311
  assume "0 < d"
51641
cd05e9fcc63d remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
hoelzl
parents: 51530
diff changeset
   312
  then show "\<exists>P. (\<exists>d>0. \<forall>xa. xa \<in> S \<longrightarrow> xa \<noteq> x \<and> dist xa x < d \<longrightarrow> P xa) \<and>
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
   313
    INFIMUM (S \<inter> ball x d - {x}) f \<le> INFIMUM (Collect P) f"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   314
    by (intro exI[of _ "\<lambda>y. y \<in> S \<inter> ball x d - {x}"])
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   315
       (auto intro!: INF_mono exI[of _ d] simp: dist_commute)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   316
qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   317
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   318
lemma Limsup_within:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   319
  fixes f :: "'a::metric_space \<Rightarrow> 'b::complete_lattice"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   320
  shows "Limsup (at x within S) f = (INF e:{0<..}. SUP y:(S \<inter> ball x e - {x}). f y)"
51641
cd05e9fcc63d remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
hoelzl
parents: 51530
diff changeset
   321
  unfolding Limsup_def eventually_at
56212
3253aaf73a01 consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
haftmann
parents: 56166
diff changeset
   322
proof (rule INF_eq, simp_all add: Ball_def Bex_def, safe)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   323
  fix P d
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   324
  assume "0 < d" and "\<forall>y. y \<in> S \<longrightarrow> y \<noteq> x \<and> dist y x < d \<longrightarrow> P y"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   325
  then have "S \<inter> ball x d - {x} \<subseteq> {x. P x}"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   326
    by (auto simp: zero_less_dist_iff dist_commute)
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
   327
  then show "\<exists>r>0. SUPREMUM (S \<inter> ball x r - {x}) f \<le> SUPREMUM (Collect P) f"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
   328
    by (intro exI[of _ d] SUP_mono conjI \<open>0 < d\<close>) auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   329
next
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   330
  fix d :: real
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   331
  assume "0 < d"
51641
cd05e9fcc63d remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
hoelzl
parents: 51530
diff changeset
   332
  then show "\<exists>P. (\<exists>d>0. \<forall>xa. xa \<in> S \<longrightarrow> xa \<noteq> x \<and> dist xa x < d \<longrightarrow> P xa) \<and>
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
   333
    SUPREMUM (Collect P) f \<le> SUPREMUM (S \<inter> ball x d - {x}) f"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   334
    by (intro exI[of _ "\<lambda>y. y \<in> S \<inter> ball x d - {x}"])
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   335
       (auto intro!: SUP_mono exI[of _ d] simp: dist_commute)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   336
qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   337
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   338
lemma Liminf_at:
54257
5c7a3b6b05a9 generalize SUP and INF to the syntactic type classes Sup and Inf
hoelzl
parents: 53788
diff changeset
   339
  fixes f :: "'a::metric_space \<Rightarrow> 'b::complete_lattice"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   340
  shows "Liminf (at x) f = (SUP e:{0<..}. INF y:(ball x e - {x}). f y)"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   341
  using Liminf_within[of x UNIV f] by simp
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   342
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   343
lemma Limsup_at:
54257
5c7a3b6b05a9 generalize SUP and INF to the syntactic type classes Sup and Inf
hoelzl
parents: 53788
diff changeset
   344
  fixes f :: "'a::metric_space \<Rightarrow> 'b::complete_lattice"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   345
  shows "Limsup (at x) f = (INF e:{0<..}. SUP y:(ball x e - {x}). f y)"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   346
  using Limsup_within[of x UNIV f] by simp
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   347
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   348
lemma min_Liminf_at:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
   349
  fixes f :: "'a::metric_space \<Rightarrow> 'b::complete_linorder"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   350
  shows "min (f x) (Liminf (at x) f) = (SUP e:{0<..}. INF y:ball x e. f y)"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   351
  unfolding inf_min[symmetric] Liminf_at
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   352
  apply (subst inf_commute)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   353
  apply (subst SUP_inf)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   354
  apply (intro SUP_cong[OF refl])
54260
6a967667fd45 use INF and SUP on conditionally complete lattices in multivariate analysis
hoelzl
parents: 54258
diff changeset
   355
  apply (cut_tac A="ball x xa - {x}" and B="{x}" and M=f in INF_union)
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55522
diff changeset
   356
  apply (drule sym)
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 55522
diff changeset
   357
  apply auto
57865
dcfb33c26f50 tuned proofs -- fewer warnings;
wenzelm
parents: 57447
diff changeset
   358
  apply (metis INF_absorb centre_in_ball)
dcfb33c26f50 tuned proofs -- fewer warnings;
wenzelm
parents: 57447
diff changeset
   359
  done
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
   360
66456
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   361
subsection \<open>Fun.thy\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   362
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   363
lemma inj_fn:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   364
  fixes f::"'a \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   365
  assumes "inj f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   366
  shows "inj (f^^n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   367
proof (induction n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   368
  case (Suc n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   369
  have "inj (f o (f^^n))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   370
    using inj_comp[OF assms Suc.IH] by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   371
  then show "inj (f^^(Suc n))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   372
    by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   373
qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   374
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   375
lemma surj_fn:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   376
  fixes f::"'a \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   377
  assumes "surj f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   378
  shows "surj (f^^n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   379
proof (induction n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   380
  case (Suc n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   381
  have "surj (f o (f^^n))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   382
    using assms Suc.IH by (simp add: comp_surj)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   383
  then show "surj (f^^(Suc n))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   384
    by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   385
qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   386
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   387
lemma bij_fn:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   388
  fixes f::"'a \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   389
  assumes "bij f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   390
  shows "bij (f^^n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   391
by (rule bijI[OF inj_fn[OF bij_is_inj[OF assms]] surj_fn[OF bij_is_surj[OF assms]]])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   392
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   393
lemma inv_fn_o_fn_is_id:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   394
  fixes f::"'a \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   395
  assumes "bij f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   396
  shows "((inv f)^^n) o (f^^n) = (\<lambda>x. x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   397
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   398
  have "((inv f)^^n)((f^^n) x) = x" for x n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   399
  proof (induction n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   400
    case (Suc n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   401
    have *: "(inv f) (f y) = y" for y
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   402
      by (simp add: assms bij_is_inj)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   403
    have "(inv f ^^ Suc n) ((f ^^ Suc n) x) = (inv f^^n) (inv f (f ((f^^n) x)))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   404
      by (simp add: funpow_swap1)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   405
    also have "... = (inv f^^n) ((f^^n) x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   406
      using * by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   407
    also have "... = x" using Suc.IH by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   408
    finally show ?case by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   409
  qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   410
  then show ?thesis unfolding o_def by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   411
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   412
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   413
lemma bij_inv_eq_iff: "bij p \<Longrightarrow> x = inv p y \<longleftrightarrow> p x = y" (* COPIED FROM Permutations *)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   414
  using surj_f_inv_f[of p] by (auto simp add: bij_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   415
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   416
lemma fn_o_inv_fn_is_id:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   417
  fixes f::"'a \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   418
  assumes "bij f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   419
  shows "(f^^n) o ((inv f)^^n) = (\<lambda>x. x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   420
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   421
  have "(f^^n) (((inv f)^^n) x) = x" for x n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   422
  proof (induction n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   423
    case (Suc n)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   424
    have *: "f(inv f y) = y" for y
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   425
      using assms by (meson bij_inv_eq_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   426
    have "(f ^^ Suc n) ((inv f ^^ Suc n) x) = (f^^n) (f (inv f ((inv f^^n) x)))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   427
      by (simp add: funpow_swap1)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   428
    also have "... = (f^^n) ((inv f^^n) x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   429
      using * by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   430
    also have "... = x" using Suc.IH by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   431
    finally show ?case by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   432
  qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   433
  then show ?thesis unfolding o_def by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   434
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   435
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   436
lemma inv_fn:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   437
  fixes f::"'a \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   438
  assumes "bij f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   439
  shows "inv (f^^n) = ((inv f)^^n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   440
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   441
  have "inv (f^^n) x = ((inv f)^^n) x" for x
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   442
  apply (rule inv_into_f_eq, auto simp add: inj_fn[OF bij_is_inj[OF assms]])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   443
  using fn_o_inv_fn_is_id[OF assms, of n] by (metis comp_apply)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   444
  then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   445
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   446
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   447
lemma mono_inv:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   448
  fixes f::"'a::linorder \<Rightarrow> 'b::linorder"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   449
  assumes "mono f" "bij f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   450
  shows "mono (inv f)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   451
proof
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   452
  fix x y::'b assume "x \<le> y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   453
  then show "inv f x \<le> inv f y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   454
    by (metis (no_types, lifting) assms bij_is_surj eq_iff le_cases mono_def surj_f_inv_f)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   455
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   456
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   457
lemma mono_bij_Inf:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   458
  fixes f :: "'a::complete_linorder \<Rightarrow> 'b::complete_linorder"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   459
  assumes "mono f" "bij f"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   460
  shows "f (Inf A) = Inf (f`A)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   461
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   462
  have "(inv f) (Inf (f`A)) \<le> Inf ((inv f)`(f`A))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   463
    using mono_Inf[OF mono_inv[OF assms], of "f`A"] by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   464
  then have "Inf (f`A) \<le> f (Inf ((inv f)`(f`A)))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   465
    by (metis (no_types, lifting) assms mono_def bij_inv_eq_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   466
  also have "... = f(Inf A)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   467
    using assms by (simp add: bij_is_inj)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   468
  finally show ?thesis using mono_Inf[OF assms(1), of A] by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   469
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   470
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   471
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   472
lemma Inf_nat_def1:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   473
  fixes K::"nat set"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   474
  assumes "K \<noteq> {}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   475
  shows "Inf K \<in> K"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   476
by (auto simp add: Min_def Inf_nat_def) (meson LeastI assms bot.extremum_unique subsetI)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   477
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   478
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   479
subsection \<open>Extended-Real.thy\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   480
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   481
text\<open>The proof of this one is copied from \verb+ereal_add_mono+.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   482
lemma ereal_add_strict_mono2:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   483
  fixes a b c d :: ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   484
  assumes "a < b"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   485
    and "c < d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   486
  shows "a + c < b + d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   487
using assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   488
apply (cases a)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   489
apply (cases rule: ereal3_cases[of b c d], auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   490
apply (cases rule: ereal3_cases[of b c d], auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   491
done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   492
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   493
text \<open>The next ones are analogues of \verb+mult_mono+ and \verb+mult_mono'+ in ereal.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   494
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   495
lemma ereal_mult_mono:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   496
  fixes a b c d::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   497
  assumes "b \<ge> 0" "c \<ge> 0" "a \<le> b" "c \<le> d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   498
  shows "a * c \<le> b * d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   499
by (metis ereal_mult_right_mono mult.commute order_trans assms)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   500
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   501
lemma ereal_mult_mono':
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   502
  fixes a b c d::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   503
  assumes "a \<ge> 0" "c \<ge> 0" "a \<le> b" "c \<le> d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   504
  shows "a * c \<le> b * d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   505
by (metis ereal_mult_right_mono mult.commute order_trans assms)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   506
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   507
lemma ereal_mult_mono_strict:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   508
  fixes a b c d::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   509
  assumes "b > 0" "c > 0" "a < b" "c < d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   510
  shows "a * c < b * d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   511
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   512
  have "c < \<infinity>" using \<open>c < d\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   513
  then have "a * c < b * c" by (metis ereal_mult_strict_left_mono[OF assms(3) assms(2)] mult.commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   514
  moreover have "b * c \<le> b * d" using assms(2) assms(4) by (simp add: assms(1) ereal_mult_left_mono less_imp_le)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   515
  ultimately show ?thesis by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   516
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   517
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   518
lemma ereal_mult_mono_strict':
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   519
  fixes a b c d::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   520
  assumes "a > 0" "c > 0" "a < b" "c < d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   521
  shows "a * c < b * d"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   522
apply (rule ereal_mult_mono_strict, auto simp add: assms) using assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   523
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   524
lemma ereal_abs_add:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   525
  fixes a b::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   526
  shows "abs(a+b) \<le> abs a + abs b"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   527
by (cases rule: ereal2_cases[of a b]) (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   528
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   529
lemma ereal_abs_diff:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   530
  fixes a b::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   531
  shows "abs(a-b) \<le> abs a + abs b"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   532
by (cases rule: ereal2_cases[of a b]) (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   533
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   534
lemma sum_constant_ereal:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   535
  fixes a::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   536
  shows "(\<Sum>i\<in>I. a) = a * card I"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   537
apply (cases "finite I", induct set: finite, simp_all)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   538
apply (cases a, auto, metis (no_types, hide_lams) add.commute mult.commute semiring_normalization_rules(3))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   539
done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   540
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   541
lemma real_lim_then_eventually_real:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   542
  assumes "(u \<longlongrightarrow> ereal l) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   543
  shows "eventually (\<lambda>n. u n = ereal(real_of_ereal(u n))) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   544
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   545
  have "ereal l \<in> {-\<infinity><..<(\<infinity>::ereal)}" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   546
  moreover have "open {-\<infinity><..<(\<infinity>::ereal)}" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   547
  ultimately have "eventually (\<lambda>n. u n \<in> {-\<infinity><..<(\<infinity>::ereal)}) F" using assms tendsto_def by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   548
  moreover have "\<And>x. x \<in> {-\<infinity><..<(\<infinity>::ereal)} \<Longrightarrow> x = ereal(real_of_ereal x)" using ereal_real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   549
  ultimately show ?thesis by (metis (mono_tags, lifting) eventually_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   550
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   551
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   552
lemma ereal_Inf_cmult:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   553
  assumes "c>(0::real)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   554
  shows "Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   555
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   556
  have "(\<lambda>x::ereal. c * x) (Inf {x::ereal. P x}) = Inf ((\<lambda>x::ereal. c * x)`{x::ereal. P x})"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   557
    apply (rule mono_bij_Inf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   558
    apply (simp add: assms ereal_mult_left_mono less_imp_le mono_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   559
    apply (rule bij_betw_byWitness[of _ "\<lambda>x. (x::ereal) / c"], auto simp add: assms ereal_mult_divide)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   560
    using assms ereal_divide_eq apply auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   561
    done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   562
  then show ?thesis by (simp only: setcompr_eq_image[symmetric])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   563
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   564
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   565
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   566
subsubsection \<open>Continuity of addition\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   567
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   568
text \<open>The next few lemmas remove an unnecessary assumption in \verb+tendsto_add_ereal+, culminating
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   569
in \verb+tendsto_add_ereal_general+ which essentially says that the addition
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   570
is continuous on ereal times ereal, except at $(-\infty, \infty)$ and $(\infty, -\infty)$.
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   571
It is much more convenient in many situations, see for instance the proof of
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   572
\verb+tendsto_sum_ereal+ below.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   573
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   574
lemma tendsto_add_ereal_PInf:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   575
  fixes y :: ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   576
  assumes y: "y \<noteq> -\<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   577
  assumes f: "(f \<longlongrightarrow> \<infinity>) F" and g: "(g \<longlongrightarrow> y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   578
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> \<infinity>) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   579
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   580
  have "\<exists>C. eventually (\<lambda>x. g x > ereal C) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   581
  proof (cases y)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   582
    case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   583
    have "y > y-1" using y real by (simp add: ereal_between(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   584
    then have "eventually (\<lambda>x. g x > y - 1) F" using g y order_tendsto_iff by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   585
    moreover have "y-1 = ereal(real_of_ereal(y-1))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   586
      by (metis real ereal_eq_1(1) ereal_minus(1) real_of_ereal.simps(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   587
    ultimately have "eventually (\<lambda>x. g x > ereal(real_of_ereal(y - 1))) F" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   588
    then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   589
  next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   590
    case (PInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   591
    have "eventually (\<lambda>x. g x > ereal 0) F" using g PInf by (simp add: tendsto_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   592
    then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   593
  qed (simp add: y)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   594
  then obtain C::real where ge: "eventually (\<lambda>x. g x > ereal C) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   595
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   596
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   597
    fix M::real
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   598
    have "eventually (\<lambda>x. f x > ereal(M - C)) F" using f by (simp add: tendsto_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   599
    then have "eventually (\<lambda>x. (f x > ereal (M-C)) \<and> (g x > ereal C)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   600
      by (auto simp add: ge eventually_conj_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   601
    moreover have "\<And>x. ((f x > ereal (M-C)) \<and> (g x > ereal C)) \<Longrightarrow> (f x + g x > ereal M)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   602
      using ereal_add_strict_mono2 by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   603
    ultimately have "eventually (\<lambda>x. f x + g x > ereal M) F" using eventually_mono by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   604
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   605
  then show ?thesis by (simp add: tendsto_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   606
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   607
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   608
text\<open>One would like to deduce the next lemma from the previous one, but the fact
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   609
that $-(x+y)$ is in general different from $(-x) + (-y)$ in ereal creates difficulties,
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   610
so it is more efficient to copy the previous proof.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   611
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   612
lemma tendsto_add_ereal_MInf:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   613
  fixes y :: ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   614
  assumes y: "y \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   615
  assumes f: "(f \<longlongrightarrow> -\<infinity>) F" and g: "(g \<longlongrightarrow> y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   616
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> -\<infinity>) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   617
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   618
  have "\<exists>C. eventually (\<lambda>x. g x < ereal C) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   619
  proof (cases y)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   620
    case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   621
    have "y < y+1" using y real by (simp add: ereal_between(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   622
    then have "eventually (\<lambda>x. g x < y + 1) F" using g y order_tendsto_iff by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   623
    moreover have "y+1 = ereal(real_of_ereal (y+1))" by (simp add: real)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   624
    ultimately have "eventually (\<lambda>x. g x < ereal(real_of_ereal(y + 1))) F" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   625
    then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   626
  next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   627
    case (MInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   628
    have "eventually (\<lambda>x. g x < ereal 0) F" using g MInf by (simp add: tendsto_MInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   629
    then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   630
  qed (simp add: y)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   631
  then obtain C::real where ge: "eventually (\<lambda>x. g x < ereal C) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   632
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   633
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   634
    fix M::real
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   635
    have "eventually (\<lambda>x. f x < ereal(M - C)) F" using f by (simp add: tendsto_MInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   636
    then have "eventually (\<lambda>x. (f x < ereal (M- C)) \<and> (g x < ereal C)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   637
      by (auto simp add: ge eventually_conj_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   638
    moreover have "\<And>x. ((f x < ereal (M-C)) \<and> (g x < ereal C)) \<Longrightarrow> (f x + g x < ereal M)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   639
      using ereal_add_strict_mono2 by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   640
    ultimately have "eventually (\<lambda>x. f x + g x < ereal M) F" using eventually_mono by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   641
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   642
  then show ?thesis by (simp add: tendsto_MInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   643
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   644
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   645
lemma tendsto_add_ereal_general1:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   646
  fixes x y :: ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   647
  assumes y: "\<bar>y\<bar> \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   648
  assumes f: "(f \<longlongrightarrow> x) F" and g: "(g \<longlongrightarrow> y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   649
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> x + y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   650
proof (cases x)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   651
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   652
  have a: "\<bar>x\<bar> \<noteq> \<infinity>" by (simp add: real)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   653
  show ?thesis by (rule tendsto_add_ereal[OF a, OF y, OF f, OF g])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   654
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   655
  case PInf
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   656
  then show ?thesis using tendsto_add_ereal_PInf assms by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   657
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   658
  case MInf
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   659
  then show ?thesis using tendsto_add_ereal_MInf assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   660
    by (metis abs_ereal.simps(3) ereal_MInfty_eq_plus)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   661
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   662
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   663
lemma tendsto_add_ereal_general2:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   664
  fixes x y :: ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   665
  assumes x: "\<bar>x\<bar> \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   666
      and f: "(f \<longlongrightarrow> x) F" and g: "(g \<longlongrightarrow> y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   667
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> x + y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   668
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   669
  have "((\<lambda>x. g x + f x) \<longlongrightarrow> x + y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   670
    using tendsto_add_ereal_general1[OF x, OF g, OF f] add.commute[of "y", of "x"] by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   671
  moreover have "\<And>x. g x + f x = f x + g x" using add.commute by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   672
  ultimately show ?thesis by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   673
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   674
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   675
text \<open>The next lemma says that the addition is continuous on ereal, except at
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   676
the pairs $(-\infty, \infty)$ and $(\infty, -\infty)$.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   677
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   678
lemma tendsto_add_ereal_general [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   679
  fixes x y :: ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   680
  assumes "\<not>((x=\<infinity> \<and> y=-\<infinity>) \<or> (x=-\<infinity> \<and> y=\<infinity>))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   681
      and f: "(f \<longlongrightarrow> x) F" and g: "(g \<longlongrightarrow> y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   682
  shows "((\<lambda>x. f x + g x) \<longlongrightarrow> x + y) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   683
proof (cases x)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   684
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   685
  show ?thesis
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   686
    apply (rule tendsto_add_ereal_general2) using real assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   687
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   688
  case (PInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   689
  then have "y \<noteq> -\<infinity>" using assms by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   690
  then show ?thesis using tendsto_add_ereal_PInf PInf assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   691
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   692
  case (MInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   693
  then have "y \<noteq> \<infinity>" using assms by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   694
  then show ?thesis using tendsto_add_ereal_MInf MInf f g by (metis ereal_MInfty_eq_plus)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   695
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   696
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   697
subsubsection \<open>Continuity of multiplication\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   698
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   699
text \<open>In the same way as for addition, we prove that the multiplication is continuous on
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   700
ereal times ereal, except at $(\infty, 0)$ and $(-\infty, 0)$ and $(0, \infty)$ and $(0, -\infty)$,
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   701
starting with specific situations.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   702
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   703
lemma tendsto_mult_real_ereal:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   704
  assumes "(u \<longlongrightarrow> ereal l) F" "(v \<longlongrightarrow> ereal m) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   705
  shows "((\<lambda>n. u n * v n) \<longlongrightarrow> ereal l * ereal m) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   706
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   707
  have ureal: "eventually (\<lambda>n. u n = ereal(real_of_ereal(u n))) F" by (rule real_lim_then_eventually_real[OF assms(1)])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   708
  then have "((\<lambda>n. ereal(real_of_ereal(u n))) \<longlongrightarrow> ereal l) F" using assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   709
  then have limu: "((\<lambda>n. real_of_ereal(u n)) \<longlongrightarrow> l) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   710
  have vreal: "eventually (\<lambda>n. v n = ereal(real_of_ereal(v n))) F" by (rule real_lim_then_eventually_real[OF assms(2)])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   711
  then have "((\<lambda>n. ereal(real_of_ereal(v n))) \<longlongrightarrow> ereal m) F" using assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   712
  then have limv: "((\<lambda>n. real_of_ereal(v n)) \<longlongrightarrow> m) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   713
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   714
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   715
    fix n assume "u n = ereal(real_of_ereal(u n))" "v n = ereal(real_of_ereal(v n))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   716
    then have "ereal(real_of_ereal(u n) * real_of_ereal(v n)) = u n * v n" by (metis times_ereal.simps(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   717
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   718
  then have *: "eventually (\<lambda>n. ereal(real_of_ereal(u n) * real_of_ereal(v n)) = u n * v n) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   719
    using eventually_elim2[OF ureal vreal] by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   720
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   721
  have "((\<lambda>n. real_of_ereal(u n) * real_of_ereal(v n)) \<longlongrightarrow> l * m) F" using tendsto_mult[OF limu limv] by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   722
  then have "((\<lambda>n. ereal(real_of_ereal(u n)) * real_of_ereal(v n)) \<longlongrightarrow> ereal(l * m)) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   723
  then show ?thesis using * filterlim_cong by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   724
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   725
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   726
lemma tendsto_mult_ereal_PInf:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   727
  fixes f g::"_ \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   728
  assumes "(f \<longlongrightarrow> l) F" "l>0" "(g \<longlongrightarrow> \<infinity>) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   729
  shows "((\<lambda>x. f x * g x) \<longlongrightarrow> \<infinity>) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   730
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   731
  obtain a::real where "0 < ereal a" "a < l" using assms(2) using ereal_dense2 by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   732
  have *: "eventually (\<lambda>x. f x > a) F" using \<open>a < l\<close> assms(1) by (simp add: order_tendsto_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   733
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   734
    fix K::real
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   735
    define M where "M = max K 1"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   736
    then have "M > 0" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   737
    then have "ereal(M/a) > 0" using \<open>ereal a > 0\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   738
    then have "\<And>x. ((f x > a) \<and> (g x > M/a)) \<Longrightarrow> (f x * g x > ereal a * ereal(M/a))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   739
      using ereal_mult_mono_strict'[where ?c = "M/a", OF \<open>0 < ereal a\<close>] by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   740
    moreover have "ereal a * ereal(M/a) = M" using \<open>ereal a > 0\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   741
    ultimately have "\<And>x. ((f x > a) \<and> (g x > M/a)) \<Longrightarrow> (f x * g x > M)" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   742
    moreover have "M \<ge> K" unfolding M_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   743
    ultimately have Imp: "\<And>x. ((f x > a) \<and> (g x > M/a)) \<Longrightarrow> (f x * g x > K)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   744
      using ereal_less_eq(3) le_less_trans by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   745
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   746
    have "eventually (\<lambda>x. g x > M/a) F" using assms(3) by (simp add: tendsto_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   747
    then have "eventually (\<lambda>x. (f x > a) \<and> (g x > M/a)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   748
      using * by (auto simp add: eventually_conj_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   749
    then have "eventually (\<lambda>x. f x * g x > K) F" using eventually_mono Imp by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   750
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   751
  then show ?thesis by (auto simp add: tendsto_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   752
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   753
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   754
lemma tendsto_mult_ereal_pos:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   755
  fixes f g::"_ \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   756
  assumes "(f \<longlongrightarrow> l) F" "(g \<longlongrightarrow> m) F" "l>0" "m>0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   757
  shows "((\<lambda>x. f x * g x) \<longlongrightarrow> l * m) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   758
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   759
  assume *: "l = \<infinity> \<or> m = \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   760
  then show ?thesis
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   761
  proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   762
    assume "m = \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   763
    then show ?thesis using tendsto_mult_ereal_PInf assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   764
  next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   765
    assume "\<not>(m = \<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   766
    then have "l = \<infinity>" using * by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   767
    then have "((\<lambda>x. g x * f x) \<longlongrightarrow> l * m) F" using tendsto_mult_ereal_PInf assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   768
    moreover have "\<And>x. g x * f x = f x * g x" using mult.commute by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   769
    ultimately show ?thesis by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   770
  qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   771
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   772
  assume "\<not>(l = \<infinity> \<or> m = \<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   773
  then have "l < \<infinity>" "m < \<infinity>" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   774
  then obtain lr mr where "l = ereal lr" "m = ereal mr"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   775
    using \<open>l>0\<close> \<open>m>0\<close> by (metis ereal_cases ereal_less(6) not_less_iff_gr_or_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   776
  then show ?thesis using tendsto_mult_real_ereal assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   777
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   778
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   779
text \<open>We reduce the general situation to the positive case by multiplying by suitable signs.
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   780
Unfortunately, as ereal is not a ring, all the neat sign lemmas are not available there. We
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   781
give the bare minimum we need.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   782
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   783
lemma ereal_sgn_abs:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   784
  fixes l::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   785
  shows "sgn(l) * l = abs(l)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   786
apply (cases l) by (auto simp add: sgn_if ereal_less_uminus_reorder)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   787
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   788
lemma sgn_squared_ereal:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   789
  assumes "l \<noteq> (0::ereal)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   790
  shows "sgn(l) * sgn(l) = 1"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   791
apply (cases l) using assms by (auto simp add: one_ereal_def sgn_if)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   792
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   793
lemma tendsto_mult_ereal [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   794
  fixes f g::"_ \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   795
  assumes "(f \<longlongrightarrow> l) F" "(g \<longlongrightarrow> m) F" "\<not>((l=0 \<and> abs(m) = \<infinity>) \<or> (m=0 \<and> abs(l) = \<infinity>))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   796
  shows "((\<lambda>x. f x * g x) \<longlongrightarrow> l * m) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   797
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   798
  assume "l=0 \<or> m=0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   799
  then have "abs(l) \<noteq> \<infinity>" "abs(m) \<noteq> \<infinity>" using assms(3) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   800
  then obtain lr mr where "l = ereal lr" "m = ereal mr" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   801
  then show ?thesis using tendsto_mult_real_ereal assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   802
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   803
  have sgn_finite: "\<And>a::ereal. abs(sgn a) \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   804
    by (metis MInfty_neq_ereal(2) PInfty_neq_ereal(2) abs_eq_infinity_cases ereal_times(1) ereal_times(3) ereal_uminus_eq_reorder sgn_ereal.elims)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   805
  then have sgn_finite2: "\<And>a b::ereal. abs(sgn a * sgn b) \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   806
    by (metis abs_eq_infinity_cases abs_ereal.simps(2) abs_ereal.simps(3) ereal_mult_eq_MInfty ereal_mult_eq_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   807
  assume "\<not>(l=0 \<or> m=0)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   808
  then have "l \<noteq> 0" "m \<noteq> 0" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   809
  then have "abs(l) > 0" "abs(m) > 0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   810
    by (metis abs_ereal_ge0 abs_ereal_less0 abs_ereal_pos ereal_uminus_uminus ereal_uminus_zero less_le not_less)+
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   811
  then have "sgn(l) * l > 0" "sgn(m) * m > 0" using ereal_sgn_abs by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   812
  moreover have "((\<lambda>x. sgn(l) * f x) \<longlongrightarrow> (sgn(l) * l)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   813
    by (rule tendsto_cmult_ereal, auto simp add: sgn_finite assms(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   814
  moreover have "((\<lambda>x. sgn(m) * g x) \<longlongrightarrow> (sgn(m) * m)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   815
    by (rule tendsto_cmult_ereal, auto simp add: sgn_finite assms(2))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   816
  ultimately have *: "((\<lambda>x. (sgn(l) * f x) * (sgn(m) * g x)) \<longlongrightarrow> (sgn(l) * l) * (sgn(m) * m)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   817
    using tendsto_mult_ereal_pos by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   818
  have "((\<lambda>x. (sgn(l) * sgn(m)) * ((sgn(l) * f x) * (sgn(m) * g x))) \<longlongrightarrow> (sgn(l) * sgn(m)) * ((sgn(l) * l) * (sgn(m) * m))) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   819
    by (rule tendsto_cmult_ereal, auto simp add: sgn_finite2 *)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   820
  moreover have "\<And>x. (sgn(l) * sgn(m)) * ((sgn(l) * f x) * (sgn(m) * g x)) = f x * g x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   821
    by (metis mult.left_neutral sgn_squared_ereal[OF \<open>l \<noteq> 0\<close>] sgn_squared_ereal[OF \<open>m \<noteq> 0\<close>] mult.assoc mult.commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   822
  moreover have "(sgn(l) * sgn(m)) * ((sgn(l) * l) * (sgn(m) * m)) = l * m"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   823
    by (metis mult.left_neutral sgn_squared_ereal[OF \<open>l \<noteq> 0\<close>] sgn_squared_ereal[OF \<open>m \<noteq> 0\<close>] mult.assoc mult.commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   824
  ultimately show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   825
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   826
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   827
lemma tendsto_cmult_ereal_general [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   828
  fixes f::"_ \<Rightarrow> ereal" and c::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   829
  assumes "(f \<longlongrightarrow> l) F" "\<not> (l=0 \<and> abs(c) = \<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   830
  shows "((\<lambda>x. c * f x) \<longlongrightarrow> c * l) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   831
by (cases "c = 0", auto simp add: assms tendsto_mult_ereal)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   832
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   833
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   834
subsubsection \<open>Continuity of division\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   835
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   836
lemma tendsto_inverse_ereal_PInf:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   837
  fixes u::"_ \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   838
  assumes "(u \<longlongrightarrow> \<infinity>) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   839
  shows "((\<lambda>x. 1/ u x) \<longlongrightarrow> 0) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   840
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   841
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   842
    fix e::real assume "e>0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   843
    have "1/e < \<infinity>" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   844
    then have "eventually (\<lambda>n. u n > 1/e) F" using assms(1) by (simp add: tendsto_PInfty)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   845
    moreover
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   846
    {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   847
      fix z::ereal assume "z>1/e"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   848
      then have "z>0" using \<open>e>0\<close> using less_le_trans not_le by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   849
      then have "1/z \<ge> 0" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   850
      moreover have "1/z < e" using \<open>e>0\<close> \<open>z>1/e\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   851
        apply (cases z) apply auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   852
        by (metis (mono_tags, hide_lams) less_ereal.simps(2) less_ereal.simps(4) divide_less_eq ereal_divide_less_pos ereal_less(4)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   853
            ereal_less_eq(4) less_le_trans mult_eq_0_iff not_le not_one_less_zero times_ereal.simps(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   854
      ultimately have "1/z \<ge> 0" "1/z < e" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   855
    }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   856
    ultimately have "eventually (\<lambda>n. 1/u n<e) F" "eventually (\<lambda>n. 1/u n\<ge>0) F" by (auto simp add: eventually_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   857
  } note * = this
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   858
  show ?thesis
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   859
  proof (subst order_tendsto_iff, auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   860
    fix a::ereal assume "a<0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   861
    then show "eventually (\<lambda>n. 1/u n > a) F" using *(2) eventually_mono less_le_trans linordered_field_no_ub by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   862
  next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   863
    fix a::ereal assume "a>0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   864
    then obtain e::real where "e>0" "a>e" using ereal_dense2 ereal_less(2) by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   865
    then have "eventually (\<lambda>n. 1/u n < e) F" using *(1) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   866
    then show "eventually (\<lambda>n. 1/u n < a) F" using \<open>a>e\<close> by (metis (mono_tags, lifting) eventually_mono less_trans)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   867
  qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   868
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   869
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   870
text \<open>The next lemma deserves to exist by itself, as it is so common and useful.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   871
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   872
lemma tendsto_inverse_real [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   873
  fixes u::"_ \<Rightarrow> real"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   874
  shows "(u \<longlongrightarrow> l) F \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> ((\<lambda>x. 1/ u x) \<longlongrightarrow> 1/l) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   875
  using tendsto_inverse unfolding inverse_eq_divide .
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   876
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   877
lemma tendsto_inverse_ereal [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   878
  fixes u::"_ \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   879
  assumes "(u \<longlongrightarrow> l) F" "l \<noteq> 0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   880
  shows "((\<lambda>x. 1/ u x) \<longlongrightarrow> 1/l) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   881
proof (cases l)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   882
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   883
  then have "r \<noteq> 0" using assms(2) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   884
  then have "1/l = ereal(1/r)" using real by (simp add: one_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   885
  define v where "v = (\<lambda>n. real_of_ereal(u n))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   886
  have ureal: "eventually (\<lambda>n. u n = ereal(v n)) F" unfolding v_def using real_lim_then_eventually_real assms(1) real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   887
  then have "((\<lambda>n. ereal(v n)) \<longlongrightarrow> ereal r) F" using assms real v_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   888
  then have *: "((\<lambda>n. v n) \<longlongrightarrow> r) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   889
  then have "((\<lambda>n. 1/v n) \<longlongrightarrow> 1/r) F" using \<open>r \<noteq> 0\<close> tendsto_inverse_real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   890
  then have lim: "((\<lambda>n. ereal(1/v n)) \<longlongrightarrow> 1/l) F" using \<open>1/l = ereal(1/r)\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   891
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   892
  have "r \<in> -{0}" "open (-{(0::real)})" using \<open>r \<noteq> 0\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   893
  then have "eventually (\<lambda>n. v n \<in> -{0}) F" using * using topological_tendstoD by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   894
  then have "eventually (\<lambda>n. v n \<noteq> 0) F" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   895
  moreover
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   896
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   897
    fix n assume H: "v n \<noteq> 0" "u n = ereal(v n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   898
    then have "ereal(1/v n) = 1/ereal(v n)" by (simp add: one_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   899
    then have "ereal(1/v n) = 1/u n" using H(2) by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   900
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   901
  ultimately have "eventually (\<lambda>n. ereal(1/v n) = 1/u n) F" using ureal eventually_elim2 by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   902
  with Lim_transform_eventually[OF this lim] show ?thesis by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   903
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   904
  case (PInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   905
  then have "1/l = 0" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   906
  then show ?thesis using tendsto_inverse_ereal_PInf assms PInf by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   907
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   908
  case (MInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   909
  then have "1/l = 0" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   910
  have "1/z = -1/ -z" if "z < 0" for z::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   911
    apply (cases z) using divide_ereal_def \<open> z < 0 \<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   912
  moreover have "eventually (\<lambda>n. u n < 0) F" by (metis (no_types) MInf assms(1) tendsto_MInfty zero_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   913
  ultimately have *: "eventually (\<lambda>n. -1/-u n = 1/u n) F" by (simp add: eventually_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   914
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   915
  define v where "v = (\<lambda>n. - u n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   916
  have "(v \<longlongrightarrow> \<infinity>) F" unfolding v_def using MInf assms(1) tendsto_uminus_ereal by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   917
  then have "((\<lambda>n. 1/v n) \<longlongrightarrow> 0) F" using tendsto_inverse_ereal_PInf by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   918
  then have "((\<lambda>n. -1/v n) \<longlongrightarrow> 0) F" using tendsto_uminus_ereal by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   919
  then show ?thesis unfolding v_def using Lim_transform_eventually[OF *] \<open> 1/l = 0 \<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   920
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   921
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   922
lemma tendsto_divide_ereal [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   923
  fixes f g::"_ \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   924
  assumes "(f \<longlongrightarrow> l) F" "(g \<longlongrightarrow> m) F" "m \<noteq> 0" "\<not>(abs(l) = \<infinity> \<and> abs(m) = \<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   925
  shows "((\<lambda>x. f x / g x) \<longlongrightarrow> l / m) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   926
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   927
  define h where "h = (\<lambda>x. 1/ g x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   928
  have *: "(h \<longlongrightarrow> 1/m) F" unfolding h_def using assms(2) assms(3) tendsto_inverse_ereal by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   929
  have "((\<lambda>x. f x * h x) \<longlongrightarrow> l * (1/m)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   930
    apply (rule tendsto_mult_ereal[OF assms(1) *]) using assms(3) assms(4) by (auto simp add: divide_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   931
  moreover have "f x * h x = f x / g x" for x unfolding h_def by (simp add: divide_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   932
  moreover have "l * (1/m) = l/m" by (simp add: divide_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   933
  ultimately show ?thesis unfolding h_def using Lim_transform_eventually by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   934
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   935
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   936
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   937
subsubsection \<open>Further limits\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   938
67727
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   939
text \<open>The assumptions of @{thm tendsto_diff_ereal} are too strong, we weaken them here.\<close>
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   940
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   941
lemma tendsto_diff_ereal_general [tendsto_intros]:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   942
  fixes u v::"'a \<Rightarrow> ereal"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   943
  assumes "(u \<longlongrightarrow> l) F" "(v \<longlongrightarrow> m) F" "\<not>((l = \<infinity> \<and> m = \<infinity>) \<or> (l = -\<infinity> \<and> m = -\<infinity>))"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   944
  shows "((\<lambda>n. u n - v n) \<longlongrightarrow> l - m) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   945
proof -
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   946
  have "((\<lambda>n. u n + (-v n)) \<longlongrightarrow> l + (-m)) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   947
    apply (intro tendsto_intros assms) using assms by (auto simp add: ereal_uminus_eq_reorder)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   948
  then show ?thesis by (simp add: minus_ereal_def)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   949
qed
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
   950
66456
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   951
lemma id_nat_ereal_tendsto_PInf [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   952
  "(\<lambda> n::nat. real n) \<longlonglongrightarrow> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   953
by (simp add: filterlim_real_sequentially tendsto_PInfty_eq_at_top)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   954
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   955
lemma tendsto_at_top_pseudo_inverse [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   956
  fixes u::"nat \<Rightarrow> nat"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   957
  assumes "LIM n sequentially. u n :> at_top"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   958
  shows "LIM n sequentially. Inf {N. u N \<ge> n} :> at_top"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   959
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   960
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   961
    fix C::nat
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   962
    define M where "M = Max {u n| n. n \<le> C}+1"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   963
    {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   964
      fix n assume "n \<ge> M"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   965
      have "eventually (\<lambda>N. u N \<ge> n) sequentially" using assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   966
        by (simp add: filterlim_at_top)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   967
      then have *: "{N. u N \<ge> n} \<noteq> {}" by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   968
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   969
      have "N > C" if "u N \<ge> n" for N
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   970
      proof (rule ccontr)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   971
        assume "\<not>(N > C)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   972
        have "u N \<le> Max {u n| n. n \<le> C}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   973
          apply (rule Max_ge) using \<open>\<not>(N > C)\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   974
        then show False using \<open>u N \<ge> n\<close> \<open>n \<ge> M\<close> unfolding M_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   975
      qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   976
      then have **: "{N. u N \<ge> n} \<subseteq> {C..}" by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   977
      have "Inf {N. u N \<ge> n} \<ge> C"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   978
        by (metis "*" "**" Inf_nat_def1 atLeast_iff subset_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   979
    }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   980
    then have "eventually (\<lambda>n. Inf {N. u N \<ge> n} \<ge> C) sequentially"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   981
      using eventually_sequentially by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   982
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   983
  then show ?thesis using filterlim_at_top by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   984
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   985
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   986
lemma pseudo_inverse_finite_set:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   987
  fixes u::"nat \<Rightarrow> nat"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   988
  assumes "LIM n sequentially. u n :> at_top"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   989
  shows "finite {N. u N \<le> n}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   990
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   991
  fix n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   992
  have "eventually (\<lambda>N. u N \<ge> n+1) sequentially" using assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   993
    by (simp add: filterlim_at_top)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   994
  then obtain N1 where N1: "\<And>N. N \<ge> N1 \<Longrightarrow> u N \<ge> n + 1"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   995
    using eventually_sequentially by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   996
  have "{N. u N \<le> n} \<subseteq> {..<N1}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   997
    apply auto using N1 by (metis Suc_eq_plus1 not_less not_less_eq_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   998
  then show "finite {N. u N \<le> n}" by (simp add: finite_subset)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
   999
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1000
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1001
lemma tendsto_at_top_pseudo_inverse2 [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1002
  fixes u::"nat \<Rightarrow> nat"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1003
  assumes "LIM n sequentially. u n :> at_top"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1004
  shows "LIM n sequentially. Max {N. u N \<le> n} :> at_top"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1005
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1006
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1007
    fix N0::nat
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1008
    have "N0 \<le> Max {N. u N \<le> n}" if "n \<ge> u N0" for n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1009
      apply (rule Max.coboundedI) using pseudo_inverse_finite_set[OF assms] that by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1010
    then have "eventually (\<lambda>n. N0 \<le> Max {N. u N \<le> n}) sequentially"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1011
      using eventually_sequentially by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1012
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1013
  then show ?thesis using filterlim_at_top by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1014
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1015
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1016
lemma ereal_truncation_top [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1017
  fixes x::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1018
  shows "(\<lambda>n::nat. min x n) \<longlonglongrightarrow> x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1019
proof (cases x)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1020
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1021
  then obtain K::nat where "K>0" "K > abs(r)" using reals_Archimedean2 gr0I by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1022
  then have "min x n = x" if "n \<ge> K" for n apply (subst real, subst real, auto) using that eq_iff by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1023
  then have "eventually (\<lambda>n. min x n = x) sequentially" using eventually_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1024
  then show ?thesis by (simp add: Lim_eventually)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1025
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1026
  case (PInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1027
  then have "min x n = n" for n::nat by (auto simp add: min_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1028
  then show ?thesis using id_nat_ereal_tendsto_PInf PInf by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1029
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1030
  case (MInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1031
  then have "min x n = x" for n::nat by (auto simp add: min_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1032
  then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1033
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1034
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1035
lemma ereal_truncation_real_top [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1036
  fixes x::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1037
  assumes "x \<noteq> - \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1038
  shows "(\<lambda>n::nat. real_of_ereal(min x n)) \<longlonglongrightarrow> x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1039
proof (cases x)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1040
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1041
  then obtain K::nat where "K>0" "K > abs(r)" using reals_Archimedean2 gr0I by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1042
  then have "min x n = x" if "n \<ge> K" for n apply (subst real, subst real, auto) using that eq_iff by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1043
  then have "real_of_ereal(min x n) = r" if "n \<ge> K" for n using real that by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1044
  then have "eventually (\<lambda>n. real_of_ereal(min x n) = r) sequentially" using eventually_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1045
  then have "(\<lambda>n. real_of_ereal(min x n)) \<longlonglongrightarrow> r" by (simp add: Lim_eventually)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1046
  then show ?thesis using real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1047
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1048
  case (PInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1049
  then have "real_of_ereal(min x n) = n" for n::nat by (auto simp add: min_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1050
  then show ?thesis using id_nat_ereal_tendsto_PInf PInf by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1051
qed (simp add: assms)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1052
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1053
lemma ereal_truncation_bottom [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1054
  fixes x::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1055
  shows "(\<lambda>n::nat. max x (- real n)) \<longlonglongrightarrow> x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1056
proof (cases x)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1057
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1058
  then obtain K::nat where "K>0" "K > abs(r)" using reals_Archimedean2 gr0I by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1059
  then have "max x (-real n) = x" if "n \<ge> K" for n apply (subst real, subst real, auto) using that eq_iff by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1060
  then have "eventually (\<lambda>n. max x (-real n) = x) sequentially" using eventually_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1061
  then show ?thesis by (simp add: Lim_eventually)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1062
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1063
  case (MInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1064
  then have "max x (-real n) = (-1)* ereal(real n)" for n::nat by (auto simp add: max_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1065
  moreover have "(\<lambda>n. (-1)* ereal(real n)) \<longlonglongrightarrow> -\<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1066
    using tendsto_cmult_ereal[of "-1", OF _ id_nat_ereal_tendsto_PInf] by (simp add: one_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1067
  ultimately show ?thesis using MInf by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1068
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1069
  case (PInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1070
  then have "max x (-real n) = x" for n::nat by (auto simp add: max_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1071
  then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1072
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1073
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1074
lemma ereal_truncation_real_bottom [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1075
  fixes x::ereal
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1076
  assumes "x \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1077
  shows "(\<lambda>n::nat. real_of_ereal(max x (- real n))) \<longlonglongrightarrow> x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1078
proof (cases x)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1079
  case (real r)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1080
  then obtain K::nat where "K>0" "K > abs(r)" using reals_Archimedean2 gr0I by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1081
  then have "max x (-real n) = x" if "n \<ge> K" for n apply (subst real, subst real, auto) using that eq_iff by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1082
  then have "real_of_ereal(max x (-real n)) = r" if "n \<ge> K" for n using real that by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1083
  then have "eventually (\<lambda>n. real_of_ereal(max x (-real n)) = r) sequentially" using eventually_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1084
  then have "(\<lambda>n. real_of_ereal(max x (-real n))) \<longlonglongrightarrow> r" by (simp add: Lim_eventually)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1085
  then show ?thesis using real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1086
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1087
  case (MInf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1088
  then have "real_of_ereal(max x (-real n)) = (-1)* ereal(real n)" for n::nat by (auto simp add: max_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1089
  moreover have "(\<lambda>n. (-1)* ereal(real n)) \<longlonglongrightarrow> -\<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1090
    using tendsto_cmult_ereal[of "-1", OF _ id_nat_ereal_tendsto_PInf] by (simp add: one_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1091
  ultimately show ?thesis using MInf by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1092
qed (simp add: assms)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1093
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1094
text \<open>the next one is copied from \verb+tendsto_sum+.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1095
lemma tendsto_sum_ereal [tendsto_intros]:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1096
  fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1097
  assumes "\<And>i. i \<in> S \<Longrightarrow> (f i \<longlongrightarrow> a i) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1098
          "\<And>i. abs(a i) \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1099
  shows "((\<lambda>x. \<Sum>i\<in>S. f i x) \<longlongrightarrow> (\<Sum>i\<in>S. a i)) F"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1100
proof (cases "finite S")
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1101
  assume "finite S" then show ?thesis using assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1102
    by (induct, simp, simp add: tendsto_add_ereal_general2 assms)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1103
qed(simp)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1104
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1105
67727
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1106
lemma continuous_ereal_abs:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1107
  "continuous_on (UNIV::ereal set) abs"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1108
proof -
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1109
  have "continuous_on ({..0} \<union> {(0::ereal)..}) abs"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1110
    apply (rule continuous_on_closed_Un, auto)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1111
    apply (rule iffD1[OF continuous_on_cong, of "{..0}" _ "\<lambda>x. -x"])
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1112
    using less_eq_ereal_def apply (auto simp add: continuous_uminus_ereal)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1113
    apply (rule iffD1[OF continuous_on_cong, of "{0..}" _ "\<lambda>x. x"])
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1114
      apply (auto simp add: continuous_on_id)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1115
    done
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1116
  moreover have "(UNIV::ereal set) = {..0} \<union> {(0::ereal)..}" by auto
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1117
  ultimately show ?thesis by auto
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1118
qed
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1119
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1120
lemmas continuous_on_compose_ereal_abs[continuous_intros] =
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1121
  continuous_on_compose2[OF continuous_ereal_abs _ subset_UNIV]
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1122
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1123
lemma tendsto_abs_ereal [tendsto_intros]:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1124
  assumes "(u \<longlongrightarrow> (l::ereal)) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1125
  shows "((\<lambda>n. abs(u n)) \<longlongrightarrow> abs l) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1126
using continuous_ereal_abs assms by (metis UNIV_I continuous_on tendsto_compose)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1127
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1128
lemma ereal_minus_real_tendsto_MInf [tendsto_intros]:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1129
  "(\<lambda>x. ereal (- real x)) \<longlonglongrightarrow> - \<infinity>"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1130
by (subst uminus_ereal.simps(1)[symmetric], intro tendsto_intros)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1131
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1132
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1133
subsection \<open>Extended-Nonnegative-Real.thy\<close>
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1134
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1135
lemma tendsto_diff_ennreal_general [tendsto_intros]:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1136
  fixes u v::"'a \<Rightarrow> ennreal"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1137
  assumes "(u \<longlongrightarrow> l) F" "(v \<longlongrightarrow> m) F" "\<not>(l = \<infinity> \<and> m = \<infinity>)"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1138
  shows "((\<lambda>n. u n - v n) \<longlongrightarrow> l - m) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1139
proof -
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1140
  have "((\<lambda>n. e2ennreal(enn2ereal(u n) - enn2ereal(v n))) \<longlongrightarrow> e2ennreal(enn2ereal l - enn2ereal m)) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1141
    apply (intro tendsto_intros) using assms by  auto
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1142
  then show ?thesis by auto
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1143
qed
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1144
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1145
lemma tendsto_mult_ennreal [tendsto_intros]:
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1146
  fixes l m::ennreal
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1147
  assumes "(u \<longlongrightarrow> l) F" "(v \<longlongrightarrow> m) F" "\<not>((l = 0 \<and> m = \<infinity>) \<or> (l = \<infinity> \<and> m = 0))"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1148
  shows "((\<lambda>n. u n * v n) \<longlongrightarrow> l * m) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1149
proof -
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1150
  have "((\<lambda>n. e2ennreal(enn2ereal (u n) * enn2ereal (v n))) \<longlongrightarrow> e2ennreal(enn2ereal l * enn2ereal m)) F"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1151
    apply (intro tendsto_intros) using assms apply auto
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1152
    using enn2ereal_inject zero_ennreal.rep_eq by fastforce+
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1153
  moreover have "e2ennreal(enn2ereal (u n) * enn2ereal (v n)) = u n * v n" for n
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1154
    by (subst times_ennreal.abs_eq[symmetric], auto simp add: eq_onp_same_args)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1155
  moreover have "e2ennreal(enn2ereal l * enn2ereal m)  = l * m"
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1156
    by (subst times_ennreal.abs_eq[symmetric], auto simp add: eq_onp_same_args)
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1157
  ultimately show ?thesis
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1158
    by auto
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1159
qed
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1160
ce3e87a51488 moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
immler
parents: 67613
diff changeset
  1161
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
  1162
subsection \<open>monoset\<close>
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1163
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1164
definition (in order) mono_set:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1165
  "mono_set S \<longleftrightarrow> (\<forall>x y. x \<le> y \<longrightarrow> x \<in> S \<longrightarrow> y \<in> S)"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1166
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1167
lemma (in order) mono_greaterThan [intro, simp]: "mono_set {B<..}" unfolding mono_set by auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1168
lemma (in order) mono_atLeast [intro, simp]: "mono_set {B..}" unfolding mono_set by auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1169
lemma (in order) mono_UNIV [intro, simp]: "mono_set UNIV" unfolding mono_set by auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1170
lemma (in order) mono_empty [intro, simp]: "mono_set {}" unfolding mono_set by auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1171
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1172
lemma (in complete_linorder) mono_set_iff:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1173
  fixes S :: "'a set"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1174
  defines "a \<equiv> Inf S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1175
  shows "mono_set S \<longleftrightarrow> S = {a <..} \<or> S = {a..}" (is "_ = ?c")
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1176
proof
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1177
  assume "mono_set S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1178
  then have mono: "\<And>x y. x \<le> y \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1179
    by (auto simp: mono_set)
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1180
  show ?c
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1181
  proof cases
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1182
    assume "a \<in> S"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1183
    show ?c
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
  1184
      using mono[OF _ \<open>a \<in> S\<close>]
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1185
      by (auto intro: Inf_lower simp: a_def)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1186
  next
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1187
    assume "a \<notin> S"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1188
    have "S = {a <..}"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1189
    proof safe
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1190
      fix x assume "x \<in> S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1191
      then have "a \<le> x"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1192
        unfolding a_def by (rule Inf_lower)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1193
      then show "a < x"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
  1194
        using \<open>x \<in> S\<close> \<open>a \<notin> S\<close> by (cases "a = x") auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1195
    next
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1196
      fix x assume "a < x"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1197
      then obtain y where "y < x" "y \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1198
        unfolding a_def Inf_less_iff ..
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1199
      with mono[of y x] show "x \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1200
        by auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1201
    qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1202
    then show ?c ..
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1203
  qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1204
qed auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1205
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1206
lemma ereal_open_mono_set:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1207
  fixes S :: "ereal set"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1208
  shows "open S \<and> mono_set S \<longleftrightarrow> S = UNIV \<or> S = {Inf S <..}"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1209
  by (metis Inf_UNIV atLeast_eq_UNIV_iff ereal_open_atLeast
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1210
    ereal_open_closed mono_set_iff open_ereal_greaterThan)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1211
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1212
lemma ereal_closed_mono_set:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1213
  fixes S :: "ereal set"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1214
  shows "closed S \<and> mono_set S \<longleftrightarrow> S = {} \<or> S = {Inf S ..}"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1215
  by (metis Inf_UNIV atLeast_eq_UNIV_iff closed_ereal_atLeast
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1216
    ereal_open_closed mono_empty mono_set_iff open_ereal_greaterThan)
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1217
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1218
lemma ereal_Liminf_Sup_monoset:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1219
  fixes f :: "'a \<Rightarrow> ereal"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1220
  shows "Liminf net f =
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1221
    Sup {l. \<forall>S. open S \<longrightarrow> mono_set S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net}"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1222
    (is "_ = Sup ?A")
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1223
proof (safe intro!: Liminf_eqI complete_lattice_class.Sup_upper complete_lattice_class.Sup_least)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1224
  fix P
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1225
  assume P: "eventually P net"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1226
  fix S
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1227
  assume S: "mono_set S" "INFIMUM (Collect P) f \<in> S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1228
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1229
    fix x
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1230
    assume "P x"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1231
    then have "INFIMUM (Collect P) f \<le> f x"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1232
      by (intro complete_lattice_class.INF_lower) simp
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1233
    with S have "f x \<in> S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1234
      by (simp add: mono_set)
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1235
  }
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1236
  with P show "eventually (\<lambda>x. f x \<in> S) net"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  1237
    by (auto elim: eventually_mono)
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1238
next
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1239
  fix y l
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1240
  assume S: "\<forall>S. open S \<longrightarrow> mono_set S \<longrightarrow> l \<in> S \<longrightarrow> eventually  (\<lambda>x. f x \<in> S) net"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1241
  assume P: "\<forall>P. eventually P net \<longrightarrow> INFIMUM (Collect P) f \<le> y"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1242
  show "l \<le> y"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1243
  proof (rule dense_le)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1244
    fix B
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1245
    assume "B < l"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1246
    then have "eventually (\<lambda>x. f x \<in> {B <..}) net"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1247
      by (intro S[rule_format]) auto
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1248
    then have "INFIMUM {x. B < f x} f \<le> y"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1249
      using P by auto
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1250
    moreover have "B \<le> INFIMUM {x. B < f x} f"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1251
      by (intro INF_greatest) auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1252
    ultimately show "B \<le> y"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1253
      by simp
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1254
  qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1255
qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1256
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1257
lemma ereal_Limsup_Inf_monoset:
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1258
  fixes f :: "'a \<Rightarrow> ereal"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1259
  shows "Limsup net f =
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1260
    Inf {l. \<forall>S. open S \<longrightarrow> mono_set (uminus ` S) \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net}"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1261
    (is "_ = Inf ?A")
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1262
proof (safe intro!: Limsup_eqI complete_lattice_class.Inf_lower complete_lattice_class.Inf_greatest)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1263
  fix P
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1264
  assume P: "eventually P net"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1265
  fix S
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1266
  assume S: "mono_set (uminus`S)" "SUPREMUM (Collect P) f \<in> S"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1267
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1268
    fix x
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1269
    assume "P x"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1270
    then have "f x \<le> SUPREMUM (Collect P) f"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1271
      by (intro complete_lattice_class.SUP_upper) simp
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1272
    with S(1)[unfolded mono_set, rule_format, of "- SUPREMUM (Collect P) f" "- f x"] S(2)
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1273
    have "f x \<in> S"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1274
      by (simp add: inj_image_mem_iff) }
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1275
  with P show "eventually (\<lambda>x. f x \<in> S) net"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  1276
    by (auto elim: eventually_mono)
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1277
next
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1278
  fix y l
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1279
  assume S: "\<forall>S. open S \<longrightarrow> mono_set (uminus ` S) \<longrightarrow> l \<in> S \<longrightarrow> eventually  (\<lambda>x. f x \<in> S) net"
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1280
  assume P: "\<forall>P. eventually P net \<longrightarrow> y \<le> SUPREMUM (Collect P) f"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1281
  show "y \<le> l"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1282
  proof (rule dense_ge)
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1283
    fix B
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1284
    assume "l < B"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1285
    then have "eventually (\<lambda>x. f x \<in> {..< B}) net"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1286
      by (intro S[rule_format]) auto
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1287
    then have "y \<le> SUPREMUM {x. f x < B} f"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1288
      using P by auto
56218
1c3f1f2431f9 elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
haftmann
parents: 56212
diff changeset
  1289
    moreover have "SUPREMUM {x. f x < B} f \<le> B"
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1290
      by (intro SUP_least) auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1291
    ultimately show "y \<le> B"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1292
      by simp
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1293
  qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1294
qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1295
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1296
lemma liminf_bounded_open:
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1297
  fixes x :: "nat \<Rightarrow> ereal"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1298
  shows "x0 \<le> liminf x \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> mono_set S \<longrightarrow> x0 \<in> S \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. x n \<in> S))"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1299
  (is "_ \<longleftrightarrow> ?P x0")
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1300
proof
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1301
  assume "?P x0"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1302
  then show "x0 \<le> liminf x"
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1303
    unfolding ereal_Liminf_Sup_monoset eventually_sequentially
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1304
    by (intro complete_lattice_class.Sup_upper) auto
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1305
next
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1306
  assume "x0 \<le> liminf x"
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1307
  {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1308
    fix S :: "ereal set"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1309
    assume om: "open S" "mono_set S" "x0 \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1310
    {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1311
      assume "S = UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1312
      then have "\<exists>N. \<forall>n\<ge>N. x n \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1313
        by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1314
    }
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1315
    moreover
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1316
    {
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1317
      assume "S \<noteq> UNIV"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1318
      then obtain B where B: "S = {B<..}"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1319
        using om ereal_open_mono_set by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1320
      then have "B < x0"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1321
        using om by auto
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1322
      then have "\<exists>N. \<forall>n\<ge>N. x n \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1323
        unfolding B
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 59452
diff changeset
  1324
        using \<open>x0 \<le> liminf x\<close> liminf_bounded_iff
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1325
        by auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1326
    }
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1327
    ultimately have "\<exists>N. \<forall>n\<ge>N. x n \<in> S"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1328
      by auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1329
  }
53788
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1330
  then show "?P x0"
b319a0c8b8a2 tuned proofs;
wenzelm
parents: 53374
diff changeset
  1331
    by auto
51340
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1332
qed
5e6296afe08d move Liminf / Limsup lemmas on complete_lattices to its own file
hoelzl
parents: 51329
diff changeset
  1333
66456
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1334
lemma limsup_finite_then_bounded:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1335
  fixes u::"nat \<Rightarrow> real"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1336
  assumes "limsup u < \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1337
  shows "\<exists>C. \<forall>n. u n \<le> C"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1338
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1339
  obtain C where C: "limsup u < C" "C < \<infinity>" using assms ereal_dense2 by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1340
  then have "C = ereal(real_of_ereal C)" using ereal_real by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1341
  have "eventually (\<lambda>n. u n < C) sequentially" using C(1) unfolding Limsup_def
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1342
    apply (auto simp add: INF_less_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1343
    using SUP_lessD eventually_mono by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1344
  then obtain N where N: "\<And>n. n \<ge> N \<Longrightarrow> u n < C" using eventually_sequentially by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1345
  define D where "D = max (real_of_ereal C) (Max {u n |n. n \<le> N})"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1346
  have "\<And>n. u n \<le> D"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1347
  proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1348
    fix n show "u n \<le> D"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1349
    proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1350
      assume *: "n \<le> N"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1351
      have "u n \<le> Max {u n |n. n \<le> N}" by (rule Max_ge, auto simp add: *)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1352
      then show "u n \<le> D" unfolding D_def by linarith
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1353
    next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1354
      assume "\<not>(n \<le> N)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1355
      then have "n \<ge> N" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1356
      then have "u n < C" using N by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1357
      then have "u n < real_of_ereal C" using \<open>C = ereal(real_of_ereal C)\<close> less_ereal.simps(1) by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1358
      then show "u n \<le> D" unfolding D_def by linarith
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1359
    qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1360
  qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1361
  then show ?thesis by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1362
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1363
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1364
lemma liminf_finite_then_bounded_below:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1365
  fixes u::"nat \<Rightarrow> real"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1366
  assumes "liminf u > -\<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1367
  shows "\<exists>C. \<forall>n. u n \<ge> C"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1368
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1369
  obtain C where C: "liminf u > C" "C > -\<infinity>" using assms using ereal_dense2 by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1370
  then have "C = ereal(real_of_ereal C)" using ereal_real by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1371
  have "eventually (\<lambda>n. u n > C) sequentially" using C(1) unfolding Liminf_def
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1372
    apply (auto simp add: less_SUP_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1373
    using eventually_elim2 less_INF_D by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1374
  then obtain N where N: "\<And>n. n \<ge> N \<Longrightarrow> u n > C" using eventually_sequentially by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1375
  define D where "D = min (real_of_ereal C) (Min {u n |n. n \<le> N})"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1376
  have "\<And>n. u n \<ge> D"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1377
  proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1378
    fix n show "u n \<ge> D"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1379
    proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1380
      assume *: "n \<le> N"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1381
      have "u n \<ge> Min {u n |n. n \<le> N}" by (rule Min_le, auto simp add: *)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1382
      then show "u n \<ge> D" unfolding D_def by linarith
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1383
    next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1384
      assume "\<not>(n \<le> N)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1385
      then have "n \<ge> N" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1386
      then have "u n > C" using N by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1387
      then have "u n > real_of_ereal C" using \<open>C = ereal(real_of_ereal C)\<close> less_ereal.simps(1) by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1388
      then show "u n \<ge> D" unfolding D_def by linarith
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1389
    qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1390
  qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1391
  then show ?thesis by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1392
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1393
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1394
lemma liminf_upper_bound:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1395
  fixes u:: "nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1396
  assumes "liminf u < l"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1397
  shows "\<exists>N>k. u N < l"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1398
by (metis assms gt_ex less_le_trans liminf_bounded_iff not_less)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1399
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1400
lemma limsup_shift:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1401
  "limsup (\<lambda>n. u (n+1)) = limsup u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1402
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1403
  have "(SUP m:{n+1..}. u m) = (SUP m:{n..}. u (m + 1))" for n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1404
    apply (rule SUP_eq) using Suc_le_D by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1405
  then have a: "(INF n. SUP m:{n..}. u (m + 1)) = (INF n. (SUP m:{n+1..}. u m))" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1406
  have b: "(INF n. (SUP m:{n+1..}. u m)) = (INF n:{1..}. (SUP m:{n..}. u m))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1407
    apply (rule INF_eq) using Suc_le_D by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1408
  have "(INF n:{1..}. v n) = (INF n. v n)" if "decseq v" for v::"nat \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1409
    apply (rule INF_eq) using \<open>decseq v\<close> decseq_Suc_iff by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1410
  moreover have "decseq (\<lambda>n. (SUP m:{n..}. u m))" by (simp add: SUP_subset_mono decseq_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1411
  ultimately have c: "(INF n:{1..}. (SUP m:{n..}. u m)) = (INF n. (SUP m:{n..}. u m))" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1412
  have "(INF n. SUPREMUM {n..} u) = (INF n. SUP m:{n..}. u (m + 1))" using a b c by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1413
  then show ?thesis by (auto cong: limsup_INF_SUP)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1414
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1415
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1416
lemma limsup_shift_k:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1417
  "limsup (\<lambda>n. u (n+k)) = limsup u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1418
proof (induction k)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1419
  case (Suc k)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1420
  have "limsup (\<lambda>n. u (n+k+1)) = limsup (\<lambda>n. u (n+k))" using limsup_shift[where ?u="\<lambda>n. u(n+k)"] by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1421
  then show ?case using Suc.IH by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1422
qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1423
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1424
lemma liminf_shift:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1425
  "liminf (\<lambda>n. u (n+1)) = liminf u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1426
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1427
  have "(INF m:{n+1..}. u m) = (INF m:{n..}. u (m + 1))" for n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1428
    apply (rule INF_eq) using Suc_le_D by (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1429
  then have a: "(SUP n. INF m:{n..}. u (m + 1)) = (SUP n. (INF m:{n+1..}. u m))" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1430
  have b: "(SUP n. (INF m:{n+1..}. u m)) = (SUP n:{1..}. (INF m:{n..}. u m))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1431
    apply (rule SUP_eq) using Suc_le_D by (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1432
  have "(SUP n:{1..}. v n) = (SUP n. v n)" if "incseq v" for v::"nat \<Rightarrow> 'a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1433
    apply (rule SUP_eq) using \<open>incseq v\<close> incseq_Suc_iff by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1434
  moreover have "incseq (\<lambda>n. (INF m:{n..}. u m))" by (simp add: INF_superset_mono mono_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1435
  ultimately have c: "(SUP n:{1..}. (INF m:{n..}. u m)) = (SUP n. (INF m:{n..}. u m))" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1436
  have "(SUP n. INFIMUM {n..} u) = (SUP n. INF m:{n..}. u (m + 1))" using a b c by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1437
  then show ?thesis by (auto cong: liminf_SUP_INF)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1438
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1439
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1440
lemma liminf_shift_k:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1441
  "liminf (\<lambda>n. u (n+k)) = liminf u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1442
proof (induction k)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1443
  case (Suc k)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1444
  have "liminf (\<lambda>n. u (n+k+1)) = liminf (\<lambda>n. u (n+k))" using liminf_shift[where ?u="\<lambda>n. u(n+k)"] by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1445
  then show ?case using Suc.IH by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1446
qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1447
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1448
lemma Limsup_obtain:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1449
  fixes u::"_ \<Rightarrow> 'a :: complete_linorder"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1450
  assumes "Limsup F u > c"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1451
  shows "\<exists>i. u i > c"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1452
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1453
  have "(INF P:{P. eventually P F}. SUP x:{x. P x}. u x) > c" using assms by (simp add: Limsup_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1454
  then show ?thesis by (metis eventually_True mem_Collect_eq less_INF_D less_SUP_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1455
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1456
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1457
text \<open>The next lemma is extremely useful, as it often makes it possible to reduce statements
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1458
about limsups to statements about limits.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1459
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1460
lemma limsup_subseq_lim:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1461
  fixes u::"nat \<Rightarrow> 'a :: {complete_linorder, linorder_topology}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1462
  shows "\<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> (u o r) \<longlonglongrightarrow> limsup u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1463
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1464
  assume "\<forall>n. \<exists>p>n. \<forall>m\<ge>p. u m \<le> u p"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1465
  then have "\<exists>r. \<forall>n. (\<forall>m\<ge>r n. u m \<le> u (r n)) \<and> r n < r (Suc n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1466
    by (intro dependent_nat_choice) (auto simp: conj_commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1467
  then obtain r :: "nat \<Rightarrow> nat" where "strict_mono r" and mono: "\<And>n m. r n \<le> m \<Longrightarrow> u m \<le> u (r n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1468
    by (auto simp: strict_mono_Suc_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1469
  define umax where "umax = (\<lambda>n. (SUP m:{n..}. u m))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1470
  have "decseq umax" unfolding umax_def by (simp add: SUP_subset_mono antimono_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1471
  then have "umax \<longlonglongrightarrow> limsup u" unfolding umax_def by (metis LIMSEQ_INF limsup_INF_SUP)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1472
  then have *: "(umax o r) \<longlonglongrightarrow> limsup u" by (simp add: LIMSEQ_subseq_LIMSEQ \<open>strict_mono r\<close>)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1473
  have "\<And>n. umax(r n) = u(r n)" unfolding umax_def using mono
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1474
    by (metis SUP_le_iff antisym atLeast_def mem_Collect_eq order_refl)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1475
  then have "umax o r = u o r" unfolding o_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1476
  then have "(u o r) \<longlonglongrightarrow> limsup u" using * by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1477
  then show ?thesis using \<open>strict_mono r\<close> by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1478
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1479
  assume "\<not> (\<forall>n. \<exists>p>n. (\<forall>m\<ge>p. u m \<le> u p))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1480
  then obtain N where N: "\<And>p. p > N \<Longrightarrow> \<exists>m>p. u p < u m" by (force simp: not_le le_less)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1481
  have "\<exists>r. \<forall>n. N < r n \<and> r n < r (Suc n) \<and> (\<forall>i\<in> {N<..r (Suc n)}. u i \<le> u (r (Suc n)))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1482
  proof (rule dependent_nat_choice)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1483
    fix x assume "N < x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1484
    then have a: "finite {N<..x}" "{N<..x} \<noteq> {}" by simp_all
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1485
    have "Max {u i |i. i \<in> {N<..x}} \<in> {u i |i. i \<in> {N<..x}}" apply (rule Max_in) using a by (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1486
    then obtain p where "p \<in> {N<..x}" and upmax: "u p = Max{u i |i. i \<in> {N<..x}}" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1487
    define U where "U = {m. m > p \<and> u p < u m}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1488
    have "U \<noteq> {}" unfolding U_def using N[of p] \<open>p \<in> {N<..x}\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1489
    define y where "y = Inf U"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1490
    then have "y \<in> U" using \<open>U \<noteq> {}\<close> by (simp add: Inf_nat_def1)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1491
    have a: "\<And>i. i \<in> {N<..x} \<Longrightarrow> u i \<le> u p"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1492
    proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1493
      fix i assume "i \<in> {N<..x}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1494
      then have "u i \<in> {u i |i. i \<in> {N<..x}}" by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1495
      then show "u i \<le> u p" using upmax by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1496
    qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1497
    moreover have "u p < u y" using \<open>y \<in> U\<close> U_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1498
    ultimately have "y \<notin> {N<..x}" using not_le by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1499
    moreover have "y > N" using \<open>y \<in> U\<close> U_def \<open>p \<in> {N<..x}\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1500
    ultimately have "y > x" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1501
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1502
    have "\<And>i. i \<in> {N<..y} \<Longrightarrow> u i \<le> u y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1503
    proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1504
      fix i assume "i \<in> {N<..y}" show "u i \<le> u y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1505
      proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1506
        assume "i = y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1507
        then show ?thesis by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1508
      next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1509
        assume "\<not>(i=y)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1510
        then have i:"i \<in> {N<..<y}" using \<open>i \<in> {N<..y}\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1511
        have "u i \<le> u p"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1512
        proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1513
          assume "i \<le> x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1514
          then have "i \<in> {N<..x}" using i by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1515
          then show ?thesis using a by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1516
        next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1517
          assume "\<not>(i \<le> x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1518
          then have "i > x" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1519
          then have *: "i > p" using \<open>p \<in> {N<..x}\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1520
          have "i < Inf U" using i y_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1521
          then have "i \<notin> U" using Inf_nat_def not_less_Least by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1522
          then show ?thesis using U_def * by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1523
        qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1524
        then show "u i \<le> u y" using \<open>u p < u y\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1525
      qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1526
    qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1527
    then have "N < y \<and> x < y \<and> (\<forall>i\<in>{N<..y}. u i \<le> u y)" using \<open>y > x\<close> \<open>y > N\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1528
    then show "\<exists>y>N. x < y \<and> (\<forall>i\<in>{N<..y}. u i \<le> u y)" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1529
  qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1530
  then obtain r where r: "\<forall>n. N < r n \<and> r n < r (Suc n) \<and> (\<forall>i\<in> {N<..r (Suc n)}. u i \<le> u (r (Suc n)))" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1531
  have "strict_mono r" using r by (auto simp: strict_mono_Suc_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1532
  have "incseq (u o r)" unfolding o_def using r by (simp add: incseq_SucI order.strict_implies_order)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1533
  then have "(u o r) \<longlonglongrightarrow> (SUP n. (u o r) n)" using LIMSEQ_SUP by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1534
  then have "limsup (u o r) = (SUP n. (u o r) n)" by (simp add: lim_imp_Limsup)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1535
  moreover have "limsup (u o r) \<le> limsup u" using \<open>strict_mono r\<close> by (simp add: limsup_subseq_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1536
  ultimately have "(SUP n. (u o r) n) \<le> limsup u" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1537
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1538
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1539
    fix i assume i: "i \<in> {N<..}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1540
    obtain n where "i < r (Suc n)" using \<open>strict_mono r\<close> using Suc_le_eq seq_suble by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1541
    then have "i \<in> {N<..r(Suc n)}" using i by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1542
    then have "u i \<le> u (r(Suc n))" using r by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1543
    then have "u i \<le> (SUP n. (u o r) n)" unfolding o_def by (meson SUP_upper2 UNIV_I)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1544
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1545
  then have "(SUP i:{N<..}. u i) \<le> (SUP n. (u o r) n)" using SUP_least by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1546
  then have "limsup u \<le> (SUP n. (u o r) n)" unfolding Limsup_def
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1547
    by (metis (mono_tags, lifting) INF_lower2 atLeast_Suc_greaterThan atLeast_def eventually_ge_at_top mem_Collect_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1548
  then have "limsup u = (SUP n. (u o r) n)" using \<open>(SUP n. (u o r) n) \<le> limsup u\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1549
  then have "(u o r) \<longlonglongrightarrow> limsup u" using \<open>(u o r) \<longlonglongrightarrow> (SUP n. (u o r) n)\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1550
  then show ?thesis using \<open>strict_mono r\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1551
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1552
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1553
lemma liminf_subseq_lim:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1554
  fixes u::"nat \<Rightarrow> 'a :: {complete_linorder, linorder_topology}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1555
  shows "\<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> (u o r) \<longlonglongrightarrow> liminf u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1556
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1557
  assume "\<forall>n. \<exists>p>n. \<forall>m\<ge>p. u m \<ge> u p"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1558
  then have "\<exists>r. \<forall>n. (\<forall>m\<ge>r n. u m \<ge> u (r n)) \<and> r n < r (Suc n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1559
    by (intro dependent_nat_choice) (auto simp: conj_commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1560
  then obtain r :: "nat \<Rightarrow> nat" where "strict_mono r" and mono: "\<And>n m. r n \<le> m \<Longrightarrow> u m \<ge> u (r n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1561
    by (auto simp: strict_mono_Suc_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1562
  define umin where "umin = (\<lambda>n. (INF m:{n..}. u m))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1563
  have "incseq umin" unfolding umin_def by (simp add: INF_superset_mono incseq_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1564
  then have "umin \<longlonglongrightarrow> liminf u" unfolding umin_def by (metis LIMSEQ_SUP liminf_SUP_INF)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1565
  then have *: "(umin o r) \<longlonglongrightarrow> liminf u" by (simp add: LIMSEQ_subseq_LIMSEQ \<open>strict_mono r\<close>)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1566
  have "\<And>n. umin(r n) = u(r n)" unfolding umin_def using mono
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1567
    by (metis le_INF_iff antisym atLeast_def mem_Collect_eq order_refl)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1568
  then have "umin o r = u o r" unfolding o_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1569
  then have "(u o r) \<longlonglongrightarrow> liminf u" using * by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1570
  then show ?thesis using \<open>strict_mono r\<close> by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1571
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1572
  assume "\<not> (\<forall>n. \<exists>p>n. (\<forall>m\<ge>p. u m \<ge> u p))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1573
  then obtain N where N: "\<And>p. p > N \<Longrightarrow> \<exists>m>p. u p > u m" by (force simp: not_le le_less)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1574
  have "\<exists>r. \<forall>n. N < r n \<and> r n < r (Suc n) \<and> (\<forall>i\<in> {N<..r (Suc n)}. u i \<ge> u (r (Suc n)))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1575
  proof (rule dependent_nat_choice)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1576
    fix x assume "N < x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1577
    then have a: "finite {N<..x}" "{N<..x} \<noteq> {}" by simp_all
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1578
    have "Min {u i |i. i \<in> {N<..x}} \<in> {u i |i. i \<in> {N<..x}}" apply (rule Min_in) using a by (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1579
    then obtain p where "p \<in> {N<..x}" and upmin: "u p = Min{u i |i. i \<in> {N<..x}}" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1580
    define U where "U = {m. m > p \<and> u p > u m}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1581
    have "U \<noteq> {}" unfolding U_def using N[of p] \<open>p \<in> {N<..x}\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1582
    define y where "y = Inf U"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1583
    then have "y \<in> U" using \<open>U \<noteq> {}\<close> by (simp add: Inf_nat_def1)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1584
    have a: "\<And>i. i \<in> {N<..x} \<Longrightarrow> u i \<ge> u p"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1585
    proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1586
      fix i assume "i \<in> {N<..x}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1587
      then have "u i \<in> {u i |i. i \<in> {N<..x}}" by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1588
      then show "u i \<ge> u p" using upmin by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1589
    qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1590
    moreover have "u p > u y" using \<open>y \<in> U\<close> U_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1591
    ultimately have "y \<notin> {N<..x}" using not_le by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1592
    moreover have "y > N" using \<open>y \<in> U\<close> U_def \<open>p \<in> {N<..x}\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1593
    ultimately have "y > x" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1594
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1595
    have "\<And>i. i \<in> {N<..y} \<Longrightarrow> u i \<ge> u y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1596
    proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1597
      fix i assume "i \<in> {N<..y}" show "u i \<ge> u y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1598
      proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1599
        assume "i = y"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1600
        then show ?thesis by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1601
      next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1602
        assume "\<not>(i=y)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1603
        then have i:"i \<in> {N<..<y}" using \<open>i \<in> {N<..y}\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1604
        have "u i \<ge> u p"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1605
        proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1606
          assume "i \<le> x"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1607
          then have "i \<in> {N<..x}" using i by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1608
          then show ?thesis using a by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1609
        next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1610
          assume "\<not>(i \<le> x)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1611
          then have "i > x" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1612
          then have *: "i > p" using \<open>p \<in> {N<..x}\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1613
          have "i < Inf U" using i y_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1614
          then have "i \<notin> U" using Inf_nat_def not_less_Least by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1615
          then show ?thesis using U_def * by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1616
        qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1617
        then show "u i \<ge> u y" using \<open>u p > u y\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1618
      qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1619
    qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1620
    then have "N < y \<and> x < y \<and> (\<forall>i\<in>{N<..y}. u i \<ge> u y)" using \<open>y > x\<close> \<open>y > N\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1621
    then show "\<exists>y>N. x < y \<and> (\<forall>i\<in>{N<..y}. u i \<ge> u y)" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1622
  qed (auto)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1623
  then obtain r :: "nat \<Rightarrow> nat" 
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1624
    where r: "\<forall>n. N < r n \<and> r n < r (Suc n) \<and> (\<forall>i\<in> {N<..r (Suc n)}. u i \<ge> u (r (Suc n)))" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1625
  have "strict_mono r" using r by (auto simp: strict_mono_Suc_iff)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1626
  have "decseq (u o r)" unfolding o_def using r by (simp add: decseq_SucI order.strict_implies_order)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1627
  then have "(u o r) \<longlonglongrightarrow> (INF n. (u o r) n)" using LIMSEQ_INF by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1628
  then have "liminf (u o r) = (INF n. (u o r) n)" by (simp add: lim_imp_Liminf)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1629
  moreover have "liminf (u o r) \<ge> liminf u" using \<open>strict_mono r\<close> by (simp add: liminf_subseq_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1630
  ultimately have "(INF n. (u o r) n) \<ge> liminf u" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1631
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1632
  {
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1633
    fix i assume i: "i \<in> {N<..}"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1634
    obtain n where "i < r (Suc n)" using \<open>strict_mono r\<close> using Suc_le_eq seq_suble by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1635
    then have "i \<in> {N<..r(Suc n)}" using i by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1636
    then have "u i \<ge> u (r(Suc n))" using r by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1637
    then have "u i \<ge> (INF n. (u o r) n)" unfolding o_def by (meson INF_lower2 UNIV_I)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1638
  }
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1639
  then have "(INF i:{N<..}. u i) \<ge> (INF n. (u o r) n)" using INF_greatest by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1640
  then have "liminf u \<ge> (INF n. (u o r) n)" unfolding Liminf_def
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1641
    by (metis (mono_tags, lifting) SUP_upper2 atLeast_Suc_greaterThan atLeast_def eventually_ge_at_top mem_Collect_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1642
  then have "liminf u = (INF n. (u o r) n)" using \<open>(INF n. (u o r) n) \<ge> liminf u\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1643
  then have "(u o r) \<longlonglongrightarrow> liminf u" using \<open>(u o r) \<longlonglongrightarrow> (INF n. (u o r) n)\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1644
  then show ?thesis using \<open>strict_mono r\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1645
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1646
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1647
text \<open>The following statement about limsups is reduced to a statement about limits using
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1648
subsequences thanks to \verb+limsup_subseq_lim+. The statement for limits follows for instance from
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1649
\verb+tendsto_add_ereal_general+.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1650
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1651
lemma ereal_limsup_add_mono:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1652
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1653
  shows "limsup (\<lambda>n. u n + v n) \<le> limsup u + limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1654
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1655
  assume "(limsup u = \<infinity>) \<or> (limsup v = \<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1656
  then have "limsup u + limsup v = \<infinity>" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1657
  then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1658
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1659
  assume "\<not>((limsup u = \<infinity>) \<or> (limsup v = \<infinity>))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1660
  then have "limsup u < \<infinity>" "limsup v < \<infinity>" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1661
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1662
  define w where "w = (\<lambda>n. u n + v n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1663
  obtain r where r: "strict_mono r" "(w o r) \<longlonglongrightarrow> limsup w" using limsup_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1664
  obtain s where s: "strict_mono s" "(u o r o s) \<longlonglongrightarrow> limsup (u o r)" using limsup_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1665
  obtain t where t: "strict_mono t" "(v o r o s o t) \<longlonglongrightarrow> limsup (v o r o s)" using limsup_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1666
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1667
  define a where "a = r o s o t"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1668
  have "strict_mono a" using r s t by (simp add: a_def strict_mono_o)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1669
  have l:"(w o a) \<longlonglongrightarrow> limsup w"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1670
         "(u o a) \<longlonglongrightarrow> limsup (u o r)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1671
         "(v o a) \<longlonglongrightarrow> limsup (v o r o s)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1672
  apply (metis (no_types, lifting) r(2) s(1) t(1) LIMSEQ_subseq_LIMSEQ a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1673
  apply (metis (no_types, lifting) s(2) t(1) LIMSEQ_subseq_LIMSEQ a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1674
  apply (metis (no_types, lifting) t(2) a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1675
  done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1676
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1677
  have "limsup (u o r) \<le> limsup u" by (simp add: limsup_subseq_mono r(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1678
  then have a: "limsup (u o r) \<noteq> \<infinity>" using \<open>limsup u < \<infinity>\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1679
  have "limsup (v o r o s) \<le> limsup v" 
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1680
    by (simp add: comp_assoc limsup_subseq_mono r(1) s(1) strict_mono_o)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1681
  then have b: "limsup (v o r o s) \<noteq> \<infinity>" using \<open>limsup v < \<infinity>\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1682
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1683
  have "(\<lambda>n. (u o a) n + (v o a) n) \<longlonglongrightarrow> limsup (u o r) + limsup (v o r o s)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1684
    using l tendsto_add_ereal_general a b by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1685
  moreover have "(\<lambda>n. (u o a) n + (v o a) n) = (w o a)" unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1686
  ultimately have "(w o a) \<longlonglongrightarrow> limsup (u o r) + limsup (v o r o s)" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1687
  then have "limsup w = limsup (u o r) + limsup (v o r o s)" using l(1) LIMSEQ_unique by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1688
  then have "limsup w \<le> limsup u + limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1689
    using \<open>limsup (u o r) \<le> limsup u\<close> \<open>limsup (v o r o s) \<le> limsup v\<close> ereal_add_mono by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1690
  then show ?thesis unfolding w_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1691
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1692
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1693
text \<open>There is an asymmetry between liminfs and limsups in ereal, as $\infty + (-\infty) = \infty$.
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1694
This explains why there are more assumptions in the next lemma dealing with liminfs that in the
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1695
previous one about limsups.\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1696
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1697
lemma ereal_liminf_add_mono:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1698
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1699
  assumes "\<not>((liminf u = \<infinity> \<and> liminf v = -\<infinity>) \<or> (liminf u = -\<infinity> \<and> liminf v = \<infinity>))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1700
  shows "liminf (\<lambda>n. u n + v n) \<ge> liminf u + liminf v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1701
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1702
  assume "(liminf u = -\<infinity>) \<or> (liminf v = -\<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1703
  then have *: "liminf u + liminf v = -\<infinity>" using assms by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1704
  show ?thesis by (simp add: *)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1705
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1706
  assume "\<not>((liminf u = -\<infinity>) \<or> (liminf v = -\<infinity>))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1707
  then have "liminf u > -\<infinity>" "liminf v > -\<infinity>" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1708
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1709
  define w where "w = (\<lambda>n. u n + v n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1710
  obtain r where r: "strict_mono r" "(w o r) \<longlonglongrightarrow> liminf w" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1711
  obtain s where s: "strict_mono s" "(u o r o s) \<longlonglongrightarrow> liminf (u o r)" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1712
  obtain t where t: "strict_mono t" "(v o r o s o t) \<longlonglongrightarrow> liminf (v o r o s)" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1713
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1714
  define a where "a = r o s o t"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1715
  have "strict_mono a" using r s t by (simp add: a_def strict_mono_o)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1716
  have l:"(w o a) \<longlonglongrightarrow> liminf w"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1717
         "(u o a) \<longlonglongrightarrow> liminf (u o r)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1718
         "(v o a) \<longlonglongrightarrow> liminf (v o r o s)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1719
  apply (metis (no_types, lifting) r(2) s(1) t(1) LIMSEQ_subseq_LIMSEQ a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1720
  apply (metis (no_types, lifting) s(2) t(1) LIMSEQ_subseq_LIMSEQ a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1721
  apply (metis (no_types, lifting) t(2) a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1722
  done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1723
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1724
  have "liminf (u o r) \<ge> liminf u" by (simp add: liminf_subseq_mono r(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1725
  then have a: "liminf (u o r) \<noteq> -\<infinity>" using \<open>liminf u > -\<infinity>\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1726
  have "liminf (v o r o s) \<ge> liminf v" 
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1727
    by (simp add: comp_assoc liminf_subseq_mono r(1) s(1) strict_mono_o)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1728
  then have b: "liminf (v o r o s) \<noteq> -\<infinity>" using \<open>liminf v > -\<infinity>\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1729
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1730
  have "(\<lambda>n. (u o a) n + (v o a) n) \<longlonglongrightarrow> liminf (u o r) + liminf (v o r o s)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1731
    using l tendsto_add_ereal_general a b by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1732
  moreover have "(\<lambda>n. (u o a) n + (v o a) n) = (w o a)" unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1733
  ultimately have "(w o a) \<longlonglongrightarrow> liminf (u o r) + liminf (v o r o s)" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1734
  then have "liminf w = liminf (u o r) + liminf (v o r o s)" using l(1) LIMSEQ_unique by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1735
  then have "liminf w \<ge> liminf u + liminf v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1736
    using \<open>liminf (u o r) \<ge> liminf u\<close> \<open>liminf (v o r o s) \<ge> liminf v\<close> ereal_add_mono by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1737
  then show ?thesis unfolding w_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1738
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1739
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1740
lemma ereal_limsup_lim_add:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1741
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1742
  assumes "u \<longlonglongrightarrow> a" "abs(a) \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1743
  shows "limsup (\<lambda>n. u n + v n) = a + limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1744
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1745
  have "limsup u = a" using assms(1) using tendsto_iff_Liminf_eq_Limsup trivial_limit_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1746
  have "(\<lambda>n. -u n) \<longlonglongrightarrow> -a" using assms(1) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1747
  then have "limsup (\<lambda>n. -u n) = -a" using tendsto_iff_Liminf_eq_Limsup trivial_limit_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1748
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1749
  have "limsup (\<lambda>n. u n + v n) \<le> limsup u + limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1750
    by (rule ereal_limsup_add_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1751
  then have up: "limsup (\<lambda>n. u n + v n) \<le> a + limsup v" using \<open>limsup u = a\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1752
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1753
  have a: "limsup (\<lambda>n. (u n + v n) + (-u n)) \<le> limsup (\<lambda>n. u n + v n) + limsup (\<lambda>n. -u n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1754
    by (rule ereal_limsup_add_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1755
  have "eventually (\<lambda>n. u n = ereal(real_of_ereal(u n))) sequentially" using assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1756
    real_lim_then_eventually_real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1757
  moreover have "\<And>x. x = ereal(real_of_ereal(x)) \<Longrightarrow> x + (-x) = 0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1758
    by (metis plus_ereal.simps(1) right_minus uminus_ereal.simps(1) zero_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1759
  ultimately have "eventually (\<lambda>n. u n + (-u n) = 0) sequentially"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1760
    by (metis (mono_tags, lifting) eventually_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1761
  moreover have "\<And>n. u n + (-u n) = 0 \<Longrightarrow> u n + v n + (-u n) = v n"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1762
    by (metis add.commute add.left_commute add.left_neutral)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1763
  ultimately have "eventually (\<lambda>n. u n + v n + (-u n) = v n) sequentially"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1764
    using eventually_mono by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1765
  then have "limsup v = limsup (\<lambda>n. u n + v n + (-u n))" using Limsup_eq by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1766
  then have "limsup v \<le> limsup (\<lambda>n. u n + v n) -a" using a \<open>limsup (\<lambda>n. -u n) = -a\<close> by (simp add: minus_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1767
  then have "limsup (\<lambda>n. u n + v n) \<ge> a + limsup v" using assms(2) by (metis add.commute ereal_le_minus)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1768
  then show ?thesis using up by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1769
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1770
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1771
lemma ereal_limsup_lim_mult:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1772
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1773
  assumes "u \<longlonglongrightarrow> a" "a>0" "a \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1774
  shows "limsup (\<lambda>n. u n * v n) = a * limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1775
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1776
  define w where "w = (\<lambda>n. u n * v n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1777
  obtain r where r: "strict_mono r" "(v o r) \<longlonglongrightarrow> limsup v" using limsup_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1778
  have "(u o r) \<longlonglongrightarrow> a" using assms(1) LIMSEQ_subseq_LIMSEQ r by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1779
  with tendsto_mult_ereal[OF this r(2)] have "(\<lambda>n. (u o r) n * (v o r) n) \<longlonglongrightarrow> a * limsup v" using assms(2) assms(3) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1780
  moreover have "\<And>n. (w o r) n = (u o r) n * (v o r) n" unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1781
  ultimately have "(w o r) \<longlonglongrightarrow> a * limsup v" unfolding w_def by presburger
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1782
  then have "limsup (w o r) = a * limsup v" by (simp add: tendsto_iff_Liminf_eq_Limsup)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1783
  then have I: "limsup w \<ge> a * limsup v" by (metis limsup_subseq_mono r(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1784
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1785
  obtain s where s: "strict_mono s" "(w o s) \<longlonglongrightarrow> limsup w" using limsup_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1786
  have *: "(u o s) \<longlonglongrightarrow> a" using assms(1) LIMSEQ_subseq_LIMSEQ s by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1787
  have "eventually (\<lambda>n. (u o s) n > 0) sequentially" using assms(2) * order_tendsto_iff by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1788
  moreover have "eventually (\<lambda>n. (u o s) n < \<infinity>) sequentially" using assms(3) * order_tendsto_iff by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1789
  moreover have "(w o s) n / (u o s) n = (v o s) n" if "(u o s) n > 0" "(u o s) n < \<infinity>" for n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1790
    unfolding w_def using that by (auto simp add: ereal_divide_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1791
  ultimately have "eventually (\<lambda>n. (w o s) n / (u o s) n = (v o s) n) sequentially" using eventually_elim2 by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1792
  moreover have "(\<lambda>n. (w o s) n / (u o s) n) \<longlonglongrightarrow> (limsup w) / a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1793
    apply (rule tendsto_divide_ereal[OF s(2) *]) using assms(2) assms(3) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1794
  ultimately have "(v o s) \<longlonglongrightarrow> (limsup w) / a" using Lim_transform_eventually by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1795
  then have "limsup (v o s) = (limsup w) / a" by (simp add: tendsto_iff_Liminf_eq_Limsup)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1796
  then have "limsup v \<ge> (limsup w) / a" by (metis limsup_subseq_mono s(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1797
  then have "a * limsup v \<ge> limsup w" using assms(2) assms(3) by (simp add: ereal_divide_le_pos)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1798
  then show ?thesis using I unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1799
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1800
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1801
lemma ereal_liminf_lim_mult:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1802
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1803
  assumes "u \<longlonglongrightarrow> a" "a>0" "a \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1804
  shows "liminf (\<lambda>n. u n * v n) = a * liminf v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1805
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1806
  define w where "w = (\<lambda>n. u n * v n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1807
  obtain r where r: "strict_mono r" "(v o r) \<longlonglongrightarrow> liminf v" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1808
  have "(u o r) \<longlonglongrightarrow> a" using assms(1) LIMSEQ_subseq_LIMSEQ r by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1809
  with tendsto_mult_ereal[OF this r(2)] have "(\<lambda>n. (u o r) n * (v o r) n) \<longlonglongrightarrow> a * liminf v" using assms(2) assms(3) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1810
  moreover have "\<And>n. (w o r) n = (u o r) n * (v o r) n" unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1811
  ultimately have "(w o r) \<longlonglongrightarrow> a * liminf v" unfolding w_def by presburger
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1812
  then have "liminf (w o r) = a * liminf v" by (simp add: tendsto_iff_Liminf_eq_Limsup)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1813
  then have I: "liminf w \<le> a * liminf v" by (metis liminf_subseq_mono r(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1814
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1815
  obtain s where s: "strict_mono s" "(w o s) \<longlonglongrightarrow> liminf w" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1816
  have *: "(u o s) \<longlonglongrightarrow> a" using assms(1) LIMSEQ_subseq_LIMSEQ s by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1817
  have "eventually (\<lambda>n. (u o s) n > 0) sequentially" using assms(2) * order_tendsto_iff by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1818
  moreover have "eventually (\<lambda>n. (u o s) n < \<infinity>) sequentially" using assms(3) * order_tendsto_iff by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1819
  moreover have "(w o s) n / (u o s) n = (v o s) n" if "(u o s) n > 0" "(u o s) n < \<infinity>" for n
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1820
    unfolding w_def using that by (auto simp add: ereal_divide_eq)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1821
  ultimately have "eventually (\<lambda>n. (w o s) n / (u o s) n = (v o s) n) sequentially" using eventually_elim2 by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1822
  moreover have "(\<lambda>n. (w o s) n / (u o s) n) \<longlonglongrightarrow> (liminf w) / a"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1823
    apply (rule tendsto_divide_ereal[OF s(2) *]) using assms(2) assms(3) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1824
  ultimately have "(v o s) \<longlonglongrightarrow> (liminf w) / a" using Lim_transform_eventually by fastforce
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1825
  then have "liminf (v o s) = (liminf w) / a" by (simp add: tendsto_iff_Liminf_eq_Limsup)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1826
  then have "liminf v \<le> (liminf w) / a" by (metis liminf_subseq_mono s(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1827
  then have "a * liminf v \<le> liminf w" using assms(2) assms(3) by (simp add: ereal_le_divide_pos)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1828
  then show ?thesis using I unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1829
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1830
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1831
lemma ereal_liminf_lim_add:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1832
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1833
  assumes "u \<longlonglongrightarrow> a" "abs(a) \<noteq> \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1834
  shows "liminf (\<lambda>n. u n + v n) = a + liminf v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1835
proof -
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1836
  have "liminf u = a" using assms(1) tendsto_iff_Liminf_eq_Limsup trivial_limit_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1837
  then have *: "abs(liminf u) \<noteq> \<infinity>" using assms(2) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1838
  have "(\<lambda>n. -u n) \<longlonglongrightarrow> -a" using assms(1) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1839
  then have "liminf (\<lambda>n. -u n) = -a" using tendsto_iff_Liminf_eq_Limsup trivial_limit_at_top_linorder by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1840
  then have **: "abs(liminf (\<lambda>n. -u n)) \<noteq> \<infinity>" using assms(2) by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1841
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1842
  have "liminf (\<lambda>n. u n + v n) \<ge> liminf u + liminf v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1843
    apply (rule ereal_liminf_add_mono) using * by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1844
  then have up: "liminf (\<lambda>n. u n + v n) \<ge> a + liminf v" using \<open>liminf u = a\<close> by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1845
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1846
  have a: "liminf (\<lambda>n. (u n + v n) + (-u n)) \<ge> liminf (\<lambda>n. u n + v n) + liminf (\<lambda>n. -u n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1847
    apply (rule ereal_liminf_add_mono) using ** by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1848
  have "eventually (\<lambda>n. u n = ereal(real_of_ereal(u n))) sequentially" using assms
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1849
    real_lim_then_eventually_real by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1850
  moreover have "\<And>x. x = ereal(real_of_ereal(x)) \<Longrightarrow> x + (-x) = 0"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1851
    by (metis plus_ereal.simps(1) right_minus uminus_ereal.simps(1) zero_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1852
  ultimately have "eventually (\<lambda>n. u n + (-u n) = 0) sequentially"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1853
    by (metis (mono_tags, lifting) eventually_mono)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1854
  moreover have "\<And>n. u n + (-u n) = 0 \<Longrightarrow> u n + v n + (-u n) = v n"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1855
    by (metis add.commute add.left_commute add.left_neutral)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1856
  ultimately have "eventually (\<lambda>n. u n + v n + (-u n) = v n) sequentially"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1857
    using eventually_mono by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1858
  then have "liminf v = liminf (\<lambda>n. u n + v n + (-u n))" using Liminf_eq by force
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1859
  then have "liminf v \<ge> liminf (\<lambda>n. u n + v n) -a" using a \<open>liminf (\<lambda>n. -u n) = -a\<close> by (simp add: minus_ereal_def)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1860
  then have "liminf (\<lambda>n. u n + v n) \<le> a + liminf v" using assms(2) by (metis add.commute ereal_minus_le)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1861
  then show ?thesis using up by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1862
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1863
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1864
lemma ereal_liminf_limsup_add:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1865
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1866
  shows "liminf (\<lambda>n. u n + v n) \<le> liminf u + limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1867
proof (cases)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1868
  assume "limsup v = \<infinity> \<or> liminf u = \<infinity>"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1869
  then show ?thesis by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1870
next
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1871
  assume "\<not>(limsup v = \<infinity> \<or> liminf u = \<infinity>)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1872
  then have "limsup v < \<infinity>" "liminf u < \<infinity>" by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1873
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1874
  define w where "w = (\<lambda>n. u n + v n)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1875
  obtain r where r: "strict_mono r" "(u o r) \<longlonglongrightarrow> liminf u" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1876
  obtain s where s: "strict_mono s" "(w o r o s) \<longlonglongrightarrow> liminf (w o r)" using liminf_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1877
  obtain t where t: "strict_mono t" "(v o r o s o t) \<longlonglongrightarrow> limsup (v o r o s)" using limsup_subseq_lim by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1878
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1879
  define a where "a = r o s o t"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1880
  have "strict_mono a" using r s t by (simp add: a_def strict_mono_o)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1881
  have l:"(u o a) \<longlonglongrightarrow> liminf u"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1882
         "(w o a) \<longlonglongrightarrow> liminf (w o r)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1883
         "(v o a) \<longlonglongrightarrow> limsup (v o r o s)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1884
  apply (metis (no_types, lifting) r(2) s(1) t(1) LIMSEQ_subseq_LIMSEQ a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1885
  apply (metis (no_types, lifting) s(2) t(1) LIMSEQ_subseq_LIMSEQ a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1886
  apply (metis (no_types, lifting) t(2) a_def comp_assoc)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1887
  done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1888
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1889
  have "liminf (w o r) \<ge> liminf w" by (simp add: liminf_subseq_mono r(1))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1890
  have "limsup (v o r o s) \<le> limsup v" 
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1891
    by (simp add: comp_assoc limsup_subseq_mono r(1) s(1) strict_mono_o)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1892
  then have b: "limsup (v o r o s) < \<infinity>" using \<open>limsup v < \<infinity>\<close> by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1893
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1894
  have "(\<lambda>n. (u o a) n + (v o a) n) \<longlonglongrightarrow> liminf u + limsup (v o r o s)"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1895
    apply (rule tendsto_add_ereal_general) using b \<open>liminf u < \<infinity>\<close> l(1) l(3) by force+
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1896
  moreover have "(\<lambda>n. (u o a) n + (v o a) n) = (w o a)" unfolding w_def by auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1897
  ultimately have "(w o a) \<longlonglongrightarrow> liminf u + limsup (v o r o s)" by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1898
  then have "liminf (w o r) = liminf u + limsup (v o r o s)" using l(2) using LIMSEQ_unique by blast
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1899
  then have "liminf w \<le> liminf u + limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1900
    using \<open>liminf (w o r) \<ge> liminf w\<close> \<open>limsup (v o r o s) \<le> limsup v\<close>
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1901
    by (metis add_mono_thms_linordered_semiring(2) le_less_trans not_less)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1902
  then show ?thesis unfolding w_def by simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1903
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1904
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1905
lemma ereal_liminf_limsup_minus:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1906
  fixes u v::"nat \<Rightarrow> ereal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1907
  shows "liminf (\<lambda>n. u n - v n) \<le> limsup u - limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1908
  unfolding minus_ereal_def
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1909
  apply (subst add.commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1910
  apply (rule order_trans[OF ereal_liminf_limsup_add])
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1911
  using ereal_Limsup_uminus[of sequentially "\<lambda>n. - v n"]
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1912
  apply (simp add: add.commute)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1913
  done
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1914
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1915
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1916
lemma liminf_minus_ennreal:
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1917
  fixes u v::"nat \<Rightarrow> ennreal"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1918
  shows "(\<And>n. v n \<le> u n) \<Longrightarrow> liminf (\<lambda>n. u n - v n) \<le> limsup u - limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1919
  unfolding liminf_SUP_INF limsup_INF_SUP
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1920
  including ennreal.lifting
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1921
proof (transfer, clarsimp)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1922
  fix v u :: "nat \<Rightarrow> ereal" assume *: "\<forall>x. 0 \<le> v x" "\<forall>x. 0 \<le> u x" "\<And>n. v n \<le> u n"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1923
  moreover have "0 \<le> limsup u - limsup v"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1924
    using * by (intro ereal_diff_positive Limsup_mono always_eventually) simp
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1925
  moreover have "0 \<le> (SUPREMUM {x..} v)" for x
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1926
    using * by (intro SUP_upper2[of x]) auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1927
  moreover have "0 \<le> (SUPREMUM {x..} u)" for x
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1928
    using * by (intro SUP_upper2[of x]) auto
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1929
  ultimately show "(SUP n. INF n:{n..}. max 0 (u n - v n))
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1930
            \<le> max 0 ((INF x. max 0 (SUPREMUM {x..} u)) - (INF x. max 0 (SUPREMUM {x..} v)))"
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1931
    by (auto simp: * ereal_diff_positive max.absorb2 liminf_SUP_INF[symmetric] limsup_INF_SUP[symmetric] ereal_liminf_limsup_minus)
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1932
qed
621897f47fab Various lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66453
diff changeset
  1933
57446
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1934
subsection "Relate extended reals and the indicator function"
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1935
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58877
diff changeset
  1936
lemma ereal_indicator_le_0: "(indicator S x::ereal) \<le> 0 \<longleftrightarrow> x \<notin> S"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58877
diff changeset
  1937
  by (auto split: split_indicator simp: one_ereal_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58877
diff changeset
  1938
57446
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1939
lemma ereal_indicator: "ereal (indicator A x) = indicator A x"
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1940
  by (auto simp: indicator_def one_ereal_def)
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1941
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1942
lemma ereal_mult_indicator: "ereal (x * indicator A y) = ereal x * indicator A y"
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1943
  by (simp split: split_indicator)
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1944
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1945
lemma ereal_indicator_mult: "ereal (indicator A y * x) = indicator A y * ereal x"
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1946
  by (simp split: split_indicator)
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1947
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1948
lemma ereal_indicator_nonneg[simp, intro]: "0 \<le> (indicator A x ::ereal)"
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1949
  unfolding indicator_def by auto
06e195515deb some lemmas about the indicator function; removed lemma sums_def2
hoelzl
parents: 57418
diff changeset
  1950
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59000
diff changeset
  1951
lemma indicator_inter_arith_ereal: "indicator A x * indicator B x = (indicator (A \<inter> B) x :: ereal)"
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59000
diff changeset
  1952
  by (simp split: split_indicator)
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 59000
diff changeset
  1953
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 43923
diff changeset
  1954
end