@@ -70,8 +70,9 @@ namespace PFun
70
70
71
71
variable {α β γ δ ε ι : Type _}
72
72
73
- instance : Inhabited (α →. β) :=
73
+ instance inhabited : Inhabited (α →. β) :=
74
74
⟨fun _ => Part.none⟩
75
+ #align pfun.inhabited PFun.inhabited
75
76
76
77
/-- The domain of a partial function -/
77
78
def Dom (f : α →. β) : Set α :=
@@ -134,11 +135,13 @@ theorem asSubtype_eq_of_mem {f : α →. β} {x : α} {y : β} (fxy : y ∈ f x)
134
135
#align pfun.as_subtype_eq_of_mem PFun.asSubtype_eq_of_mem
135
136
136
137
/-- Turn a total function into a partial function. -/
138
+ @[coe]
137
139
protected def lift (f : α → β) : α →. β := fun a => Part.some (f a)
138
140
#align pfun.lift PFun.lift
139
141
140
- instance : Coe (α → β) (α →. β) :=
142
+ instance coe : Coe (α → β) (α →. β) :=
141
143
⟨PFun.lift⟩
144
+ #align pfun.has_coe PFun.coe
142
145
143
146
@[simp]
144
147
theorem coe_val (f : α → β) (a : α) : (f : α →. β) a = Part.some (f a) :=
@@ -219,16 +222,18 @@ theorem bind_apply (f : α →. β) (g : β → α →. γ) (a : α) : f.bind g
219
222
def map (f : β → γ) (g : α →. β) : α →. γ := fun a => (g a).map f
220
223
#align pfun.map PFun.map
221
224
222
- instance : Monad (PFun α) where
225
+ instance monad : Monad (PFun α) where
223
226
pure := PFun.pure
224
227
bind := PFun.bind
225
228
map := PFun.map
229
+ #align pfun.monad PFun.monad
226
230
227
- instance : LawfulMonad (PFun α) := LawfulMonad.mk'
231
+ instance lawfulMonad : LawfulMonad (PFun α) := LawfulMonad.mk'
228
232
(bind_pure_comp := fun f x => funext fun a => Part.bind_some_eq_map _ _)
229
233
(id_map := fun f => by funext a ; dsimp [Functor.map, PFun.map] ; cases f a; rfl)
230
234
(pure_bind := fun x f => funext fun a => Part.bind_some _ (f x))
231
235
(bind_assoc := fun f g k => funext fun a => (f a).bind_assoc (fun b => g b a) fun b => k b a)
236
+ #align pfun.is_lawful_monad PFun.lawfulMonad
232
237
233
238
theorem pure_defined (p : Set α) (x : β) : p ⊆ (@PFun.pure α _ x).Dom :=
234
239
p.subset_univ
@@ -245,8 +250,7 @@ exists. By abusing notation to illustrate, either `f a` is in the `β` part of `
245
250
case `f.fix a` returns `f a`), or it is undefined (in which case `f.fix a` is undefined as well), or
246
251
it is in the `α` part of `β ⊕ α` (in which case we repeat the procedure, so `f.fix a` will return
247
252
`f.fix (f a)`). -/
248
- -- Porting note: had to mark `noncomputable`
249
- noncomputable def fix (f : α →. Sum β α) : α →. β := fun a =>
253
+ def fix (f : α →. Sum β α) : α →. β := fun a =>
250
254
Part.assert (Acc (fun x y => Sum.inr x ∈ f y) a) $ fun h =>
251
255
WellFounded.fixF
252
256
(fun a IH =>
@@ -323,9 +327,8 @@ theorem fix_fwd {f : α →. Sum β α} {b : β} {a a' : α} (hb : b ∈ f.fix a
323
327
#align pfun.fix_fwd PFun.fix_fwd
324
328
325
329
/-- A recursion principle for `PFun.fix`. -/
326
- -- Porting note: had to add `noncomputable`
327
330
@[elab_as_elim]
328
- noncomputable def fixInduction {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α} (h : b ∈ f.fix a)
331
+ def fixInduction {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α} (h : b ∈ f.fix a)
329
332
(H : ∀ a', b ∈ f.fix a' → (∀ a'', Sum.inr a'' ∈ f a' → C a'') → C a') : C a := by
330
333
have h₂ := (Part.mem_assert_iff.1 h).snd;
331
334
-- Porting note: revert/intro trick required to address `generalize_proofs` bug
@@ -351,7 +354,7 @@ theorem fixInduction_spec {C : α → Sort _} {f : α →. Sum β α} {b : β} {
351
354
`a` given that `f a` inherits `P` from `a` and `P` holds for preimages of `b`.
352
355
-/
353
356
@[elab_as_elim]
354
- noncomputable def fixInduction' {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α}
357
+ def fixInduction' {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α}
355
358
(h : b ∈ f.fix a) (hbase : ∀ a_final : α, Sum.inl b ∈ f a_final → C a_final)
356
359
(hind : ∀ a₀ a₁ : α, b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀) : C a := by
357
360
refine' fixInduction h fun a' h ih => _
0 commit comments