Skip to content

Commit 43573b8

Browse files
committed
More theory cleanup
1 parent 3a5f0e6 commit 43573b8

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

src/Init/Internal/Order/Basic.lean

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ theorem monotone_dite
423423

424424
end monotone_lemmas
425425

426-
section prod_order
426+
section pprod_order
427427

428428
open PartialOrder
429429

@@ -440,87 +440,96 @@ instance [PartialOrder α] [PartialOrder β] : PartialOrder (α ×' β) where
440440
dsimp at *
441441
rw [rel_antisymm ha.1 hb.1, rel_antisymm ha.2 hb.2]
442442

443-
theorem monotone_prod [PartialOrder α] [PartialOrder β] [PartialOrder γ]
443+
theorem monotone_pprod [PartialOrder α] [PartialOrder β] [PartialOrder γ]
444444
{f : γ → α} {g : γ → β} (hf : monotone f) (hg : monotone g) :
445445
monotone (fun x => PProd.mk (f x) (g x)) :=
446446
fun _ _ h12 => ⟨hf _ _ h12, hg _ _ h12⟩
447447

448-
theorem monotone_fst [PartialOrder α] [PartialOrder β] [PartialOrder γ]
448+
theorem monotone_pprod_fst [PartialOrder α] [PartialOrder β] [PartialOrder γ]
449449
{f : γ → α ×' β} (hf : monotone f) : monotone (fun x => (f x).1) :=
450450
fun _ _ h12 => (hf _ _ h12).1
451451

452-
theorem monotone_snd [PartialOrder α] [PartialOrder β] [PartialOrder γ]
452+
theorem monotone_pprod_snd [PartialOrder α] [PartialOrder β] [PartialOrder γ]
453453
{f : γ → α ×' β} (hf : monotone f) : monotone (fun x => (f x).2) :=
454454
fun _ _ h12 => (hf _ _ h12).2
455455

456-
def chain_fst [CCPO α] [CCPO β] (c : α ×' β → Prop) : α → Prop := (fun a => ∃ b, c ⟨a, b⟩)
457-
def chain_snd [CCPO α] [CCPO β] (c : α ×' β → Prop) : β → Prop := (fun b => ∃ a, c ⟨a, b⟩)
456+
def chain_pprod_fst [CCPO α] [CCPO β] (c : α ×' β → Prop) : α → Prop := fun a => ∃ b, c ⟨a, b⟩
457+
def chain_pprod_snd [CCPO α] [CCPO β] (c : α ×' β → Prop) : β → Prop := fun b => ∃ a, c ⟨a, b⟩
458458

459-
theorem chain.fst [CCPO α] [CCPO β] (c : α ×' β → Prop) (hchain : chain c) :
460-
chain (chain_fst c) := by
459+
theorem chain.pprod_fst [CCPO α] [CCPO β] (c : α ×' β → Prop) (hchain : chain c) :
460+
chain (chain_pprod_fst c) := by
461461
intro a₁ a₂ ⟨b₁, h₁⟩ ⟨b₂, h₂⟩
462462
cases hchain ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h₁ h₂
463463
case inl h => left; exact h.1
464464
case inr h => right; exact h.1
465465

466-
theorem chain.snd [CCPO α] [CCPO β] (c : α ×' β → Prop) (hchain : chain c) :
467-
chain (chain_snd c) := by
466+
theorem chain.pprod_snd [CCPO α] [CCPO β] (c : α ×' β → Prop) (hchain : chain c) :
467+
chain (chain_pprod_snd c) := by
468468
intro b₁ b₂ ⟨a₁, h₁⟩ ⟨a₂, h₂⟩
469469
cases hchain ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h₁ h₂
470470
case inl h => left; exact h.2
471471
case inr h => right; exact h.2
472472

473473
instance [CCPO α] [CCPO β] : CCPO (α ×' β) where
474-
csup c := ⟨CCPO.csup (chain_fst c), CCPO.csup (chain_snd c)⟩
474+
csup c := ⟨CCPO.csup (chain_pprod_fst c), CCPO.csup (chain_pprod_snd c)⟩
475475
csup_spec := by
476476
intro ⟨a, b⟩ c hchain
477477
dsimp
478478
constructor
479479
next =>
480480
intro ⟨h₁, h₂⟩ ⟨a', b'⟩ cab
481-
dsimp at *
482-
constructor <;> dsimp
481+
constructor <;> dsimp at *
483482
· apply rel_trans ?_ h₁
484-
apply le_csup hchain.fst
483+
apply le_csup hchain.pprod_fst
485484
exact ⟨b', cab⟩
486485
· apply rel_trans ?_ h₂
487-
apply le_csup hchain.snd
486+
apply le_csup hchain.pprod_snd
488487
exact ⟨a', cab⟩
489488
next =>
490489
intro h
491490
constructor <;> dsimp
492-
· apply csup_le hchain.fst
491+
· apply csup_le hchain.pprod_fst
493492
intro a' ⟨b', hcab⟩
494493
apply (h _ hcab).1
495-
· apply csup_le hchain.snd
494+
· apply csup_le hchain.pprod_snd
496495
intro b' ⟨a', hcab⟩
497496
apply (h _ hcab).2
498497

499-
theorem admissible_fst {α : Sort u} {β : Sort v} [CCPO α] [CCPO β] (P : α → Prop)
498+
theorem admissible_pprod_fst {α : Sort u} {β : Sort v} [CCPO α] [CCPO β] (P : α → Prop)
500499
(hadm : admissible P) : admissible (fun (x : α ×' β) => P x.1) := by
501500
intro c hchain h
502-
apply hadm _ hchain.fst
501+
apply hadm _ hchain.pprod_fst
503502
intro x ⟨y, hxy⟩
504503
apply h ⟨x,y⟩ hxy
505504

506-
theorem admissible_snd {α : Sort u} {β : Sort v} [CCPO α] [CCPO β] (P : β → Prop)
505+
theorem admissible_pprod_snd {α : Sort u} {β : Sort v} [CCPO α] [CCPO β] (P : β → Prop)
507506
(hadm : admissible P) : admissible (fun (x : α ×' β) => P x.2) := by
508507
intro c hchain h
509-
apply hadm _ hchain.snd
508+
apply hadm _ hchain.pprod_snd
510509
intro y ⟨x, hxy⟩
511510
apply h ⟨x,y⟩ hxy
512511

513-
end prod_order
512+
end pprod_order
514513

515514
section flat_order
516515

517516
variable {α : Sort u}
518517

519518
set_option linter.unusedVariables false in
519+
/--
520+
`FlatOrder b` wraps the type `α` with the flat partial order generated by `∀ x, b ⊑ x`.
521+
522+
This is intended to be used in the construction of `partial_fixpoint`, and not meant to be used otherwise.
523+
-/
520524
def FlatOrder {α : Sort u} (b : α) := α
521525

522526
variable {b : α}
523527

528+
/--
529+
The flat partial order generated by `∀ x, b ⊑ x`.
530+
531+
This is intended to be used in the construction of `partial_fixpoint`, and not meant to be used otherwise.
532+
-/
524533
inductive FlatOrder.rel : (x y : FlatOrder b) → Prop where
525534
| bot : rel b x
526535
| refl : rel x x
@@ -590,9 +599,15 @@ end flat_order
590599

591600
section mono_bind
592601

602+
/--
603+
The class `MonoBind m` indicates that every `m α` has a `PartialOrder`, and that the bind operation
604+
on `m` is monotone in both arguments with regard to that order.
605+
606+
This is intended to be used in the construction of `partial_fixpoint`, and not meant to be used otherwise.
607+
-/
593608
class MonoBind (m : Type u → Type v) [Bind m] [∀ α, PartialOrder (m α)] where
594-
bind_mono_left (a₁ a₂ : m α) (f : α → m b) (h : a₁ ⊑ a₂) : a₁ >>= f ⊑ a₂ >>= f
595-
bind_mono_right (a : m α) (f₁ f₂ : α → m b) (h : ∀ x, f₁ x ⊑ f₂ x) : a >>= f₁ ⊑ a >>= f₂
609+
bind_mono_left {a₁ a₂ : m α} {f : α → m b} (h : a₁ ⊑ a₂) : a₁ >>= f ⊑ a₂ >>= f
610+
bind_mono_right {a : m α} {f₁ f₂ : α → m b} (h : ∀ x, f₁ x ⊑ f₂ x) : a >>= f₁ ⊑ a >>= f₂
596611

597612
theorem monotone_bind
598613
(m : Type u → Type v) [Bind m] [∀ α, PartialOrder (m α)] [MonoBind m]
@@ -604,18 +619,18 @@ theorem monotone_bind
604619
monotone (fun (x : γ) => f x >>= g x) := by
605620
intro x₁ x₂ hx₁₂
606621
apply PartialOrder.rel_trans
607-
· apply MonoBind.bind_mono_left _ _ _ (hmono₁ _ _ hx₁₂)
608-
· apply MonoBind.bind_mono_right _ _ _ (fun y => monotone_apply y _ hmono₂ _ _ hx₁₂)
622+
· apply MonoBind.bind_mono_left (hmono₁ _ _ hx₁₂)
623+
· apply MonoBind.bind_mono_right (fun y => monotone_apply y _ hmono₂ _ _ hx₁₂)
609624

610625
instance : PartialOrder (Option α) := inferInstanceAs (PartialOrder (FlatOrder none))
611626
noncomputable instance : CCPO (Option α) := inferInstanceAs (CCPO (FlatOrder none))
612627
noncomputable instance : MonoBind Option where
613-
bind_mono_left _ _ _ h := by
628+
bind_mono_left h := by
614629
cases h
615630
· exact FlatOrder.rel.bot
616631
· exact FlatOrder.rel.refl
617-
bind_mono_right a _ _ h := by
618-
cases a
632+
bind_mono_right h := by
633+
cases ‹Option _›
619634
· exact FlatOrder.rel.refl
620635
· exact h _
621636

@@ -626,10 +641,10 @@ theorem admissible_eq_some (P : Prop) (y : α) :
626641
instance [Monad m] [inst : ∀ α, PartialOrder (m α)] : PartialOrder (ExceptT ε m α) := inst _
627642
instance [Monad m] [∀ α, PartialOrder (m α)] [inst : ∀ α, CCPO (m α)] : CCPO (ExceptT ε m α) := inst _
628643
instance [Monad m] [∀ α, PartialOrder (m α)] [∀ α, CCPO (m α)] [MonoBind m] : MonoBind (ExceptT ε m) where
629-
bind_mono_left a₁ a₂ f h₁₂ := by
644+
bind_mono_left h₁₂ := by
630645
apply MonoBind.bind_mono_left (m := m)
631646
exact h₁₂
632-
bind_mono_right a₁ a₂ f h₁₂ := by
647+
bind_mono_right h₁₂ := by
633648
apply MonoBind.bind_mono_right (m := m)
634649
intro x
635650
cases x

0 commit comments

Comments
 (0)