control.basicMathlib.Control.Basic

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

refactor(*): move all mk_simp_attribute commands to 1 file (#19223)
Diff
@@ -5,6 +5,7 @@ Authors: Johannes Hölzl
 
 Extends the theory on functors, applicatives and monads.
 -/
+import tactic.mk_simp_attribute
 
 universes u v w
 variables {α β γ : Type u}
@@ -14,9 +15,6 @@ notation a ` $< `:1 f:1 := f a
 section functor
 variables {f : Type u → Type v} [functor f] [is_lawful_functor f]
 
-run_cmd mk_simp_attr `functor_norm
-run_cmd tactic.add_doc_string `simp_attr.functor_norm "Simp set for functor_norm"
-
 @[functor_norm] theorem functor.map_map (m : α → β) (g : β → γ) (x : f α) :
   g <$> (m <$> x) = (g ∘ m) <$> x :=
 (comp_map _ _ _).symm
@@ -85,6 +83,7 @@ lemma seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} : (f <$> x) >>= g
 show bind (f <$> x) g = bind x (g ∘ f),
 by rw [← bind_pure_comp_eq_map, bind_assoc]; simp [pure_bind]
 
+@[monad_norm]
 lemma seq_eq_bind_map {x : m α} {f : m (α → β)} : f <*> x = (f >>= (<$> x)) :=
 (bind_map_eq_seq f x).symm
 

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -5,7 +5,7 @@ Authors: Johannes Hölzl
 
 Extends the theory on functors, applicatives and monads.
 -/
-import Mathbin.Tactic.MkSimpAttribute
+import Tactic.MkSimpAttribute
 
 #align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
 
Diff
@@ -4,14 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johannes Hölzl
 
 Extends the theory on functors, applicatives and monads.
-
-! This file was ported from Lean 3 source module control.basic
-! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Tactic.MkSimpAttribute
 
+#align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
+
 universe u v w
 
 variable {α β γ : Type u}
Diff
@@ -6,10 +6,11 @@ Authors: Johannes Hölzl
 Extends the theory on functors, applicatives and monads.
 
 ! This file was ported from Lean 3 source module control.basic
-! leanprover-community/mathlib commit abb3121f210743a930dea73cd766d988079bdf8b
+! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
+import Mathbin.Tactic.MkSimpAttribute
 
 universe u v w
 
@@ -21,12 +22,6 @@ section Functor
 
 variable {f : Type u → Type v} [Functor f] [LawfulFunctor f]
 
-run_cmd
-  mk_simp_attr `functor_norm
-
-run_cmd
-  tactic.add_doc_string `simp_attr.functor_norm "Simp set for functor_norm"
-
 @[functor_norm]
 theorem Functor.map_map (m : α → β) (g : β → γ) (x : f α) : g <$> m <$> x = (g ∘ m) <$> x :=
   (comp_map _ _ _).symm
@@ -123,6 +118,7 @@ theorem seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} : f <$> x >>= g
 #align seq_bind_eq seq_bind_eq
 -/
 
+@[monad_norm]
 theorem seq_eq_bind_map {x : m α} {f : m (α → β)} : f <*> x = f >>= (· <$> x) :=
   (bind_map f x).symm
 #align seq_eq_bind_map seq_eq_bind_mapₓ
Diff
@@ -124,7 +124,7 @@ theorem seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} : f <$> x >>= g
 -/
 
 theorem seq_eq_bind_map {x : m α} {f : m (α → β)} : f <*> x = f >>= (· <$> x) :=
-  (bind_map_eq_seq f x).symm
+  (bind_map f x).symm
 #align seq_eq_bind_map seq_eq_bind_mapₓ
 
 /-- This is the Kleisli composition -/
@@ -271,8 +271,8 @@ instance : LawfulMonad (Sum.{v, u} e)
     where
   bind_assoc := by intros; casesm Sum _ _ <;> rfl
   pure_bind := by intros; rfl
-  bind_pure_comp_eq_map := by intros; casesm Sum _ _ <;> rfl
-  bind_map_eq_seq := by intros; cases f <;> rfl
+  bind_pure_comp := by intros; casesm Sum _ _ <;> rfl
+  bind_map := by intros; cases f <;> rfl
 
 end Sum
 
Diff
@@ -15,7 +15,6 @@ universe u v w
 
 variable {α β γ : Type u}
 
--- mathport name: «expr $< »
 notation:1 a " $< " f:1 => f a
 
 section Functor
@@ -63,13 +62,16 @@ variable [LawfulApplicative F]
 
 attribute [functor_norm] seq_assoc pure_seq_eq_map
 
+#print pure_id'_seq /-
 @[simp]
 theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x :=
   pure_id_seq x
 #align pure_id'_seq pure_id'_seq
+-/
 
 attribute [functor_norm] seq_assoc pure_seq_eq_map
 
+#print seq_map_assoc /-
 @[functor_norm]
 theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :
     x <*> f <$> y = (fun m : α → β => m ∘ f) <$> x <*> y :=
@@ -78,11 +80,14 @@ theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :
   simp [seq_assoc, (comp_map _ _ _).symm, (· ∘ ·)]
   simp [pure_seq_eq_map]
 #align seq_map_assoc seq_map_assoc
+-/
 
+#print map_seq /-
 @[functor_norm]
 theorem map_seq (f : β → γ) (x : F (α → β)) (y : F α) : f <$> (x <*> y) = (· ∘ ·) f <$> x <*> y :=
   by simp [(pure_seq_eq_map _ _).symm] <;> simp [seq_assoc]
 #align map_seq map_seq
+-/
 
 end Applicative
 
@@ -127,7 +132,6 @@ theorem seq_eq_bind_map {x : m α} {f : m (α → β)} : f <*> x = f >>= (· <$>
 def fish {m} [Monad m] {α β γ} (f : α → m β) (g : β → m γ) := fun x => f x >>= g
 #align fish fish
 
--- mathport name: «expr >=> »
 infixl:55
   " >=> " =>-- >=> is already defined in the core library but it is unusable
   -- because of its precedence (it is defined with precedence 2) and
@@ -135,9 +139,11 @@ infixl:55
   -- function
   fish
 
+#print fish_pure /-
 @[functor_norm]
 theorem fish_pure {α β} (f : α → m β) : f >=> pure = f := by simp only [(· >=> ·), functor_norm]
 #align fish_pure fish_pure
+-/
 
 #print fish_pipe /-
 @[functor_norm]
@@ -145,10 +151,12 @@ theorem fish_pipe {α β} (f : α → m β) : pure >=> f = f := by simp only [(
 #align fish_pipe fish_pipe
 -/
 
+#print fish_assoc /-
 @[functor_norm]
 theorem fish_assoc {α β γ φ} (f : α → m β) (g : β → m γ) (h : γ → m φ) :
     f >=> g >=> h = f >=> (g >=> h) := by simp only [(· >=> ·), functor_norm]
 #align fish_assoc fish_assoc
+-/
 
 variable {β' γ' : Type v}
 
@@ -277,6 +285,7 @@ class CommApplicative (m : Type _ → Type _) [Applicative m] extends LawfulAppl
 
 open Functor
 
+#print CommApplicative.commutative_map /-
 theorem CommApplicative.commutative_map {m : Type _ → Type _} [Applicative m] [CommApplicative m]
     {α β γ} (a : m α) (b : m β) {f : α → β → γ} : f <$> a <*> b = flip f <$> b <*> a :=
   calc
@@ -286,4 +295,5 @@ theorem CommApplicative.commutative_map {m : Type _ → Type _} [Applicative m]
       rw [CommApplicative.commutative_prod] <;>
         simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]
 #align is_comm_applicative.commutative_map CommApplicative.commutative_map
+-/
 
Diff
@@ -285,6 +285,5 @@ theorem CommApplicative.commutative_map {m : Type _ → Type _} [Applicative m]
     _ = (fun b a => f a b) <$> b <*> a := by
       rw [CommApplicative.commutative_prod] <;>
         simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]
-    
 #align is_comm_applicative.commutative_map CommApplicative.commutative_map
 
Diff
@@ -261,10 +261,10 @@ instance : LawfulFunctor (Sum.{v, u} e) := by refine' { .. } <;> intros <;> case
 
 instance : LawfulMonad (Sum.{v, u} e)
     where
-  bind_assoc := by intros ; casesm Sum _ _ <;> rfl
-  pure_bind := by intros ; rfl
-  bind_pure_comp_eq_map := by intros ; casesm Sum _ _ <;> rfl
-  bind_map_eq_seq := by intros ; cases f <;> rfl
+  bind_assoc := by intros; casesm Sum _ _ <;> rfl
+  pure_bind := by intros; rfl
+  bind_pure_comp_eq_map := by intros; casesm Sum _ _ <;> rfl
+  bind_map_eq_seq := by intros; cases f <;> rfl
 
 end Sum
 
Diff
@@ -63,12 +63,6 @@ variable [LawfulApplicative F]
 
 attribute [functor_norm] seq_assoc pure_seq_eq_map
 
-/- warning: pure_id'_seq -> pure_id'_seq is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {F : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} F] [_inst_2 : LawfulApplicative.{u1, u2} F _inst_1] (x : F α), Eq.{succ u2} (F α) (Seq.seq.{u1, u2} F (Applicative.toHasSeq.{u1, u2} F _inst_1) α α (Pure.pure.{u1, u2} F (Applicative.toHasPure.{u1, u2} F _inst_1) (α -> α) (fun (x : α) => x)) x) x
-but is expected to have type
-  forall {α : Type.{u1}} {F : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} F] [_inst_2 : LawfulApplicative.{u1, u2} F _inst_1] (x : F α), Eq.{succ u2} (F α) (Seq.seq.{u1, u2} F (Applicative.toSeq.{u1, u2} F _inst_1) α α (Pure.pure.{u1, u2} F (Applicative.toPure.{u1, u2} F _inst_1) (α -> α) (fun (x : α) => x)) (fun (x._@.Mathlib.Control.Basic._hyg.391 : Unit) => x)) x
-Case conversion may be inaccurate. Consider using '#align pure_id'_seq pure_id'_seqₓ'. -/
 @[simp]
 theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x :=
   pure_id_seq x
@@ -76,12 +70,6 @@ theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x :=
 
 attribute [functor_norm] seq_assoc pure_seq_eq_map
 
-/- warning: seq_map_assoc -> seq_map_assoc is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} {F : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} F] [_inst_2 : LawfulApplicative.{u1, u2} F _inst_1] (x : F (α -> β)) (f : γ -> α) (y : F γ), Eq.{succ u2} (F β) (Seq.seq.{u1, u2} F (Applicative.toHasSeq.{u1, u2} F _inst_1) α β x (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) γ α f y)) (Seq.seq.{u1, u2} F (Applicative.toHasSeq.{u1, u2} F _inst_1) γ β (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) (α -> β) (γ -> β) (fun (m : α -> β) => Function.comp.{succ u1, succ u1, succ u1} γ α β m f) x) y)
-but is expected to have type
-  forall {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} {F : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} F] [_inst_2 : LawfulApplicative.{u1, u2} F _inst_1] (x : F (α -> β)) (f : γ -> α) (y : F γ), Eq.{succ u2} (F β) (Seq.seq.{u1, u2} F (Applicative.toSeq.{u1, u2} F _inst_1) α β x (fun (x._@.Mathlib.Control.Basic._hyg.433 : Unit) => Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) γ α f y)) (Seq.seq.{u1, u2} F (Applicative.toSeq.{u1, u2} F _inst_1) γ β (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) (α -> β) (γ -> β) (fun (m : α -> β) => Function.comp.{succ u1, succ u1, succ u1} γ α β m f) x) (fun (x._@.Mathlib.Control.Basic._hyg.462 : Unit) => y))
-Case conversion may be inaccurate. Consider using '#align seq_map_assoc seq_map_assocₓ'. -/
 @[functor_norm]
 theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :
     x <*> f <$> y = (fun m : α → β => m ∘ f) <$> x <*> y :=
@@ -91,12 +79,6 @@ theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :
   simp [pure_seq_eq_map]
 #align seq_map_assoc seq_map_assoc
 
-/- warning: map_seq -> map_seq is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} {F : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} F] [_inst_2 : LawfulApplicative.{u1, u2} F _inst_1] (f : β -> γ) (x : F (α -> β)) (y : F α), Eq.{succ u2} (F γ) (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) β γ f (Seq.seq.{u1, u2} F (Applicative.toHasSeq.{u1, u2} F _inst_1) α β x y)) (Seq.seq.{u1, u2} F (Applicative.toHasSeq.{u1, u2} F _inst_1) α γ (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) (α -> β) (α -> γ) (Function.comp.{succ u1, succ u1, succ u1} α β γ f) x) y)
-but is expected to have type
-  forall {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} {F : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} F] [_inst_2 : LawfulApplicative.{u1, u2} F _inst_1] (f : β -> γ) (x : F (α -> β)) (y : F α), Eq.{succ u2} (F γ) (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) β γ f (Seq.seq.{u1, u2} F (Applicative.toSeq.{u1, u2} F _inst_1) α β x (fun (x._@.Mathlib.Control.Basic._hyg.518 : Unit) => y))) (Seq.seq.{u1, u2} F (Applicative.toSeq.{u1, u2} F _inst_1) α γ (Functor.map.{u1, u2} F (Applicative.toFunctor.{u1, u2} F _inst_1) (α -> β) (α -> γ) (fun (x._@.Mathlib.Control.Basic._hyg.529 : α -> β) => Function.comp.{succ u1, succ u1, succ u1} α β γ f x._@.Mathlib.Control.Basic._hyg.529) x) (fun (x._@.Mathlib.Control.Basic._hyg.543 : Unit) => y))
-Case conversion may be inaccurate. Consider using '#align map_seq map_seqₓ'. -/
 @[functor_norm]
 theorem map_seq (f : β → γ) (x : F (α → β)) (y : F α) : f <$> (x <*> y) = (· ∘ ·) f <$> x <*> y :=
   by simp [(pure_seq_eq_map _ _).symm] <;> simp [seq_assoc]
@@ -153,12 +135,6 @@ infixl:55
   -- function
   fish
 
-/- warning: fish_pure -> fish_pure is a dubious translation:
-lean 3 declaration is
-  forall {m : Type.{u1} -> Type.{u2}} [_inst_1 : Monad.{u1, u2} m] [_inst_2 : LawfulMonad.{u1, u2} m _inst_1] {α : Sort.{u3}} {β : Type.{u1}} (f : α -> (m β)), Eq.{max u3 (succ u2)} (α -> (m β)) (fish.{u1, u2, u3} m _inst_1 α β β f (Pure.pure.{u1, u2} m (Applicative.toHasPure.{u1, u2} m (Monad.toApplicative.{u1, u2} m _inst_1)) β)) f
-but is expected to have type
-  forall {m : Type.{u2} -> Type.{u3}} [_inst_1 : Monad.{u2, u3} m] [_inst_2 : LawfulMonad.{u2, u3} m _inst_1] {α : Type.{u1}} {β : Type.{u2}} (f : α -> (m β)), Eq.{max (succ u3) (succ u1)} (α -> (m β)) (Bind.kleisliRight.{u1, u2, u3} α m β β (Monad.toBind.{u2, u3} m _inst_1) f (Pure.pure.{u2, u3} m (Applicative.toPure.{u2, u3} m (Monad.toApplicative.{u2, u3} m _inst_1)) β)) f
-Case conversion may be inaccurate. Consider using '#align fish_pure fish_pureₓ'. -/
 @[functor_norm]
 theorem fish_pure {α β} (f : α → m β) : f >=> pure = f := by simp only [(· >=> ·), functor_norm]
 #align fish_pure fish_pure
@@ -169,12 +145,6 @@ theorem fish_pipe {α β} (f : α → m β) : pure >=> f = f := by simp only [(
 #align fish_pipe fish_pipe
 -/
 
-/- warning: fish_assoc -> fish_assoc is a dubious translation:
-lean 3 declaration is
-  forall {m : Type.{u1} -> Type.{u2}} [_inst_1 : Monad.{u1, u2} m] [_inst_2 : LawfulMonad.{u1, u2} m _inst_1] {α : Sort.{u3}} {β : Type.{u1}} {γ : Type.{u1}} {φ : Type.{u1}} (f : α -> (m β)) (g : β -> (m γ)) (h : γ -> (m φ)), Eq.{max u3 (succ u2)} (α -> (m φ)) (fish.{u1, u2, u3} m _inst_1 α γ φ (fish.{u1, u2, u3} m _inst_1 α β γ f g) h) (fish.{u1, u2, u3} m _inst_1 α β φ f (fish.{u1, u2, succ u1} m _inst_1 β γ φ g h))
-but is expected to have type
-  forall {m : Type.{u2} -> Type.{u3}} [_inst_1 : Monad.{u2, u3} m] [_inst_2 : LawfulMonad.{u2, u3} m _inst_1] {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u2}} {φ : Type.{u2}} (f : α -> (m β)) (g : β -> (m γ)) (h : γ -> (m φ)), Eq.{max (succ u3) (succ u1)} (α -> (m φ)) (Bind.kleisliRight.{u1, u2, u3} α m γ φ (Monad.toBind.{u2, u3} m _inst_1) (Bind.kleisliRight.{u1, u2, u3} α m β γ (Monad.toBind.{u2, u3} m _inst_1) f g) h) (Bind.kleisliRight.{u1, u2, u3} α m β φ (Monad.toBind.{u2, u3} m _inst_1) f (Bind.kleisliRight.{u2, u2, u3} β m γ φ (Monad.toBind.{u2, u3} m _inst_1) g h))
-Case conversion may be inaccurate. Consider using '#align fish_assoc fish_assocₓ'. -/
 @[functor_norm]
 theorem fish_assoc {α β γ φ} (f : α → m β) (g : β → m γ) (h : γ → m φ) :
     f >=> g >=> h = f >=> (g >=> h) := by simp only [(· >=> ·), functor_norm]
@@ -307,12 +277,6 @@ class CommApplicative (m : Type _ → Type _) [Applicative m] extends LawfulAppl
 
 open Functor
 
-/- warning: is_comm_applicative.commutative_map -> CommApplicative.commutative_map is a dubious translation:
-lean 3 declaration is
-  forall {m : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} m] [_inst_2 : CommApplicative.{u1, u2} m _inst_1] {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} (a : m α) (b : m β) {f : α -> β -> γ}, Eq.{succ u2} (m γ) (Seq.seq.{u1, u2} (fun {α : Type.{u1}} => m α) (Applicative.toHasSeq.{u1, u2} (fun {α : Type.{u1}} => m α) _inst_1) β γ (Functor.map.{u1, u2} (fun {α : Type.{u1}} => m α) (Applicative.toFunctor.{u1, u2} (fun {α : Type.{u1}} => m α) _inst_1) α (β -> γ) f a) b) (Seq.seq.{u1, u2} m (Applicative.toHasSeq.{u1, u2} m _inst_1) α γ (Functor.map.{u1, u2} m (Applicative.toFunctor.{u1, u2} m _inst_1) β (α -> γ) (flip.{succ u1, succ u1, succ u1} α β γ f) b) a)
-but is expected to have type
-  forall {m : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} m] [_inst_2 : CommApplicative.{u1, u2} m _inst_1] {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} (a : m α) (b : m β) {f : α -> β -> γ}, Eq.{succ u2} (m γ) (Seq.seq.{u1, u2} m (Applicative.toSeq.{u1, u2} m _inst_1) β γ (Functor.map.{u1, u2} m (Applicative.toFunctor.{u1, u2} m _inst_1) α (β -> γ) f a) (fun (x._@.Mathlib.Control.Basic._hyg.2549 : Unit) => b)) (Seq.seq.{u1, u2} m (Applicative.toSeq.{u1, u2} m _inst_1) α γ (Functor.map.{u1, u2} m (Applicative.toFunctor.{u1, u2} m _inst_1) β (α -> γ) (flip.{succ u1, succ u1, succ u1} α β γ f) b) (fun (x._@.Mathlib.Control.Basic._hyg.2564 : Unit) => a))
-Case conversion may be inaccurate. Consider using '#align is_comm_applicative.commutative_map CommApplicative.commutative_mapₓ'. -/
 theorem CommApplicative.commutative_map {m : Type _ → Type _} [Applicative m] [CommApplicative m]
     {α β γ} (a : m α) (b : m β) {f : α → β → γ} : f <$> a <*> b = flip f <$> b <*> a :=
   calc
Diff
@@ -291,18 +291,10 @@ instance : LawfulFunctor (Sum.{v, u} e) := by refine' { .. } <;> intros <;> case
 
 instance : LawfulMonad (Sum.{v, u} e)
     where
-  bind_assoc := by
-    intros
-    casesm Sum _ _ <;> rfl
-  pure_bind := by
-    intros
-    rfl
-  bind_pure_comp_eq_map := by
-    intros
-    casesm Sum _ _ <;> rfl
-  bind_map_eq_seq := by
-    intros
-    cases f <;> rfl
+  bind_assoc := by intros ; casesm Sum _ _ <;> rfl
+  pure_bind := by intros ; rfl
+  bind_pure_comp_eq_map := by intros ; casesm Sum _ _ <;> rfl
+  bind_map_eq_seq := by intros ; cases f <;> rfl
 
 end Sum
 

Changes in mathlib4

mathlib3
mathlib4
chore: avoid id.def (adaptation for nightly-2024-03-27) (#11829)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Diff
@@ -143,16 +143,16 @@ variable {m : Type u → Type u} [Monad m] [LawfulMonad m]
 
 theorem joinM_map_map {α β : Type u} (f : α → β) (a : m (m α)) :
     joinM (Functor.map f <$> a) = f <$> joinM a := by
-  simp only [joinM, (· ∘ ·), id.def, ← bind_pure_comp, bind_assoc, map_bind, pure_bind]
+  simp only [joinM, (· ∘ ·), id, ← bind_pure_comp, bind_assoc, map_bind, pure_bind]
 #align mjoin_map_map joinM_map_map
 
 theorem joinM_map_joinM {α : Type u} (a : m (m (m α))) : joinM (joinM <$> a) = joinM (joinM a) := by
-  simp only [joinM, (· ∘ ·), id.def, map_bind, ← bind_pure_comp, bind_assoc, pure_bind]
+  simp only [joinM, (· ∘ ·), id, map_bind, ← bind_pure_comp, bind_assoc, pure_bind]
 #align mjoin_map_mjoin joinM_map_joinM
 
 @[simp]
 theorem joinM_map_pure {α : Type u} (a : m α) : joinM (pure <$> a) = a := by
-  simp only [joinM, (· ∘ ·), id.def, map_bind, ← bind_pure_comp, bind_assoc, pure_bind, bind_pure]
+  simp only [joinM, (· ∘ ·), id, map_bind, ← bind_pure_comp, bind_assoc, pure_bind, bind_pure]
 #align mjoin_map_pure joinM_map_pure
 
 @[simp]
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -113,7 +113,6 @@ theorem fish_assoc {α β γ φ} (f : α → m β) (g : β → m γ) (h : γ →
 #align fish_assoc fish_assoc
 
 variable {β' γ' : Type v}
-
 variable {m' : Type v → Type w} [Monad m']
 
 /-- Takes a value `β` and `List α` and accumulates pairs according to a monadic function `f`.
chore: squeeze some non-terminal simps (#11247)

This PR accompanies #11246, squeezing some non-terminal simps highlighted by the linter until I decided to stop!

Diff
@@ -254,7 +254,7 @@ theorem CommApplicative.commutative_map {m : Type u → Type v} [h : Applicative
   f <$> a <*> b = flip f <$> b <*> a :=
   calc
     f <$> a <*> b = (fun p : α × β => f p.1 p.2) <$> (Prod.mk <$> a <*> b) := by
-      simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]; rfl
+      simp only [map_seq, map_map]; rfl
     _ = (fun b a => f a b) <$> b <*> a := by
       rw [@CommApplicative.commutative_prod m h]
       simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map, (· ∘ ·)]
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -7,7 +7,6 @@ import Mathlib.Init.Control.Combinators
 import Mathlib.Init.Function
 import Mathlib.Tactic.CasesM
 import Mathlib.Tactic.Attr.Core
-import Std.Data.List.Basic
 
 #align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
 
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johannes Hölzl
 -/
 import Mathlib.Init.Control.Combinators
+import Mathlib.Init.Function
 import Mathlib.Tactic.CasesM
 import Mathlib.Tactic.Attr.Core
 import Std.Data.List.Basic
@@ -87,26 +88,29 @@ theorem map_bind (x : m α) {g : α → m β} {f : β → γ} :
 
 theorem seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} :
     f <$> x >>= g = x >>= g ∘ f :=
-  show bind (f <$> x) g = bind x (g ∘ f)
-  by rw [← bind_pure_comp, bind_assoc]; simp [pure_bind, (· ∘ ·)]
+  show bind (f <$> x) g = bind x (g ∘ f) by
+    rw [← bind_pure_comp, bind_assoc]
+    simp [pure_bind, Function.comp_def]
 #align seq_bind_eq seq_bind_eq
 
 #align seq_eq_bind_map seq_eq_bind_mapₓ
 -- order of implicits and `Seq.seq` has a lazily evaluated second argument using `Unit`
 
 @[functor_norm]
-theorem fish_pure {α β} (f : α → m β) : f >=> pure = f := by simp only [(· >=> ·), functor_norm]
+theorem fish_pure {α β} (f : α → m β) : f >=> pure = f := by
+  simp (config := { unfoldPartialApp := true }) only [(· >=> ·), functor_norm]
 #align fish_pure fish_pure
 
 @[functor_norm]
-theorem fish_pipe {α β} (f : α → m β) : pure >=> f = f := by simp only [(· >=> ·), functor_norm]
+theorem fish_pipe {α β} (f : α → m β) : pure >=> f = f := by
+  simp (config := { unfoldPartialApp := true }) only [(· >=> ·), functor_norm]
 #align fish_pipe fish_pipe
 
 -- note: in Lean 3 `>=>` is left-associative, but in Lean 4 it is right-associative.
 @[functor_norm]
 theorem fish_assoc {α β γ φ} (f : α → m β) (g : β → m γ) (h : γ → m φ) :
     (f >=> g) >=> h = f >=> g >=> h := by
-  simp only [(· >=> ·), functor_norm]
+  simp (config := { unfoldPartialApp := true }) only [(· >=> ·), functor_norm]
 #align fish_assoc fish_assoc
 
 variable {β' γ' : Type v}
chore: remove nonterminal simp (#7580)

Removes nonterminal simps on lines looking like simp [...]

Diff
@@ -59,8 +59,8 @@ theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x :=
 @[functor_norm]
 theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :
     x <*> f <$> y = (· ∘ f) <$> x <*> y := by
-  simp [← pure_seq]
-  simp [seq_assoc, ← comp_map, (· ∘ ·)]
+  simp only [← pure_seq]
+  simp only [seq_assoc, Function.comp, seq_pure, ← comp_map]
   simp [pure_seq]
 #align seq_map_assoc seq_map_assoc
 
chore: only four spaces for subsequent lines (#7286)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -140,7 +140,7 @@ section
 variable {m : Type u → Type u} [Monad m] [LawfulMonad m]
 
 theorem joinM_map_map {α β : Type u} (f : α → β) (a : m (m α)) :
-  joinM (Functor.map f <$> a) = f <$> joinM a := by
+    joinM (Functor.map f <$> a) = f <$> joinM a := by
   simp only [joinM, (· ∘ ·), id.def, ← bind_pure_comp, bind_assoc, map_bind, pure_bind]
 #align mjoin_map_map joinM_map_map
 
chore: bump Std to #253 (#7113)

Bump PR for https://github.com/leanprover/std4/pull/253

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -6,6 +6,7 @@ Authors: Johannes Hölzl
 import Mathlib.Init.Control.Combinators
 import Mathlib.Tactic.CasesM
 import Mathlib.Tactic.Attr.Core
+import Std.Data.List.Basic
 
 #align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
 
@@ -77,14 +78,6 @@ variable {m : Type u → Type v} [Monad m] [LawfulMonad m]
 
 open List
 
-/-- A generalization of `List.partition` which partitions the list according to a monadic
-predicate. `List.partition` corresponds to the case where `f = Id`. -/
-def List.partitionM {f : Type → Type} [Monad f] {α : Type} (p : α → f Bool) :
-    List α → f (List α × List α)
-  | [] => pure ([], [])
-  | x :: xs => condM (p x)
-    (Prod.map (cons x) id <$> List.partitionM p xs)
-    (Prod.map id (cons x) <$> List.partitionM p xs)
 #align list.mpartition List.partitionM
 
 theorem map_bind (x : m α) {g : α → m β} {f : β → γ} :
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2017 Johannes Hölzl. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johannes Hölzl
-
-! This file was ported from Lean 3 source module control.basic
-! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Init.Control.Combinators
 import Mathlib.Tactic.CasesM
 import Mathlib.Tactic.Attr.Core
 
+#align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
+
 /-!
 Extends the theory on functors, applicatives and monads.
 -/
refactor: move all register_simp_attrs to 1 file (#5681)

There are slight differences between mathlib3 and mathlib4 (different set of attributes, different lemmas are in core/std), so I redid the same refactor instead of forward-porting changes.

mathlib3 PR: leanprover-community/mathlib#19223

Diff
@@ -4,13 +4,13 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johannes Hölzl
 
 ! This file was ported from Lean 3 source module control.basic
-! leanprover-community/mathlib commit 08aeb33b5b693fb1392a7568ae2c0b253516535e
+! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathlib.Control.SimpSet
 import Mathlib.Init.Control.Combinators
 import Mathlib.Tactic.CasesM
+import Mathlib.Tactic.Attr.Core
 
 /-!
 Extends the theory on functors, applicatives and monads.
@@ -29,7 +29,6 @@ theorem Functor.map_map (m : α → β) (g : β → γ) (x : f α) : g <$> m <$>
 #align functor.map_map Functor.map_mapₓ
 -- order of implicits
 
-attribute [simp] id_map'
 #align id_map' id_map'ₓ
 -- order of implicits
 
@@ -54,15 +53,11 @@ def zipWithM' (f : α → β → F γ) : List α → List β → F PUnit
 
 variable [LawfulApplicative F]
 
-attribute [functor_norm] seq_assoc pure_seq
-
 @[simp]
 theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x :=
   pure_id_seq x
 #align pure_id'_seq pure_id'_seq
 
-attribute [functor_norm] seq_assoc pure_seq
-
 @[functor_norm]
 theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :
     x <*> f <$> y = (· ∘ f) <$> x <*> y := by
@@ -79,9 +74,6 @@ theorem map_seq (f : β → γ) (x : F (α → β)) (y : F α) :
 
 end Applicative
 
--- TODO: setup `functor_norm` for `monad` laws
-attribute [functor_norm] pure_bind bind_assoc bind_pure
-
 section Monad
 
 variable {m : Type u → Type v} [Monad m] [LawfulMonad m]
@@ -100,13 +92,13 @@ def List.partitionM {f : Type → Type} [Monad f] {α : Type} (p : α → f Bool
 
 theorem map_bind (x : m α) {g : α → m β} {f : β → γ} :
     f <$> (x >>= g) = x >>= fun a => f <$> g a := by
-  rw [← bind_pure_comp, bind_assoc] <;> simp [bind_pure_comp]
+  rw [← bind_pure_comp, bind_assoc]; simp [bind_pure_comp]
 #align map_bind map_bind
 
 theorem seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} :
     f <$> x >>= g = x >>= g ∘ f :=
   show bind (f <$> x) g = bind x (g ∘ f)
-  by rw [← bind_pure_comp, bind_assoc] <;> simp [pure_bind, (· ∘ ·)]
+  by rw [← bind_pure_comp, bind_assoc]; simp [pure_bind, (· ∘ ·)]
 #align seq_bind_eq seq_bind_eq
 
 #align seq_eq_bind_map seq_eq_bind_mapₓ
@@ -269,8 +261,8 @@ theorem CommApplicative.commutative_map {m : Type u → Type v} [h : Applicative
   f <$> a <*> b = flip f <$> b <*> a :=
   calc
     f <$> a <*> b = (fun p : α × β => f p.1 p.2) <$> (Prod.mk <$> a <*> b) := by
-      simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map] <;> rfl
+      simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]; rfl
     _ = (fun b a => f a b) <$> b <*> a := by
-      rw [@CommApplicative.commutative_prod m h] <;>
+      rw [@CommApplicative.commutative_prod m h]
       simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map, (· ∘ ·)]
 #align is_comm_applicative.commutative_map CommApplicative.commutative_map
chore: fix upper/lowercase in comments (#4360)
  • Run a non-interactive version of fix-comments.py on all files.
  • Go through the diff and manually add/discard/edit chunks.
Diff
@@ -182,7 +182,7 @@ section Alternative
 
 variable {F : Type → Type v} [Alternative F]
 
--- [todo] add notation for `Functor.mapConst` and port `functor.map_const_rev`
+-- [todo] add notation for `Functor.mapConst` and port `Functor.mapConstRev`
 /-- Returns `pure true` if the computation succeeds and `pure false` otherwise. -/
 def succeeds {α} (x : F α) : F Bool :=
   Functor.mapConst true x <|> pure false
feat: add Mathlib.Tactic.Common, and import (#4056)

This makes a mathlib4 version of mathlib3's tactic.basic, now called Mathlib.Tactic.Common, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.

This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -9,8 +9,8 @@ Authors: Johannes Hölzl
 ! if you have ported upstream changes.
 -/
 import Mathlib.Control.SimpSet
-import Mathlib.Tactic.CasesM
 import Mathlib.Init.Control.Combinators
+import Mathlib.Tactic.CasesM
 
 /-!
 Extends the theory on functors, applicatives and monads.
chore: bye-bye, solo bys! (#3825)

This PR puts, with one exception, every single remaining by that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh. The exception is when the by begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.

Essentially this is s/\n *by$/ by/g, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated bys".

Diff
@@ -268,11 +268,9 @@ theorem CommApplicative.commutative_map {m : Type u → Type v} [h : Applicative
     [CommApplicative m] {α β γ} (a : m α) (b : m β) {f : α → β → γ} :
   f <$> a <*> b = flip f <$> b <*> a :=
   calc
-    f <$> a <*> b = (fun p : α × β => f p.1 p.2) <$> (Prod.mk <$> a <*> b) :=
-      by
-        simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map] <;> rfl
-    _ = (fun b a => f a b) <$> b <*> a :=
-      by
-        rw [@CommApplicative.commutative_prod m h] <;>
-        simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map, (· ∘ ·)]
+    f <$> a <*> b = (fun p : α × β => f p.1 p.2) <$> (Prod.mk <$> a <*> b) := by
+      simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map] <;> rfl
+    _ = (fun b a => f a b) <$> b <*> a := by
+      rw [@CommApplicative.commutative_prod m h] <;>
+      simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map, (· ∘ ·)]
 #align is_comm_applicative.commutative_map CommApplicative.commutative_map
chore: fix #align lines (#3640)

This PR fixes two things:

  • Most align statements for definitions and theorems and instances that are separated by two newlines from the relevant declaration (s/\n\n#align/\n#align). This is often seen in the mathport output after ending calc blocks.
  • All remaining more-than-one-line #align statements. (This was needed for a script I wrote for #3630.)
Diff
@@ -275,5 +275,4 @@ theorem CommApplicative.commutative_map {m : Type u → Type v} [h : Applicative
       by
         rw [@CommApplicative.commutative_prod m h] <;>
         simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map, (· ∘ ·)]
-
 #align is_comm_applicative.commutative_map CommApplicative.commutative_map
feat: interval_cases tactic (#1155)

Implements the interval_cases tactic from mathlib. This is a from scratch implementation, which should be a lot faster and give better goals than the original. I also tried to make a reasonable MetaM version of the tactic.

The original tactic was very generic and used typeclass inference to find most of the structure on the type. The new one is still somewhat type-generic but relies on meta-instances which implement the required functionality for supported types. Currently only Nat and Int are supported; PNat is more difficult because norm_num doesn't work on it.

Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com>

Diff
@@ -193,6 +193,10 @@ def tryM {α} (x : F α) : F Unit :=
   Functor.mapConst () x <|> pure ()
 #align mtry tryM
 
+/-- Attempts to perform the computation, and returns `none` if it doesn't succeed. -/
+def try? {α} (x : F α) : F (Option α) :=
+  some <$> x <|> pure none
+
 @[simp]
 theorem guard_true {h : Decidable True} : @guard F _ True h = pure () := by simp [guard, if_pos]
 #align guard_true guard_true
fix: make casesm and constructorm fail if no matches are found (#1552)

The main thing I want to fix here is that tauto on master currently never fails quickly. E.g. this takes many seconds to fail:

example (p : Prop) : p := by tauto

The reason is that the final step of tauto repeats until it sees a failure, and constructorMatching never fails, so we end up going until a timeout is hit. https://github.com/leanprover-community/mathlib4/blob/e78a2694fd2c5b00c16b4139f4a45faa17d2718d/Mathlib/Tactic/Tauto.lean#L150-L153

When I originally wrote this code, I had expected that constructorMatching would fail when it finds no match, similar to how the mathlib3 tactic constructor_matching fails when it finds no match.

To fix the problem, this PR adds a throwOnNoMatch optional parameter to the casesMatching and constructorMatching functions, with default value set to !recursive. This means that the casesm and constructorm tactics will fail on no match, but the casesm* and constructorm* tactics will succeed on no match. That corresponds exactly to how the analogous tactics work in mathlib3.

According to some zulip discussion, other folks agree that the mathlib3 behavior was better.

This PR also explicitly sets (throwOnNoMatch := false) on the other calls to constructorMatching and casesMatching in tautoCore, because in those cases we don't want a failure. Technically, to exactly match the mathlib3 behavior there, we should be setting (recursive := true), as I do in #1507, but if I do that here without the other performance fixes in that PR, then the proof of Preorder.toCircularPreorder gets pushed over the default maxHeartbeats timeout.

Diff
@@ -219,7 +219,8 @@ instance : Monad (Sum.{v, u} e) where
   pure := @Sum.inr e
   bind := @Sum.bind e
 
-instance : LawfulFunctor (Sum.{v, u} e) := by refine' { .. } <;> intros <;> casesm Sum _ _ <;> rfl
+instance : LawfulFunctor (Sum.{v, u} e) := by
+  refine' { .. } <;> intros <;> (try casesm Sum _ _) <;> rfl
 
 instance : LawfulMonad (Sum.{v, u} e) where
   seqRight_eq := by
chore: add source headers to ported theory files (#1094)

The script used to do this is included. The yaml file was obtained from https://raw.githubusercontent.com/wiki/leanprover-community/mathlib/mathlib4-port-status.md

Diff
@@ -2,6 +2,11 @@
 Copyright (c) 2017 Johannes Hölzl. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johannes Hölzl
+
+! This file was ported from Lean 3 source module control.basic
+! leanprover-community/mathlib commit 08aeb33b5b693fb1392a7568ae2c0b253516535e
+! Please do not edit these lines, except to modify the commit id
+! if you have ported upstream changes.
 -/
 import Mathlib.Control.SimpSet
 import Mathlib.Tactic.CasesM

Dependencies

1 files ported (100.0%)
206 lines ported (100.0%)

All dependencies are ported!