-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathScottContinuity.lean
More file actions
212 lines (170 loc) · 8.34 KB
/
ScottContinuity.lean
File metadata and controls
212 lines (170 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/-
Copyright (c) 2022 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
module
public import Mathlib.Tactic.FunProp.Attr
public import Mathlib.Tactic.ToFun
import Mathlib.Order.Bounds.Image
public import Mathlib.Order.Bounds.Defs
public import Mathlib.Order.Directed
/-!
# Scott continuity
A function `f : α → β` between preorders is Scott continuous (referring to Dana Scott) if it
distributes over `IsLUB`. Scott continuity corresponds to continuity in Scott topological spaces
(defined in `Mathlib/Topology/Order/ScottTopology.lean`). It is distinct from the (more commonly
used) continuity from topology (see `Mathlib/Topology/Basic.lean`).
## Implementation notes
Given a set `D` of directed sets, we define say `f` is `ScottContinuousOn D` if it distributes over
`IsLUB` for all elements of `D`. This allows us to consider Scott Continuity on all directed sets
in this file, and ωScott Continuity on chains later in
`Mathlib/Order/OmegaCompletePartialOrder.lean`.
## References
* [Abramsky and Jung, *Domain Theory*][abramsky_gabbay_maibaum_1994]
* [Gierz et al, *A Compendium of Continuous Lattices*][GierzEtAl1980]
-/
@[expose] public section
open Set
variable {α β γ : Type*}
section ScottContinuous
variable [Preorder α] [Preorder β] [Preorder γ] {D D₁ D₂ : Set (Set α)}
{f : α → β}
attribute [local push ←] Function.comp_def
attribute [local push] Function.const_def
/-- A function between preorders is said to be Scott continuous on a set `D` of directed sets if it
preserves `IsLUB` on elements of `D`.
The dual notion
```lean
∀ ⦃d : Set α⦄, d ∈ D → d.Nonempty → DirectedOn (· ≥ ·) d → ∀ ⦃a⦄, IsGLB d a → IsGLB (f '' d) (f a)
```
does not appear to play a significant role in the literature, so is omitted here.
-/
@[fun_prop]
def ScottContinuousOn (D : Set (Set α)) (f : α → β) : Prop :=
∀ ⦃d : Set α⦄, d ∈ D → d.Nonempty → DirectedOn (· ≤ ·) d → ∀ ⦃a⦄, IsLUB d a → IsLUB (f '' d) (f a)
lemma ScottContinuousOn.mono (hD : D₁ ⊆ D₂) (hf : ScottContinuousOn D₂ f) :
ScottContinuousOn D₁ f := fun _ hdD₁ hd₁ hd₂ _ hda => hf (hD hdD₁) hd₁ hd₂ hda
protected theorem ScottContinuousOn.monotone (D : Set (Set α)) (hD : ∀ a b : α, a ≤ b → {a, b} ∈ D)
(h : ScottContinuousOn D f) : Monotone f := by
refine fun a b hab =>
(h (hD a b hab) (insert_nonempty _ _) (directedOn_pair hab) ?_).1
(mem_image_of_mem _ <| mem_insert _ _)
rw [IsLUB, upperBounds_insert, upperBounds_singleton,
inter_eq_self_of_subset_right (Ici_subset_Ici.2 hab)]
exact isLeast_Ici
@[fun_prop, to_fun (attr := simp)]
lemma ScottContinuousOn.id : ScottContinuousOn D (id : α → α) := by simp [ScottContinuousOn]
@[fun_prop, to_fun (attr := simp)]
lemma ScottContinuousOn.const (x : β) : ScottContinuousOn D (Function.const α x) := by
rintro s _ ⟨a⟩ _ _ _
simp [IsLUB, IsLeast, upperBounds, lowerBounds]; grind
@[fun_prop, to_fun]
theorem ScottContinuousOn.comp {g : β → γ} {D'}
(hD : ∀ a b : α, a ≤ b → {a, b} ∈ D) (hD' : Set.MapsTo (f '' ·) D D')
(hg : ScottContinuousOn D' g) (hf : ScottContinuousOn D f) :
ScottContinuousOn D (g ∘ f) := by
intro d hd₁ hd₂ hd₃ a ha
have hd : DirectedOn (fun x1 x2 ↦ x1 ≤ x2) (f '' d) := by
have := hf.monotone
simp only [Monotone, DirectedOn, mem_image, exists_exists_and_eq_and, forall_exists_index,
and_imp, forall_apply_eq_imp_iff₂] at ⊢ this hd₃
grind
rw [Set.image_comp]
exact hg (hD' hd₁) ⟨f hd₂.choose, by grind⟩ hd (hf hd₁ hd₂ hd₃ ha)
@[fun_prop, to_fun]
theorem ScottContinuousOn.image_comp {g : β → γ}
(hD : ∀ a b : α, a ≤ b → {a, b} ∈ D)
(hg : ScottContinuousOn ((f '' ·) '' D) g)
(hf : ScottContinuousOn D f) :
ScottContinuousOn D (g ∘ f) :=
ScottContinuousOn.comp hD (Set.mapsTo_image (f '' ·) D) hg hf
@[fun_prop]
lemma ScottContinuousOn.prodMk {g : α → γ} (hD : ∀ a b : α, a ≤ b → {a, b} ∈ D)
(hf : ScottContinuousOn D f) (hg : ScottContinuousOn D g) :
ScottContinuousOn D fun x => (f x, g x) := fun d hd₁ hd₂ hd₃ a hda => by
rw [IsLUB, IsLeast, upperBounds]
constructor
· simp only [mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, mem_setOf_eq,
Prod.mk_le_mk]
intro b hb
exact ⟨hf.monotone D hD (hda.1 hb), hg.monotone D hD (hda.1 hb)⟩
· intro ⟨p₁, p₂⟩ hp
simp only [mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, mem_setOf_eq,
Prod.mk_le_mk] at hp
constructor
· rw [isLUB_le_iff (hf hd₁ hd₂ hd₃ hda), upperBounds]
simp only [mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, mem_setOf_eq]
intro _ hb
exact (hp _ hb).1
· rw [isLUB_le_iff (hg hd₁ hd₂ hd₃ hda), upperBounds]
simp only [mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, mem_setOf_eq]
intro _ hb
exact (hp _ hb).2
@[simp, fun_prop]
lemma ScottContinuousOn.fst {D} : ScottContinuousOn D (Prod.fst : α × β → α) := by
intro d hd₁ hd₂ hd₃ a ha
simp only [isLUB_prod] at ha
exact ha.1
@[simp, fun_prop]
lemma ScottContinuousOn.snd {D} : ScottContinuousOn D (Prod.snd : α × β → β) := by
intro d hd₁ hd₂ hd₃ a ha
simp only [isLUB_prod] at ha
exact ha.2
/-- A function between preorders is said to be Scott continuous if it preserves `IsLUB` on directed
sets. It can be shown that a function is Scott continuous if and only if it is continuous w.r.t. the
Scott topology.
-/
@[fun_prop]
def ScottContinuous (f : α → β) : Prop :=
∀ ⦃d : Set α⦄, d.Nonempty → DirectedOn (· ≤ ·) d → ∀ ⦃a⦄, IsLUB d a → IsLUB (f '' d) (f a)
@[simp] lemma scottContinuousOn_univ : ScottContinuousOn univ f ↔ ScottContinuous f := by
simp [ScottContinuousOn, ScottContinuous]
lemma ScottContinuous.scottContinuousOn {D : Set (Set α)} :
ScottContinuous f → ScottContinuousOn D f := fun h _ _ d₂ d₃ _ hda => h d₂ d₃ hda
protected theorem ScottContinuous.monotone (h : ScottContinuous f) : Monotone f :=
h.scottContinuousOn.monotone univ (fun _ _ _ ↦ mem_univ _)
@[fun_prop, to_fun (attr := simp)]
lemma ScottContinuous.id : ScottContinuous (id : α → α) := by simp [ScottContinuous]
@[fun_prop, to_fun (attr := simp)]
lemma ScottContinuous.const (x : β) : ScottContinuous (Function.const α x) := by
simp_rw [← scottContinuousOn_univ, ScottContinuousOn.const]
@[fun_prop, to_fun]
lemma ScottContinuous.comp {g : β → γ}
(hf : ScottContinuous f) (hg : ScottContinuous g) :
ScottContinuous (g ∘ f) := by
rw [← scottContinuousOn_univ] at ⊢ hf hg
exact ScottContinuousOn.comp (by simp) (by simp [MapsTo]) hg hf
@[fun_prop]
lemma ScottContinuous.prodMk {g : α → γ}
(hf : ScottContinuous f) (hg : ScottContinuous g) :
ScottContinuous fun x => (f x, g x) := by
rw [← scottContinuousOn_univ] at ⊢ hf hg
exact ScottContinuousOn.prodMk (by grind) hf hg
@[simp, fun_prop]
lemma ScottContinuous.fst : ScottContinuous (Prod.fst : α × β → α) := by
simp_rw [← scottContinuousOn_univ, ScottContinuousOn.fst]
@[simp, fun_prop]
lemma ScottContinuous.snd : ScottContinuous (Prod.snd : α × β → β) := by
simp_rw [← scottContinuousOn_univ, ScottContinuousOn.snd]
end ScottContinuous
section SemilatticeSup
variable [SemilatticeSup β]
/-- The join operation is Scott continuous -/
@[fun_prop]
lemma ScottContinuous.sup₂ :
ScottContinuous fun b : β × β => (b.1 ⊔ b.2 : β) := fun d _ _ ⟨p₁, p₂⟩ hdp => by
simp only [IsLUB, IsLeast, upperBounds, Prod.forall, mem_setOf_eq, Prod.mk_le_mk] at hdp
simp only [IsLUB, IsLeast, upperBounds, mem_image, Prod.exists, forall_exists_index, and_imp]
have e1 : (p₁, p₂) ∈ lowerBounds {x | ∀ (b₁ b₂ : β), (b₁, b₂) ∈ d → (b₁, b₂) ≤ x} := hdp.2
simp only [lowerBounds, mem_setOf_eq, Prod.forall, Prod.mk_le_mk] at e1
refine ⟨fun a b₁ b₂ hbd hba => ?_,fun b hb => ?_⟩
· rw [← hba]
exact sup_le_sup (hdp.1 _ _ hbd).1 (hdp.1 _ _ hbd).2
· rw [sup_le_iff]
exact e1 _ _ fun b₁ b₂ hb' => sup_le_iff.mp (hb b₁ b₂ hb' rfl)
@[fun_prop]
lemma ScottContinuousOn.sup₂ {D : Set (Set (β × β))} :
ScottContinuousOn D fun (a, b) => (a ⊔ b : β) :=
ScottContinuous.sup₂.scottContinuousOn
end SemilatticeSup