fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
foldrM (m : Type u → Type u) [Monad m] (α : Type u) : Type u := End <| KleisliCat.mk m α
abbrev
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrM
null
foldrM.mk (f : α → m α) : foldrM m α := f
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrM.mk
null
foldrM.get (x : foldrM m α) : α → m α := x @[simps]
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrM.get
null
foldrM.ofFreeMonoid [LawfulMonad m] (f : α → β → m β) : FreeMonoid α →* Monoid.foldrM m β where toFun xs := flip (List.foldrM f) (FreeMonoid.toList xs) map_one' := rfl map_mul' := by intros; funext; apply List.foldrM_append
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrM.ofFreeMonoid
null
foldMap {α ω} [One ω] [Mul ω] (f : α → ω) : t α → ω := traverse (Const.mk' ∘ f)
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldMap
null
foldl (f : α → β → α) (x : α) (xs : t β) : α := (foldMap (Foldl.mk ∘ flip f) xs).get x
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldl
null
foldr (f : α → β → β) (x : β) (xs : t α) : β := (foldMap (Foldr.mk ∘ f) xs).get x
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldr
null
toList : t α → List α := List.reverse ∘ foldl (flip List.cons) []
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
toList
Conceptually, `toList` collects all the elements of a collection in a list. This idea is formalized by `lemma toList_spec (x : t α) : toList x = foldMap FreeMonoid.mk x`. The definition of `toList` is based on `foldl` and `List.cons` for speed. It is faster than using `foldMap FreeMonoid.mk` because, by using `foldl` and `List.cons`, each insertion is done in constant time. As a consequence, `toList` performs in linear. On the other hand, `foldMap FreeMonoid.mk` creates a singleton list around each element and concatenates all the resulting lists. In `xs ++ ys`, concatenation takes a time proportional to `length xs`. Since the order in which concatenation is evaluated is unspecified, nothing prevents each element of the traversable to be appended at the end `xs ++ [x]` which would yield a `O(n²)` run time.
length (xs : t α) : ℕ := down <| foldl (fun l _ => up <| l.down + 1) (up 0) xs variable {m : Type u → Type u} [Monad m]
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
length
null
foldlm (f : α → β → m α) (x : α) (xs : t β) : m α := (foldMap (foldlM.mk ∘ flip f) xs).get x
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldlm
null
foldrm (f : α → β → m β) (x : β) (xs : t α) : m β := (foldMap (foldrM.mk ∘ f) xs).get x
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrm
null
mapFold [Monoid α] [Monoid β] (f : α →* β) : ApplicativeTransformation (Const α) (Const β) where app _ := f preserves_seq' := by intros; simp only [Seq.seq, map_mul] preserves_pure' := by intros; simp only [map_one, pure]
def
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
mapFold
null
Free.map_eq_map (f : α → β) (xs : List α) : f <$> xs = (FreeMonoid.toList (FreeMonoid.map f (FreeMonoid.ofList xs))) := rfl
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
Free.map_eq_map
null
foldl.unop_ofFreeMonoid (f : β → α → β) (xs : FreeMonoid α) (a : β) : unop (Foldl.ofFreeMonoid f xs) a = List.foldl f a (FreeMonoid.toList xs) := rfl variable {t : Type u → Type u} [Traversable t] [LawfulTraversable t] open LawfulTraversable
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldl.unop_ofFreeMonoid
null
foldMap_hom [Monoid α] [Monoid β] (f : α →* β) (g : γ → α) (x : t γ) : f (foldMap g x) = foldMap (f ∘ g) x := calc f (foldMap g x) = f (traverse (Const.mk' ∘ g) x) := rfl _ = (mapFold f).app _ (traverse (Const.mk' ∘ g) x) := rfl _ = traverse ((mapFold f).app _ ∘ Const.mk' ∘ g) x := naturality (mapFold f) _ _ _ = foldMap (f ∘ g) x := rfl
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldMap_hom
null
foldMap_hom_free [Monoid β] (f : FreeMonoid α →* β) (x : t α) : f (foldMap FreeMonoid.of x) = foldMap (f ∘ FreeMonoid.of) x := foldMap_hom f _ x
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldMap_hom_free
null
@[simp] foldl.ofFreeMonoid_comp_of (f : α → β → α) : Foldl.ofFreeMonoid f ∘ FreeMonoid.of = Foldl.mk ∘ flip f := rfl @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldl.ofFreeMonoid_comp_of
null
foldr.ofFreeMonoid_comp_of (f : β → α → α) : Foldr.ofFreeMonoid f ∘ FreeMonoid.of = Foldr.mk ∘ f := rfl @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldr.ofFreeMonoid_comp_of
null
foldlm.ofFreeMonoid_comp_of {m} [Monad m] [LawfulMonad m] (f : α → β → m α) : foldlM.ofFreeMonoid f ∘ FreeMonoid.of = foldlM.mk ∘ flip f := by ext1 x simp only [foldlM.ofFreeMonoid, Function.flip_def, MonoidHom.coe_mk, OneHom.coe_mk, Function.comp_apply, FreeMonoid.toList_of, List.foldlM_cons, List.foldlM_nil, bind_pure, foldlM.mk, op_inj] rfl @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldlm.ofFreeMonoid_comp_of
null
foldrm.ofFreeMonoid_comp_of {m} [Monad m] [LawfulMonad m] (f : β → α → m α) : foldrM.ofFreeMonoid f ∘ FreeMonoid.of = foldrM.mk ∘ f := by ext simp [(· ∘ ·), foldrM.ofFreeMonoid, foldrM.mk, Function.flip_def]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrm.ofFreeMonoid_comp_of
null
toList_spec (xs : t α) : toList xs = FreeMonoid.toList (foldMap FreeMonoid.of xs) := Eq.symm <| calc FreeMonoid.toList (foldMap FreeMonoid.of xs) = FreeMonoid.toList (foldMap FreeMonoid.of xs).reverse.reverse := by simp only [FreeMonoid.reverse_reverse] _ = (List.foldr cons [] (foldMap FreeMonoid.of xs).toList.reverse).reverse := by simp _ = (unop (Foldl.ofFreeMonoid (flip cons) (foldMap FreeMonoid.of xs)) []).reverse := by simp [Function.flip_def, List.foldr_reverse, Foldl.ofFreeMonoid, unop_op] _ = toList xs := by rw [foldMap_hom_free (Foldl.ofFreeMonoid (flip <| @cons α))] simp only [toList, foldl, Foldl.get, foldl.ofFreeMonoid_comp_of, Function.comp_apply]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
toList_spec
null
foldMap_map [Monoid γ] (f : α → β) (g : β → γ) (xs : t α) : foldMap g (f <$> xs) = foldMap (g ∘ f) xs := by simp only [foldMap, traverse_map, Function.comp_def]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldMap_map
null
foldl_toList (f : α → β → α) (xs : t β) (x : α) : foldl f x xs = List.foldl f x (toList xs) := by rw [← FreeMonoid.toList_ofList (toList xs), ← foldl.unop_ofFreeMonoid] simp only [foldl, toList_spec, foldMap_hom_free, foldl.ofFreeMonoid_comp_of, Foldl.get, FreeMonoid.ofList_toList]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldl_toList
null
foldr_toList (f : α → β → β) (xs : t α) (x : β) : foldr f x xs = List.foldr f x (toList xs) := by change _ = Foldr.ofFreeMonoid _ (FreeMonoid.ofList <| toList xs) _ rw [toList_spec, foldr, Foldr.get, FreeMonoid.ofList_toList, foldMap_hom_free, foldr.ofFreeMonoid_comp_of]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldr_toList
null
toList_map (f : α → β) (xs : t α) : toList (f <$> xs) = f <$> toList xs := by simp only [toList_spec, Free.map_eq_map, foldMap_hom, foldMap_map, FreeMonoid.ofList_toList, FreeMonoid.map_of, Function.comp_def] @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
toList_map
null
foldl_map (g : β → γ) (f : α → γ → α) (a : α) (l : t β) : foldl f a (g <$> l) = foldl (fun x y => f x (g y)) a l := by simp only [foldl, foldMap_map, Function.comp_def, Function.flip_def] @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldl_map
null
foldr_map (g : β → γ) (f : γ → α → α) (a : α) (l : t β) : foldr f a (g <$> l) = foldr (f ∘ g) a l := by simp only [foldr, foldMap_map, Function.comp_def] @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldr_map
null
toList_eq_self {xs : List α} : toList xs = xs := by simp only [toList_spec, foldMap, traverse] induction xs with | nil => rfl | cons _ _ ih => (conv_rhs => rw [← ih]); rfl
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
toList_eq_self
null
length_toList {xs : t α} : length xs = List.length (toList xs) := by unfold length rw [foldl_toList] generalize toList xs = ys rw [← Nat.add_zero ys.length] generalize 0 = n induction ys generalizing n with | nil => simp | cons _ _ ih => simp +arith [ih] variable {m : Type u → Type u} [Monad m] [LawfulMonad m]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
length_toList
null
foldlm_toList {f : α → β → m α} {x : α} {xs : t β} : foldlm f x xs = List.foldlM f x (toList xs) := calc foldlm f x xs _ = unop (foldlM.ofFreeMonoid f (FreeMonoid.ofList <| toList xs)) x := by simp only [foldlm, toList_spec, foldMap_hom_free (foldlM.ofFreeMonoid f), foldlm.ofFreeMonoid_comp_of, foldlM.get, FreeMonoid.ofList_toList] _ = List.foldlM f x (toList xs) := by simp [foldlM.ofFreeMonoid, unop_op, flip]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldlm_toList
null
foldrm_toList (f : α → β → m β) (x : β) (xs : t α) : foldrm f x xs = List.foldrM f x (toList xs) := by change _ = foldrM.ofFreeMonoid f (FreeMonoid.ofList <| toList xs) x simp only [foldrm, toList_spec, foldMap_hom_free (foldrM.ofFreeMonoid f), foldrm.ofFreeMonoid_comp_of, foldrM.get, FreeMonoid.ofList_toList] @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrm_toList
null
foldlm_map (g : β → γ) (f : α → γ → m α) (a : α) (l : t β) : foldlm f a (g <$> l) = foldlm (fun x y => f x (g y)) a l := by simp only [foldlm, foldMap_map, Function.comp_def, Function.flip_def] @[simp]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldlm_map
null
foldrm_map (g : β → γ) (f : γ → α → m α) (a : α) (l : t β) : foldrm f a (g <$> l) = foldrm (f ∘ g) a l := by simp only [foldrm, foldMap_map, Function.comp_def]
theorem
Control
[ "Mathlib.Algebra.Group.Opposite", "Mathlib.Algebra.FreeMonoid.Basic", "Mathlib.CategoryTheory.Category.KleisliCat", "Mathlib.CategoryTheory.Endomorphism", "Mathlib.CategoryTheory.Types.Basic", "Mathlib.Control.Traversable.Instances", "Mathlib.Control.Traversable.Lemmas", "Mathlib.Tactic.AdaptationNote...
Mathlib/Control/Fold.lean
foldrm_map
null
Functor.map_id : (id <$> ·) = (id : F α → F α) := funext id_map
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Functor.map_id
null
Functor.map_comp_map (f : α → β) (g : β → γ) : ((g <$> ·) ∘ (f <$> ·) : F α → F γ) = ((g ∘ f) <$> ·) := funext fun _ => (comp_map _ _ _).symm
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Functor.map_comp_map
null
Functor.ext {F} : ∀ {F1 : Functor F} {F2 : Functor F} [@LawfulFunctor F F1] [@LawfulFunctor F F2], (∀ (α β) (f : α → β) (x : F α), @Functor.map _ F1 _ _ f x = @Functor.map _ F2 _ _ f x) → F1 = F2 | ⟨m, mc⟩, ⟨m', mc'⟩, H1, H2, H => by cases show @m = @m' by funext α β f x; apply H congr funext α β have E1 := @map_const _ ⟨@m, @mc⟩ H1 have E2 := @map_const _ ⟨@m, @mc'⟩ H2 exact E1.trans E2.symm
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Functor.ext
null
@[deprecated "Use `pure : α → Id α` instead." (since := "2025-05-21")] id.mk {α : Sort u} : α → id α := id
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
id.mk
Introduce `id` as a quasi-functor. (Note that where a lawful `Monad` or `Applicative` or `Functor` is needed, `Id` is the correct definition).
@[nolint unusedArguments] Const (α : Type*) (_β : Type*) := α
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Const
`Const α` is the constant functor, mapping every type to `α`. When `α` has a monoid structure, `Const α` has an `Applicative` instance. (If `α` has an additive monoid structure, see `Functor.AddConst`.)
@[match_pattern] Const.mk {α β} (x : α) : Const α β := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Const.mk
`Const.mk` is the canonical map `α → Const α β` (the identity), and it can be used as a pattern to extract this value.
Const.mk' {α} (x : α) : Const α PUnit := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Const.mk'
`Const.mk'` is `Const.mk` but specialized to map `α` to `Const α PUnit`, where `PUnit` is the terminal object in `Type*`.
Const.run {α β} (x : Const α β) : α := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Const.run
Extract the element of `α` from the `Const` functor.
protected ext {α β} {x y : Const α β} (h : x.run = y.run) : x = y := h
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
ext
null
@[nolint unusedArguments] protected map {γ α β} (_f : α → β) (x : Const γ β) : Const γ α := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
map
The map operation of the `Const γ` functor.
functor {γ} : Functor (Const γ) where map := @Const.map γ
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
functor
null
lawfulFunctor {γ} : LawfulFunctor (Const γ) := by constructor <;> intros <;> rfl
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
lawfulFunctor
null
AddConst (α : Type*) := Const α
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
AddConst
`AddConst α` is a synonym for constant functor `Const α`, mapping every type to `α`. When `α` has an additive monoid structure, `AddConst α` has an `Applicative` instance. (If `α` has a multiplicative monoid structure, see `Functor.Const`.)
@[match_pattern] AddConst.mk {α β} (x : α) : AddConst α β := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
AddConst.mk
`AddConst.mk` is the canonical map `α → AddConst α β`, which is the identity, where `AddConst α β = Const α β`. It can be used as a pattern to extract this value.
AddConst.run {α β} : AddConst α β → α := id
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
AddConst.run
Extract the element of `α` from the constant functor.
AddConst.functor {γ} : Functor (AddConst γ) := @Const.functor γ
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
AddConst.functor
null
AddConst.lawfulFunctor {γ} : LawfulFunctor (AddConst γ) := @Const.lawfulFunctor γ
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
AddConst.lawfulFunctor
null
Comp (F : Type u → Type w) (G : Type v → Type u) (α : Type v) : Type w := F <| G α
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Comp
`Functor.Comp` is a wrapper around `Function.Comp` for types. It prevents Lean's type class resolution mechanism from trying a `Functor (Comp F id)` when `Functor F` would do.
@[match_pattern] Comp.mk {F : Type u → Type w} {G : Type v → Type u} {α : Type v} (x : F (G α)) : Comp F G α := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Comp.mk
Construct a term of `Comp F G α` from a term of `F (G α)`, which is the same type. Can be used as a pattern to extract a term of `F (G α)`.
Comp.run {F : Type u → Type w} {G : Type v → Type u} {α : Type v} (x : Comp F G α) : F (G α) := x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Comp.run
Extract a term of `F (G α)` from a term of `Comp F G α`, which is the same type.
protected ext {α} {x y : Comp F G α} : x.run = y.run → x = y := id
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
ext
null
protected map {α β : Type v} (h : α → β) : Comp F G α → Comp F G β | Comp.mk x => Comp.mk ((h <$> ·) <$> x)
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
map
The map operation for the composition `Comp F G` of functors `F` and `G`.
functor : Functor (Comp F G) where map := @Comp.map F G _ _ @[functor_norm]
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
functor
null
map_mk {α β} (h : α → β) (x : F (G α)) : h <$> Comp.mk x = Comp.mk ((h <$> ·) <$> x) := rfl @[simp]
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
map_mk
null
protected run_map {α β} (h : α → β) (x : Comp F G α) : (h <$> x).run = (h <$> ·) <$> x.run := rfl variable [LawfulFunctor F] [LawfulFunctor G] variable {α β γ : Type v}
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
run_map
null
protected id_map : ∀ x : Comp F G α, Comp.map id x = x | Comp.mk x => by simp only [Comp.map, id_map, id_map']; rfl
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
id_map
null
protected comp_map (g' : α → β) (h : β → γ) : ∀ x : Comp F G α, Comp.map (h ∘ g') x = Comp.map h (Comp.map g' x) | Comp.mk x => by simp [Comp.map, Comp.mk, functor_norm, Function.comp_def]
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
comp_map
null
lawfulFunctor : LawfulFunctor (Comp F G) where map_const := rfl id_map := Comp.id_map comp_map := Comp.comp_map
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
lawfulFunctor
null
functor_comp_id {F} [AF : Functor F] [LawfulFunctor F] : Comp.functor (G := Id) = AF := @Functor.ext F _ AF (Comp.lawfulFunctor (G := Id)) _ fun _ _ _ _ => rfl
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
functor_comp_id
null
functor_id_comp {F} [AF : Functor F] [LawfulFunctor F] : Comp.functor (F := Id) = AF := @Functor.ext F _ AF (Comp.lawfulFunctor (F := Id)) _ fun _ _ _ _ => rfl
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
functor_id_comp
null
protected seq {α β : Type v} : Comp F G (α → β) → (Unit → Comp F G α) → Comp F G β | Comp.mk f, g => match g () with | Comp.mk x => Comp.mk <| (· <*> ·) <$> f <*> x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
seq
The `<*>` operation for the composition of applicative functors.
@[simp] protected run_pure {α : Type v} : ∀ x : α, (pure x : Comp F G α).run = pure (pure x) | _ => rfl @[simp]
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
run_pure
null
protected run_seq {α β : Type v} (f : Comp F G (α → β)) (x : Comp F G α) : (f <*> x).run = (· <*> ·) <$> f.run <*> x.run := rfl
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
run_seq
null
instApplicativeComp : Applicative (Comp F G) := { map := @Comp.map F G _ _, seq := @Comp.seq F G _ _ }
instance
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
instApplicativeComp
null
Liftp {α : Type u} (p : α → Prop) (x : F α) : Prop := ∃ u : F (Subtype p), Subtype.val <$> u = x
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Liftp
If we consider `x : F α` to, in some sense, contain values of type `α`, predicate `Liftp p x` holds iff every value contained by `x` satisfies `p`.
Liftr {α : Type u} (r : α → α → Prop) (x y : F α) : Prop := ∃ u : F { p : α × α // r p.fst p.snd }, (fun t : { p : α × α // r p.fst p.snd } => t.val.fst) <$> u = x ∧ (fun t : { p : α × α // r p.fst p.snd } => t.val.snd) <$> u = y
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
Liftr
If we consider `x : F α` to, in some sense, contain values of type `α`, then `Liftr r x y` relates `x` and `y` iff (1) `x` and `y` have the same shape and (2) we can pair values `a` from `x` and `b` from `y` so that `r a b` holds.
supp {α : Type u} (x : F α) : Set α := { y : α | ∀ ⦃p⦄, Liftp p x → p y }
def
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
supp
If we consider `x : F α` to, in some sense, contain values of type `α`, then `supp x` is the set of values of type `α` that `x` contains.
of_mem_supp {α : Type u} {x : F α} {p : α → Prop} (h : Liftp p x) : ∀ y ∈ supp x, p y := fun _ hy => hy h
theorem
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
of_mem_supp
null
mapConstRev {f : Type u → Type v} [Functor f] {α β : Type u} : f β → α → f α := fun a b => Functor.mapConst b a
abbrev
Control
[ "Mathlib.Tactic.Attr.Register", "Mathlib.Data.Set.Defs", "Mathlib.Tactic.TypeStar", "Batteries.Tactic.Lint" ]
Mathlib/Control/Functor.lean
mapConstRev
If `f` is a functor, if `fb : f β` and `a : α`, then `mapConstRev fb a` is the result of applying `f.map` to the constant function `β → α` sending everything to `a`, and then evaluating at `fb`. In other words it's `const a <$> fb`.
protected mk (f : σ → m (α × σ)) : StateT σ m α := f @[simp]
def
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
mk
`StateT` doesn't require a constructor, but it appears confusing to declare the following theorem as a simp theorem. ```lean @[simp] theorem run_fun (f : σ → m (α × σ)) (st : σ) : StateT.run (fun s => f s) st = f st := rfl ``` If we declare this theorem as a simp theorem, `StateT.run f st` is simplified to `f st` by eta reduction. This breaks the structure of `StateT`. So, we declare a constructor-like definition `StateT.mk` and a simp theorem for it.
run_mk (f : σ → m (α × σ)) (st : σ) : StateT.run (StateT.mk f) st = f st := rfl
theorem
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
run_mk
null
protected map_const [Monad m] : (Functor.mapConst : α → StateT σ m β → StateT σ m α) = Functor.map ∘ Function.const β := rfl @[simp] lemma run_mapConst [Monad m] [LawfulMonad m] (x : StateT σ m α) (y : β) (st : σ) : (Functor.mapConst y x).run st = Prod.map (Function.const α y) id <$> x.run st := run_map _ _ _
lemma
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
map_const
A copy of `LawfulFunctor.map_const` for `StateT` that holds even if `m` is not lawful.
@[simp] run_monadLift {n} [Monad m] [MonadLiftT n m] (x : n α) : (monadLift x : ExceptT ε m α).run = Except.ok <$> (monadLift x : m α) := rfl @[simp]
theorem
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
run_monadLift
null
run_monadMap {n} [MonadFunctorT n m] (f : ∀ {α}, n α → n α) : (monadMap (@f) x : ExceptT ε m α).run = monadMap (@f) x.run := rfl
theorem
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
run_monadMap
null
protected mk (f : σ → m α) : ReaderT σ m α := f @[simp]
def
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
mk
`ReaderT` doesn't require a constructor, but it appears confusing to declare the following theorem as a simp theorem. ```lean @[simp] theorem run_fun (f : σ → m α) (r : σ) : ReaderT.run (fun r' => f r') r = f r := rfl ``` If we declare this theorem as a simp theorem, `ReaderT.run f st` is simplified to `f st` by eta reduction. This breaks the structure of `ReaderT`. So, we declare a constructor-like definition `ReaderT.mk` and a simp theorem for it.
run_mk (f : σ → m α) (r : σ) : ReaderT.run (ReaderT.mk f) r = f r := rfl
theorem
Control
[ "Mathlib.Tactic.Basic" ]
Mathlib/Control/Lawful.lean
run_mk
null
LawfulFix (α : Type*) [OmegaCompletePartialOrder α] extends Fix α where fix_eq : ∀ {f : α → α}, ωScottContinuous f → Fix.fix f = f (Fix.fix f)
class
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
LawfulFix
Intuitively, a fixed point operator `fix` is lawful if it satisfies `fix f = f (fix f)` for all `f`, but this is inconsistent / uninteresting in most cases due to the existence of "exotic" functions `f`, such as the function that is defined iff its argument is not, familiar from the halting problem. Instead, this requirement is limited to only functions that are `Continuous` in the sense of `ω`-complete partial orders, which excludes the example because it is not monotone (making the input argument less defined can make `f` more defined).
approx_mono' {i : ℕ} : Fix.approx f i ≤ Fix.approx f (succ i) := by induction i with | zero => dsimp [approx]; apply @bot_le _ _ _ (f ⊥) | succ _ i_ih => intro; apply f.monotone; apply i_ih
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
approx_mono'
null
approx_mono ⦃i j : ℕ⦄ (hij : i ≤ j) : approx f i ≤ approx f j := by induction j with | zero => cases hij; exact le_rfl | succ j ih => cases hij; · exact le_rfl exact le_trans (ih ‹_›) (approx_mono' f)
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
approx_mono
null
mem_iff (a : α) (b : β a) : b ∈ Part.fix f a ↔ ∃ i, b ∈ approx f i a := by classical by_cases h₀ : ∃ i : ℕ, (approx f i a).Dom · simp only [Part.fix_def f h₀] constructor <;> intro hh · exact ⟨_, hh⟩ have h₁ := Nat.find_spec h₀ rw [dom_iff_mem] at h₁ obtain ⟨y, h₁⟩ := h₁ replace h₁ := approx_mono' f _ _ h₁ suffices y = b by subst this exact h₁ obtain ⟨i, hh⟩ := hh revert h₁; generalize succ (Nat.find h₀) = j; intro h₁ wlog case : i ≤ j · rcases le_total i j with H | H <;> [skip; symm] <;> apply_assumption <;> assumption replace hh := approx_mono f case _ _ hh apply Part.mem_unique h₁ hh · simp only [fix_def' (⇑f) h₀, not_exists, false_iff, notMem_none] simp only [dom_iff_mem, not_exists] at h₀ intro; apply h₀
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
mem_iff
null
approx_le_fix (i : ℕ) : approx f i ≤ Part.fix f := fun a b hh ↦ by rw [mem_iff f] exact ⟨_, hh⟩
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
approx_le_fix
null
exists_fix_le_approx (x : α) : ∃ i, Part.fix f x ≤ approx f i x := by by_cases hh : ∃ i b, b ∈ approx f i x · rcases hh with ⟨i, b, hb⟩ exists i intro b' h' have hb' := approx_le_fix f i _ _ hb obtain rfl := Part.mem_unique h' hb' exact hb · simp only [not_exists] at hh exists 0 intro b' h' simp only [mem_iff f] at h' obtain ⟨i, h'⟩ := h' cases hh _ _ h'
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
exists_fix_le_approx
null
approxChain : Chain ((a : _) → Part <| β a) := ⟨approx f, approx_mono f⟩
def
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
approxChain
The series of approximations of `fix f` (see `approx`) as a `Chain`
le_f_of_mem_approx {x} : x ∈ approxChain f → x ≤ f x := by simp only [Membership.mem, forall_exists_index] rintro i rfl apply approx_mono'
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
le_f_of_mem_approx
null
approx_mem_approxChain {i} : approx f i ∈ approxChain f := Stream'.mem_of_get_eq rfl
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
approx_mem_approxChain
null
fix_eq_ωSup : Part.fix f = ωSup (approxChain f) := by apply le_antisymm · intro x obtain ⟨i, hx⟩ := exists_fix_le_approx f x trans approx f i.succ x · trans · apply hx · apply approx_mono' f apply le_ωSup_of_le i.succ dsimp [approx] rfl · apply ωSup_le _ _ _ simp only [Fix.approxChain] intro y x apply approx_le_fix f
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
fix_eq_ωSup
null
fix_le {X : (a : _) → Part <| β a} (hX : f X ≤ X) : Part.fix f ≤ X := by rw [fix_eq_ωSup f] apply ωSup_le _ _ _ simp only [Fix.approxChain] intro i induction i with | zero => dsimp [Fix.approx]; apply bot_le | succ _ i_ih => trans f X · apply f.monotone i_ih · apply hX variable {g : ((a : _) → Part <| β a) → (a : _) → Part <| β a}
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
fix_le
null
fix_eq_ωSup_of_ωScottContinuous (hc : ωScottContinuous g) : Part.fix g = ωSup (approxChain (⟨g,hc.monotone⟩ : ((a : _) → Part <| β a) →o (a : _) → Part <| β a)) := by rw [← fix_eq_ωSup] rfl
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
fix_eq_ωSup_of_ωScottContinuous
null
fix_eq_of_ωScottContinuous (hc : ωScottContinuous g) : Part.fix g = g (Part.fix g) := by rw [fix_eq_ωSup_of_ωScottContinuous hc, hc.map_ωSup] apply le_antisymm · apply ωSup_le_ωSup_of_le _ intro i exists i intro x apply le_f_of_mem_approx _ ⟨i, rfl⟩ · apply ωSup_le_ωSup_of_le _ intro i exists i.succ variable {f}
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
fix_eq_of_ωScottContinuous
null
@[simps] toUnitMono (f : Part α →o Part α) : (Unit → Part α) →o Unit → Part α where toFun x u := f (x u) monotone' x y (h : x ≤ y) u := f.monotone <| h u
def
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
toUnitMono
`toUnit` as a monotone function
ωScottContinuous_toUnitMono (f : Part α → Part α) (hc : ωScottContinuous f) : ωScottContinuous (toUnitMono ⟨f,hc.monotone⟩) := .of_map_ωSup_of_orderHom fun _ => by ext ⟨⟩ : 1 dsimp [OmegaCompletePartialOrder.ωSup] erw [hc.map_ωSup] rw [Chain.map_comp] rfl
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
ωScottContinuous_toUnitMono
null
noncomputable lawfulFix : LawfulFix (Part α) := ⟨fun {f : Part α → Part α} hc ↦ show Part.fix (toUnitMono ⟨f,hc.monotone⟩) () = _ by rw [Part.fix_eq_of_ωScottContinuous (ωScottContinuous_toUnitMono f hc)]; rfl⟩
instance
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
lawfulFix
null
noncomputable lawfulFix {β} : LawfulFix (α → Part β) := ⟨fun {_f} ↦ Part.fix_eq_of_ωScottContinuous⟩ variable {γ : ∀ a : α, β a → Type*}
instance
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
lawfulFix
null
@[simps] monotoneCurry [(x y : _) → Preorder <| γ x y] : (∀ x : Σ a, β a, γ x.1 x.2) →o ∀ (a) (b : β a), γ a b where toFun := curry monotone' _x _y h a b := h ⟨a, b⟩
def
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
monotoneCurry
`Sigma.curry` as a monotone function.
@[simps] monotoneUncurry [(x y : _) → Preorder <| γ x y] : (∀ (a) (b : β a), γ a b) →o ∀ x : Σ a, β a, γ x.1 x.2 where toFun := uncurry monotone' _x _y h a := h a.1 a.2 variable [(x y : _) → OmegaCompletePartialOrder <| γ x y] open OmegaCompletePartialOrder.Chain
def
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
monotoneUncurry
`Sigma.uncurry` as a monotone function.
ωScottContinuous_curry : ωScottContinuous (monotoneCurry α β γ) := ωScottContinuous.of_map_ωSup_of_orderHom fun c ↦ by ext x y dsimp [curry, ωSup] rw [map_comp, map_comp] rfl
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
ωScottContinuous_curry
null
ωScottContinuous_uncurry : ωScottContinuous (monotoneUncurry α β γ) := .of_map_ωSup_of_orderHom fun c ↦ by ext ⟨x, y⟩ dsimp [uncurry, ωSup] rw [map_comp, map_comp] rfl
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
ωScottContinuous_uncurry
null