Zulip Chat Archive

Stream: new members

Topic: Prop equal and def equal


tsuki hao (Sep 01 2023 at 00:27):

import Mathlib.Tactic
import Mathlib.Analysis.Convex.Function
import Mathlib.Data.Real.EReal
import Mathlib.Topology.Basic
import Mathlib.Topology.Sequences
import Mathlib.Order.Filter.Basic
import Mathlib.Order.LiminfLimsup
import Mathlib.Data.Set.Basic
import Mathlib.Logic.Basic
import Mathlib.Order.Basic
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.Bases
import Mathlib.Init.Set
import Mathlib.Data.Set.Basic

open EReal Function Topology Filter Set TopologicalSpace


variable {๐•œ E ฮฑ ฮฒ ฮน : Type _}

variable [OrderedSemiring ๐•œ]

variable [AddCommMonoid E]

variable (๐•œ) (s : Set E) (f : E โ†’ EReal)[SMul ๐•œ E]

def properfun : Prop :=
  (โˆƒ x โˆˆ s, f x < โŠค) โˆง (โˆ€ x โˆˆ s, f x > โŠฅ)

def dom : Set E :=
  {x | f x < โŠค} โˆฉ s

def sublevel (r : EReal) : Set E :=
  { x โˆˆ s | f x โ‰ค r }

def uplevel (r : EReal) : Set E :=
  { x โˆˆ s | f x > r }

def epigraph : Set <| E ร— EReal :=
  {p : E ร— EReal | p.1 โˆˆ s โˆง f p.1 โ‰ค p.2}
-- {p : E ร— ฮฒ | p.1 โˆˆ s โˆง f p.1 โ‰ค p.2}

variable [TopologicalSpace ๐•œ] [PseudoMetricSpace E] [TopologicalSpace EReal]

variable [SequentialSpace E] [SequentialSpace EReal] [SequentialSpace <| E ร— EReal]

variable [OrderTopology EReal]

variable [FirstCountableTopology E] [FirstCountableTopology EReal]


def closedfunc : Prop :=
  IsClosed <| epigraph s f

def lo_semicontinuous : Prop :=
  โˆ€ x โˆˆ s, f x โ‰ค (liminf f <| ๐“[s] x)

section IsClosed

variable (s : Closeds E) (f : E โ†’ EReal) [SMul ๐•œ E] [SMul ๐•œ EReal]


theorem aux12 (hf : โˆ€ (r : EReal), IsClosed <| sublevel s f r) : lo_semicontinuous s f := by
  by_contra h
  unfold lo_semicontinuous at h
  push_neg at h
  rcases h with โŸจx, โŸจ_, hxโŸฉโŸฉ
  rcases exists_between hx with โŸจt, โŸจltt, tltโŸฉโŸฉ
  have : x โˆˆ sublevel s f t := by
    apply (isClosed_iff_frequently.mp (hf t) x)
    have h1 : โˆƒแถ  (y : E) in ๐“[s] x, f y < t := frequently_lt_of_liminf_lt (by isBoundedDefault) ltt
    have h1' : โˆƒแถ  (y : E) in ๐“[s] x, f y โ‰ค t := by
      apply frequently_iff.mpr
      intro _ hu
      rcases ((frequently_iff.mp h1) hu) with โŸจx, xu, fxโŸฉ
      exact Exists.intro x { left := xu, right := LT.lt.le fx }
    have : โˆƒแถ  (y : E) in ๐“ x, f y โ‰ค t โˆง y โˆˆ s := frequently_nhdsWithin_iff.mp h1'
    apply frequently_iff.mpr
    intro _ hu
    rcases ((frequently_iff.mp this) hu) with โŸจx, xu, fx, xsโŸฉ
    exact Exists.intro x { left := xu, right := { left := xs, right := fx } }
  apply not_le_of_gt tlt (mem_setOf.mp this).2

theorem aux23 (hf : lo_semicontinuous s f) : closedfunc s f := by
  apply IsSeqClosed.isClosed
  intro f' โŸจx', y'โŸฉ hxy cxy
  rw [Prod.tendsto_iff] at cxy
  let x : โ„• -> E := fun (n : โ„•) => (f' n).1
  have hx : โˆ€ (n : โ„•), x n โˆˆ โ†‘ s := fun n =>  (hxy n).1
  have h1 : x' โˆˆ s :=
    SetLike.mem_coe.mp ((isSeqClosed_iff_isClosed.mpr <| Closeds.closed s) hx cxy.1)
  have cx : Tendsto x atTop (๐“[s] x') :=
    tendsto_nhdsWithin_iff.mpr โŸจcxy.1, eventually_of_forall hxโŸฉ
  let y : โ„• -> EReal := fun (n : โ„•) => (f' n).2
  have xley : โˆ€ (n : โ„•), (f โˆ˜ x) n โ‰ค y n :=
    fun n => Trans.trans (Trans.trans (Eq.refl ((f โˆ˜ x) n)) (hxy n).2) (Eq.refl (f' n).2)
  have h2 : f x' โ‰ค y' := by
    calc
      f x' โ‰ค liminf f (๐“[s] x') := hf x' h1
      _ = sSup {a | โˆ€แถ  (n : E) in ๐“[s] x', a โ‰ค f n} := by rw[liminf_eq]
      _ โ‰ค sSup {a | โˆ€แถ  (n : โ„•) in atTop, a โ‰ค (f โˆ˜ x) n} :=
        sSup_le_sSup
        fun _ fa => mem_setOf.mpr ((eventually_iff_seq_eventually.mp <| mem_setOf.mp fa) x cx)
      _ = liminf (f โˆ˜ x) atTop := by rw[โ† liminf_eq]
      _ โ‰ค liminf y atTop := liminf_le_liminf (eventually_of_forall xley)
      _ = y' := (cxy.2).liminf_eq
  exact โŸจh1, h2โŸฉ

theorem aux31 (hf : closedfunc s f) : โˆ€ (r : EReal), IsClosed <| sublevel s f r := by
  intro r
  rw [โ† isSeqClosed_iff_isClosed]
  intro x x' xns cx
  exact IsClosed.isSeqClosed hf (fun n => xns n) (Tendsto.prod_mk_nhds cx tendsto_const_nhds)

theorem aux31' (s : Set E) (f : E โ†’ EReal) (hf : closedfunc s f) : โˆ€ (r : EReal), IsClosed <| sublevel s f r := by
  intro r
  rw [โ† isSeqClosed_iff_isClosed]
  intro x x' xns cx
  exact IsClosed.isSeqClosed hf (fun n => xns n) (Tendsto.prod_mk_nhds cx tendsto_const_nhds)

theorem eq12 :  (โˆ€ (r : EReal), IsClosed <| sublevel s f r) โ†” lo_semicontinuous s f :=
  โŸจfun a => aux12 s f a, fun a => aux31 s f (aux23 s f a)โŸฉ

theorem eq23 : lo_semicontinuous s f โ†” closedfunc s f :=
  โŸจfun a => aux23 s f a, fun a => aux12 s f (aux31 s f a)โŸฉ

theorem eq31 : closedfunc s f โ†” (โˆ€ (r : EReal), IsClosed <| sublevel s f r):=
  โŸจfun a => aux31 s f a , fun a => aux23 s f (aux12 s f a)โŸฉ

end IsClosed


theorem closed_of_continuous (hs : IsClosed s) (hf : Continuous f) : closedfunc s f := by
  apply IsSeqClosed.isClosed
  intro xt prod h cxt
  rcases (Prod.tendsto_iff xt prod).mp cxt with โŸจcx, ctโŸฉ
  have cfx : Tendsto f (๐“ prod.1) (๐“ (f prod.1)) := Continuous.continuousAt hf
  constructor
  ยท exact (IsClosed.isSeqClosed hs) (fun n => (h n).1) cx
  ยท exact le_of_tendsto_of_tendsto' (Tendsto.comp cfx cx) ct (fun n => (h n).2)


#check @le_of_tendsto_of_tendsto'


theorem aux (hf :  โˆ€ (r : EReal), IsClosed <| sublevel s f r) : closedfunc s f := by
  sorry

theorem sup_closed2 (f1 f2: E โ†’ EReal){hf1 : closedfunc s f1} {hf2 : closedfunc s f2} : closedfunc s (sSup {f1, f2}) := by
  have h : โˆ€ (r : EReal), IsClosed <| sublevel s (sSup {f1, f2}) r := by
    have h1 : โˆ€ (r : EReal),  IsClosed <| sublevel s f1 r := by
      exact fun r => aux31' s f1 hf1 r
    have h2 : โˆ€ (r : EReal),  IsClosed <| sublevel s f2 r := by
      exact fun r => aux31' s f2 hf2 r
    have h3 : โˆ€ (r : EReal), sublevel s (sSup {f1, f2}) r = {x โˆˆ s | sSup {f1, f2} x โ‰ค r }:= by
      exact fun r => rfl
    have h4 : โˆ€ (r : EReal), {x โˆˆ s | sSup {f1, f2} x โ‰ค r } = {x โˆˆ s | f1 x โ‰ค r} โˆฉ {x โˆˆ s | f2 x โ‰ค r} := by
      intro r
      have l1 : โˆ€ x โˆˆ {x โˆˆ s | sSup {f1, f2} x โ‰ค r }, x โˆˆ {x | sSup {f1, f2} x โ‰ค r} := by
        exact fun x a => mem_of_mem_inter_right a
      have c1 : โˆ€ x โˆˆ {x โˆˆ s | sSup {f1, f2} x โ‰ค r }, sSup {f1, f2} x โ‰ค r := by
        exact fun x a => l1 x a
      have c2 : โˆ€ x โˆˆ {x โˆˆ s | sSup {f1, f2} x โ‰ค r }, x โˆˆ {x โˆˆ s | f1 x โ‰ค r} โˆฉ {x โˆˆ s | f2 x โ‰ค r}:= by
        have m1 : โˆ€ x โˆˆ s, f1 x โ‰ค r โˆง f2 x โ‰ค r โ†’ x โˆˆ {x โˆˆ s | f1 x โ‰ค r} โˆฉ {x โˆˆ s | f2 x โ‰ค r} := by
          intro x a1 a2
          rcases a2 with โŸจa3, a4โŸฉ
          constructor
          ยท exact mem_sep a1 a3
          ยท exact mem_sep a1 a4
      have c3 : โˆ€ x โˆˆ {x โˆˆ s | f1 x โ‰ค r} โˆฉ {x โˆˆ s | f2 x โ‰ค r}, x โˆˆ {x โˆˆ s | sSup {f1, f2} x โ‰ค r } := by
        sorry
      exact Subset.antisymm c2 c3

    have h5 : โˆ€ (r : EReal), sublevel s (sSup {f1, f2}) r = {x โˆˆ s | f1 x โ‰ค r} โˆฉ {x โˆˆ s | f2 x โ‰ค r} := by
      exact fun r => h4 r
    have h6 : โˆ€ (r : EReal), IsClosed <| {x โˆˆ s | f1 x โ‰ค r} โˆฉ {x โˆˆ s | f2 x โ‰ค r} := by
      exact fun r => IsClosed.inter (h1 r) (h2 r)
    have h7 : โˆ€ (r : EReal), IsClosed <| sublevel s (sSup {f1, f2}) r := by
      sorry
    exact fun r => h7 r
  exact aux s (sSup {f1, f2}) h

Does anyone know how to write the last sorry? It should be launched directly with h5 and h6, but h5 is Prop Equal not Def Equal, maybe it cannot be directly replaced for this reason? Does anyone know what to do?

Kevin Buzzard (Sep 01 2023 at 07:30):

    have h7 : โˆ€ (r : EReal), IsClosed <| sublevel s (sSup {f1, f2}) r := by
      convert h6
      apply h5

By the way, you don't need all those imports:

import Mathlib.Tactic
import Mathlib.Data.Real.EReal
import Mathlib.Topology.Sets.Closeds

will do.

Kevin Buzzard (Sep 01 2023 at 07:34):

And also, stuff like [TopologicalSpace EReal] is I suspect not correct: this means "put an arbitrary topology on EReal", not "put the obvious topology on EReal". I might be wrong about this though, I don't know much about EReal (I did write the definition, but I didn't think at all about topology at the time)

Kevin Buzzard (Sep 01 2023 at 08:43):

Yeah you should be importing Mathlib.Topology.Instances.EReal and you should delete all variables putting instances on EReal; you can put structure on abstract types using variables (eg variable [AddCommMonoid E] is fine) but you can't put structure on a concrete type like EReal in this way (it will overwrite the correct structure if you do)

Kevin Buzzard (Sep 01 2023 at 08:46):

Similarly you shouldn't have two SMul \k E variables -- this will put two different actions of \k on E.


Last updated: Dec 20 2023 at 11:08 UTC