@@ -988,10 +988,20 @@ theorem monotone_stateTRun [PartialOrder γ]
988988 monotone (fun (x : γ) => StateT.run (f x) s) :=
989989 monotone_apply s _ hmono
990990
991- -- TODO: axiomatize these instances (ideally without `Nonempty ε`) when EIO and friends are opaque
991+ noncomputable def EST.bot [Nonempty ε] : EST ε σ α :=
992+ fun s => .error Classical.ofNonempty (Classical.choice ⟨s⟩)
992993
993- noncomputable instance [Nonempty ε] : CCPO (EST ε σ α) :=
994- inferInstanceAs (CCPO ((s : _) → FlatOrder (.error Classical.ofNonempty (Classical.choice ⟨s⟩))))
994+ -- Essentially
995+ -- instance [Nonempty ε] : CCPO (EST ε σ α) :=
996+ -- inferInstanceAs (CCPO ((s : _) → FlatOrder (EST.bot s)))
997+ -- but hat would incur a noncomputable on the instance
998+
999+ instance [Nonempty ε] : CCPO (EST ε σ α) where
1000+ rel := PartialOrder.rel (α := ∀ s, FlatOrder (EST.bot s))
1001+ rel_refl := PartialOrder.rel_refl
1002+ rel_antisymm := PartialOrder.rel_antisymm
1003+ rel_trans := PartialOrder.rel_trans
1004+ has_csup hchain := CCPO.has_csup (α := ∀ s, FlatOrder (EST.bot s)) hchain
9951005
9961006instance [Nonempty ε] : MonoBind (EST ε σ) where
9971007 bind_mono_left {_ _ a₁ a₂ f} h₁₂ := by
@@ -1011,39 +1021,17 @@ instance [Nonempty ε] : MonoBind (EST ε σ) where
10111021 · apply h₁₂
10121022 · exact .refl
10131023
1014- noncomputable instance [Nonempty α] : CCPO (ST σ α) :=
1015- inferInstanceAs (CCPO ((s : _) → FlatOrder (.mk Classical.ofNonempty (Classical.choice ⟨s⟩))))
1016-
1017- noncomputable instance [Nonempty α] : CCPO (BaseIO α) :=
1018- inferInstanceAs (CCPO (ST IO.RealWorld α))
1019-
1020- noncomputable instance [Nonempty ε] : CCPO (EIO ε α) :=
1024+ instance [Nonempty ε] : CCPO (EIO ε α) :=
10211025 inferInstanceAs (CCPO (EST ε IO.RealWorld α))
10221026
1023- noncomputable instance [Nonempty ε] : MonoBind (EIO ε) :=
1027+ instance [Nonempty ε] : MonoBind (EIO ε) :=
10241028 inferInstanceAs (MonoBind (EST ε IO.RealWorld))
10251029
1026- -- Quick hack to get a computable instance
10271030instance : CCPO (IO α) :=
1028- inferInstanceAs (CCPO ((s : _) → FlatOrder (.error (.userError " csup ∅ " ) (Classical.choice ⟨s⟩)) ))
1031+ inferInstanceAs (CCPO (EIO IO.Error α ))
10291032
1030- instance : MonoBind IO where
1031- bind_mono_left {_ _ a₁ a₂ f} h₁₂ := by
1032- intro s
1033- specialize h₁₂ s
1034- change FlatOrder.rel (a₁.bind f s) (a₂.bind f s)
1035- simp only [EST.bind]
1036- generalize a₁ s = a₁ at h₁₂; generalize a₂ s = a₂ at h₁₂
1037- cases h₁₂
1038- · exact .bot
1039- · exact .refl
1040- bind_mono_right {_ _ a f₁ f₂} h₁₂ := by
1041- intro w
1042- change FlatOrder.rel (a.bind f₁ w) (a.bind f₂ w)
1043- simp only [EST.bind]
1044- split
1045- · apply h₁₂
1046- · exact .refl
1033+ instance : MonoBind IO :=
1034+ inferInstanceAs (MonoBind (EIO IO.Error))
10471035
10481036end mono_bind
10491037
0 commit comments