-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProp.lean
More file actions
142 lines (121 loc) · 4.07 KB
/
Prop.lean
File metadata and controls
142 lines (121 loc) · 4.07 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
module
import QuasiBorelSpaces.Basic
import QuasiBorelSpaces.Pi
public import QuasiBorelSpaces.Defs
public import QuasiBorelSpaces.Prod
public import QuasiBorelSpaces.Subtype
public section
variable
{A : Type*} {_ : QuasiBorelSpace A}
{B : Type*} {_ : QuasiBorelSpace B}
{I : Sort*} [Countable I]
namespace QuasiBorelSpace.Prop
example : DiscreteQuasiBorelSpace Prop := inferInstance
@[fun_prop]
lemma isHom_ite
{p : A → Prop} (hp : IsHom p) [inst : DecidablePred p]
{f : A → B} (hf : IsHom f)
{g : A → B} (hg : IsHom g)
: IsHom (fun x ↦ if p x then f x else g x) := by
classical
have (x : A) : inst x = Classical.dec _ := by subsingleton
conv => enter [1, x]; rw [this]
apply isHom_cases (f := fun b x ↦ if b then f x else g x) hp
intro
split_ifs <;> assumption
@[fun_prop]
lemma isHom_not
{f : A → Prop} (hf : IsHom f)
: IsHom (fun x ↦ ¬f x) := by
fun_prop
@[fun_prop]
lemma isHom_and
{f g : A → Prop} (hf : IsHom f) (hg : IsHom g)
: IsHom (fun x ↦ f x ∧ g x) := by
fun_prop
@[fun_prop]
lemma isHom_or
{f g : A → Prop} (hf : IsHom f) (hg : IsHom g)
: IsHom (fun x ↦ f x ∨ g x) := by
fun_prop
lemma isHom_imp
{f g : A → Prop} (hf : IsHom f) (hg : IsHom g)
: IsHom (fun x ↦ f x → g x) := by
apply isHom_comp' (f := fun x ↦ x.1 → x.2) (g := fun x ↦ (f x, g x))
· simp only [isHom_of_discrete_countable]
· fun_prop
@[fun_prop]
lemma isHom_iff
{f g : A → Prop} (hf : IsHom f) (hg : IsHom g)
: IsHom (fun x ↦ f x ↔ g x) := by
fun_prop
lemma isHom_forall
{f : I → A → Prop} (hf : ∀ i, IsHom (f i))
: IsHom (fun x ↦ ∀i, f i x) := by
rw [isHom_def]
intro φ hφ
simp only [isHom_ofMeasurableSpace]
apply Measurable.forall
intro i
rw [←isHom_iff_measurable]
fun_prop
@[fun_prop]
lemma isHom_exists
{f : I → A → Prop} (hf : ∀ i, IsHom (f i))
: IsHom (fun x ↦ ∃i, f i x) := by
rw [isHom_def]
intro φ hφ
simp only [isHom_ofMeasurableSpace]
apply Measurable.exists
intro i
rw [←isHom_iff_measurable]
fun_prop
@[fun_prop]
lemma isHom_dite
{p : A → Prop} (hp : IsHom p) [inst : DecidablePred p]
{f : (x : A) → p x → B} (hf : IsHom fun x : Subtype p ↦ f x.val x.property)
{g : (x : A) → ¬p x → B} (hg : IsHom fun x : Subtype (fun x ↦ ¬p x) ↦ g x.val x.property)
: IsHom (fun x ↦ if h : p x then f x h else g x h) := by
classical
have : inst = fun x ↦ Classical.dec _ := by subsingleton
subst this
wlog hp : Nonempty (Subtype p)
· simp only [nonempty_subtype, not_exists] at hp
simp only [hp, ↓reduceDIte]
have : IsHom fun x : A ↦ (⟨x, hp x⟩ : Subtype fun x ↦ ¬p x) := by fun_prop
apply isHom_comp' hg this
wlog hnp : Nonempty (Subtype fun x ↦ ¬p x)
· simp only [nonempty_subtype, not_exists, Decidable.not_not] at hnp
simp only [hnp, ↓reduceDIte]
have : IsHom fun x : A ↦ (⟨x, hnp x⟩ : Subtype p) := by fun_prop
apply isHom_comp' hf this
let f' := fun x : Subtype p ↦ f x.val x.property
let g' := fun x : Subtype (fun x ↦ ¬p x) ↦ g x.val x.property
let k q x :=
if q
then f' (if h : p x then ⟨x, h⟩ else Classical.arbitrary _)
else g' (if h : ¬p x then ⟨x, h⟩ else Classical.arbitrary _)
have {x}
: (if h : p x then f x h else g x h)
= if p x
then f' (if h : p x then ⟨x, h⟩ else Classical.arbitrary _)
else g' (if h : ¬p x then ⟨x, h⟩ else Classical.arbitrary _) := by
grind
simp only [this]
apply isHom_ite
· fun_prop
· apply isHom_comp' hf
simp only [Subtype.isHom_def, apply_dite, dite_eq_ite]
apply isHom_ite <;> fun_prop
· apply isHom_comp' hg
simp only [Subtype.isHom_def, apply_dite, dite_eq_ite]
apply isHom_ite <;> fun_prop
@[fun_prop]
lemma isHom_decide
{p : A → Prop} [inst : DecidablePred p] (hp : IsHom p)
: IsHom (fun x ↦ decide (p x)) := by
classical
have : inst = fun x ↦ Classical.dec (p x) := by subsingleton
subst this
apply isHom_cases (f := fun p _ ↦ decide p) <;> fun_prop
end QuasiBorelSpace.Prop