data.fun_like.basic
⟷
Mathlib.Data.FunLike.Basic
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.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -133,17 +133,17 @@ instead of linearly increasing the work per `my_hom`-related declaration.
-- `fun_like → has_coe_to_fun`
attribute [instance 10] coeFnTrans
-#print FunLike /-
+#print DFunLike /-
/-- The class `fun_like F α β` expresses that terms of type `F` have an
injective coercion to functions from `α` to `β`.
This typeclass is used in the definition of the homomorphism typeclasses,
such as `zero_hom_class`, `mul_hom_class`, `monoid_hom_class`, ....
-/
-class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sort _) where
+class DFunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sort _) where
coe : F → ∀ a : α, β a
coe_injective' : Function.Injective coe
-#align fun_like FunLike
+#align fun_like DFunLike
-/
section Dependent
@@ -153,85 +153,85 @@ section Dependent
variable (F α : Sort _) (β : α → Sort _)
-namespace FunLike
+namespace DFunLike
-variable {F α β} [i : FunLike F α β]
+variable {F α β} [i : DFunLike F α β]
-- Give this a priority between `coe_fn_trans` and the default priority
-- `α` and `β` are out_params, so this instance should not be dangerous
@[nolint dangerous_instance]
-instance (priority := 100) : CoeFun F fun _ => ∀ a : α, β a where coe := FunLike.coe
+instance (priority := 100) : CoeFun F fun _ => ∀ a : α, β a where coe := DFunLike.coe
-#print FunLike.coe_eq_coe_fn /-
+#print DFunLike.coe_eq_coe_fn /-
@[simp]
-theorem coe_eq_coe_fn : (FunLike.coe : F → ∀ a : α, β a) = coeFn :=
+theorem coe_eq_coe_fn : (DFunLike.coe : F → ∀ a : α, β a) = coeFn :=
rfl
-#align fun_like.coe_eq_coe_fn FunLike.coe_eq_coe_fn
+#align fun_like.coe_eq_coe_fn DFunLike.coe_eq_coe_fn
-/
-#print FunLike.coe_injective /-
+#print DFunLike.coe_injective /-
theorem coe_injective : Function.Injective (coeFn : F → ∀ a : α, β a) :=
- FunLike.coe_injective'
-#align fun_like.coe_injective FunLike.coe_injective
+ DFunLike.coe_injective'
+#align fun_like.coe_injective DFunLike.coe_injective
-/
-#print FunLike.coe_fn_eq /-
+#print DFunLike.coe_fn_eq /-
@[simp, norm_cast]
theorem coe_fn_eq {f g : F} : (f : ∀ a : α, β a) = (g : ∀ a : α, β a) ↔ f = g :=
⟨fun h => @coe_injective _ _ _ i _ _ h, fun h => by cases h <;> rfl⟩
-#align fun_like.coe_fn_eq FunLike.coe_fn_eq
+#align fun_like.coe_fn_eq DFunLike.coe_fn_eq
-/
-#print FunLike.ext' /-
+#print DFunLike.ext' /-
theorem ext' {f g : F} (h : (f : ∀ a : α, β a) = (g : ∀ a : α, β a)) : f = g :=
coe_injective h
-#align fun_like.ext' FunLike.ext'
+#align fun_like.ext' DFunLike.ext'
-/
-#print FunLike.ext'_iff /-
+#print DFunLike.ext'_iff /-
theorem ext'_iff {f g : F} : f = g ↔ (f : ∀ a : α, β a) = (g : ∀ a : α, β a) :=
coe_fn_eq.symm
-#align fun_like.ext'_iff FunLike.ext'_iff
+#align fun_like.ext'_iff DFunLike.ext'_iff
-/
-#print FunLike.ext /-
+#print DFunLike.ext /-
theorem ext (f g : F) (h : ∀ x : α, f x = g x) : f = g :=
coe_injective (funext h)
-#align fun_like.ext FunLike.ext
+#align fun_like.ext DFunLike.ext
-/
-#print FunLike.ext_iff /-
+#print DFunLike.ext_iff /-
theorem ext_iff {f g : F} : f = g ↔ ∀ x, f x = g x :=
coe_fn_eq.symm.trans Function.funext_iff
-#align fun_like.ext_iff FunLike.ext_iff
+#align fun_like.ext_iff DFunLike.ext_iff
-/
-#print FunLike.congr_fun /-
+#print DFunLike.congr_fun /-
protected theorem congr_fun {f g : F} (h₁ : f = g) (x : α) : f x = g x :=
congr_fun (congr_arg _ h₁) x
-#align fun_like.congr_fun FunLike.congr_fun
+#align fun_like.congr_fun DFunLike.congr_fun
-/
-#print FunLike.ne_iff /-
+#print DFunLike.ne_iff /-
theorem ne_iff {f g : F} : f ≠ g ↔ ∃ a, f a ≠ g a :=
ext_iff.Not.trans Classical.not_forall
-#align fun_like.ne_iff FunLike.ne_iff
+#align fun_like.ne_iff DFunLike.ne_iff
-/
-#print FunLike.exists_ne /-
+#print DFunLike.exists_ne /-
theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
ne_iff.mp h
-#align fun_like.exists_ne FunLike.exists_ne
+#align fun_like.exists_ne DFunLike.exists_ne
-/
-#print FunLike.subsingleton_cod /-
+#print DFunLike.subsingleton_cod /-
/-- This is not an instance to avoid slowing down every single `subsingleton` typeclass search.-/
theorem subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
⟨fun f g => coe_injective <| Subsingleton.elim _ _⟩
-#align fun_like.subsingleton_cod FunLike.subsingleton_cod
+#align fun_like.subsingleton_cod DFunLike.subsingleton_cod
-/
-end FunLike
+end DFunLike
end Dependent
@@ -240,23 +240,23 @@ section NonDependent
/-! ### `fun_like F α (λ _, β)` where `β` does not depend on `a : α` -/
-variable {F α β : Sort _} [i : FunLike F α fun _ => β]
+variable {F α β : Sort _} [i : DFunLike F α fun _ => β]
-namespace FunLike
+namespace DFunLike
-#print FunLike.congr /-
+#print DFunLike.congr /-
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
-#align fun_like.congr FunLike.congr
+#align fun_like.congr DFunLike.congr
-/
-#print FunLike.congr_arg /-
+#print DFunLike.congr_arg /-
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
-#align fun_like.congr_arg FunLike.congr_arg
+#align fun_like.congr_arg DFunLike.congr_arg
-/
-end FunLike
+end DFunLike
end NonDependent
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -214,7 +214,7 @@ protected theorem congr_fun {f g : F} (h₁ : f = g) (x : α) : f x = g x :=
#print FunLike.ne_iff /-
theorem ne_iff {f g : F} : f ≠ g ↔ ∃ a, f a ≠ g a :=
- ext_iff.Not.trans not_forall
+ ext_iff.Not.trans Classical.not_forall
#align fun_like.ne_iff FunLike.ne_iff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
-import Mathbin.Logic.Function.Basic
+import Logic.Function.Basic
import Mathbin.Tactic.Lint.Default
-import Mathbin.Tactic.NormCast
+import Tactic.NormCast
#align_import data.fun_like.basic from "leanprover-community/mathlib"@"448144f7ae193a8990cb7473c9e9a01990f64ac7"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-
-! This file was ported from Lean 3 source module data.fun_like.basic
-! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Logic.Function.Basic
import Mathbin.Tactic.Lint.Default
import Mathbin.Tactic.NormCast
+#align_import data.fun_like.basic from "leanprover-community/mathlib"@"448144f7ae193a8990cb7473c9e9a01990f64ac7"
+
/-!
# Typeclass for a type `F` with an injective map to `A → B`
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -136,6 +136,7 @@ instead of linearly increasing the work per `my_hom`-related declaration.
-- `fun_like → has_coe_to_fun`
attribute [instance 10] coeFnTrans
+#print FunLike /-
/-- The class `fun_like F α β` expresses that terms of type `F` have an
injective coercion to functions from `α` to `β`.
@@ -146,6 +147,7 @@ class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sor
coe : F → ∀ a : α, β a
coe_injective' : Function.Injective coe
#align fun_like FunLike
+-/
section Dependent
@@ -158,59 +160,79 @@ namespace FunLike
variable {F α β} [i : FunLike F α β]
-include i
-
-- Give this a priority between `coe_fn_trans` and the default priority
-- `α` and `β` are out_params, so this instance should not be dangerous
@[nolint dangerous_instance]
instance (priority := 100) : CoeFun F fun _ => ∀ a : α, β a where coe := FunLike.coe
+#print FunLike.coe_eq_coe_fn /-
@[simp]
theorem coe_eq_coe_fn : (FunLike.coe : F → ∀ a : α, β a) = coeFn :=
rfl
#align fun_like.coe_eq_coe_fn FunLike.coe_eq_coe_fn
+-/
+#print FunLike.coe_injective /-
theorem coe_injective : Function.Injective (coeFn : F → ∀ a : α, β a) :=
FunLike.coe_injective'
#align fun_like.coe_injective FunLike.coe_injective
+-/
+#print FunLike.coe_fn_eq /-
@[simp, norm_cast]
theorem coe_fn_eq {f g : F} : (f : ∀ a : α, β a) = (g : ∀ a : α, β a) ↔ f = g :=
⟨fun h => @coe_injective _ _ _ i _ _ h, fun h => by cases h <;> rfl⟩
#align fun_like.coe_fn_eq FunLike.coe_fn_eq
+-/
+#print FunLike.ext' /-
theorem ext' {f g : F} (h : (f : ∀ a : α, β a) = (g : ∀ a : α, β a)) : f = g :=
coe_injective h
#align fun_like.ext' FunLike.ext'
+-/
+#print FunLike.ext'_iff /-
theorem ext'_iff {f g : F} : f = g ↔ (f : ∀ a : α, β a) = (g : ∀ a : α, β a) :=
coe_fn_eq.symm
#align fun_like.ext'_iff FunLike.ext'_iff
+-/
+#print FunLike.ext /-
theorem ext (f g : F) (h : ∀ x : α, f x = g x) : f = g :=
coe_injective (funext h)
#align fun_like.ext FunLike.ext
+-/
+#print FunLike.ext_iff /-
theorem ext_iff {f g : F} : f = g ↔ ∀ x, f x = g x :=
coe_fn_eq.symm.trans Function.funext_iff
#align fun_like.ext_iff FunLike.ext_iff
+-/
+#print FunLike.congr_fun /-
protected theorem congr_fun {f g : F} (h₁ : f = g) (x : α) : f x = g x :=
congr_fun (congr_arg _ h₁) x
#align fun_like.congr_fun FunLike.congr_fun
+-/
+#print FunLike.ne_iff /-
theorem ne_iff {f g : F} : f ≠ g ↔ ∃ a, f a ≠ g a :=
ext_iff.Not.trans not_forall
#align fun_like.ne_iff FunLike.ne_iff
+-/
+#print FunLike.exists_ne /-
theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
ne_iff.mp h
#align fun_like.exists_ne FunLike.exists_ne
+-/
+#print FunLike.subsingleton_cod /-
/-- This is not an instance to avoid slowing down every single `subsingleton` typeclass search.-/
theorem subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
⟨fun f g => coe_injective <| Subsingleton.elim _ _⟩
#align fun_like.subsingleton_cod FunLike.subsingleton_cod
+-/
end FunLike
@@ -223,17 +245,19 @@ section NonDependent
variable {F α β : Sort _} [i : FunLike F α fun _ => β]
-include i
-
namespace FunLike
+#print FunLike.congr /-
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
#align fun_like.congr FunLike.congr
+-/
+#print FunLike.congr_arg /-
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
#align fun_like.congr_arg FunLike.congr_arg
+-/
end FunLike
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -136,12 +136,6 @@ instead of linearly increasing the work per `my_hom`-related declaration.
-- `fun_like → has_coe_to_fun`
attribute [instance 10] coeFnTrans
-/- warning: fun_like -> FunLike is a dubious translation:
-lean 3 declaration is
- Sort.{u1} -> (forall (α : outParam.{succ u2} Sort.{u2}), (outParam.{max u2 (succ u3)} (α -> Sort.{u3})) -> Sort.{max 1 (imax u1 u2 u3)})
-but is expected to have type
- Sort.{u1} -> (forall (α : outParam.{succ u2} Sort.{u2}), (outParam.{max u2 (succ u3)} (α -> Sort.{u3})) -> Sort.{max (max (max 1 u1) u2) u3})
-Case conversion may be inaccurate. Consider using '#align fun_like FunLikeₓ'. -/
/-- The class `fun_like F α β` expresses that terms of type `F` have an
injective coercion to functions from `α` to `β`.
@@ -171,114 +165,48 @@ include i
@[nolint dangerous_instance]
instance (priority := 100) : CoeFun F fun _ => ∀ a : α, β a where coe := FunLike.coe
-/- warning: fun_like.coe_eq_coe_fn -> FunLike.coe_eq_coe_fn is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β], Eq.{imax u1 u2 u3} (F -> (forall (a : α), β a)) (FunLike.coe.{u1, u2, u3} F α (fun (a : α) => β a) i) (coeFn.{u1, imax u2 u3} F (fun (ᾰ : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : α -> Sort.{u1}} [i : FunLike.{u3, u2, u1} F α β], Eq.{imax u3 u2 u1} (F -> (forall (a : α), β a)) (FunLike.coe.{u3, u2, u1} F α β i) (fun (f : F) => FunLike.coe.{u3, u2, u1} F α (fun (a : α) => β a) i f)
-Case conversion may be inaccurate. Consider using '#align fun_like.coe_eq_coe_fn FunLike.coe_eq_coe_fnₓ'. -/
@[simp]
theorem coe_eq_coe_fn : (FunLike.coe : F → ∀ a : α, β a) = coeFn :=
rfl
#align fun_like.coe_eq_coe_fn FunLike.coe_eq_coe_fn
-/- warning: fun_like.coe_injective -> FunLike.coe_injective is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β], Function.Injective.{u1, imax u2 u3} F (forall (a : α), β a) (coeFn.{u1, imax u2 u3} F (fun (ᾰ : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : α -> Sort.{u1}} [i : FunLike.{u3, u2, u1} F α β], Function.Injective.{u3, imax u2 u1} F (forall (a : α), β a) (fun (f : F) => FunLike.coe.{u3, u2, u1} F α (fun (a : α) => β a) i f)
-Case conversion may be inaccurate. Consider using '#align fun_like.coe_injective FunLike.coe_injectiveₓ'. -/
theorem coe_injective : Function.Injective (coeFn : F → ∀ a : α, β a) :=
FunLike.coe_injective'
#align fun_like.coe_injective FunLike.coe_injective
-/- warning: fun_like.coe_fn_eq -> FunLike.coe_fn_eq is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, Iff (Eq.{imax u2 u3} ((fun (_x : F) => forall (a : α), β a) f) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g)) (Eq.{u1} F f g)
-but is expected to have type
- forall {F : Sort.{u1}} {α : Sort.{u3}} {β : α -> Sort.{u2}} [i : FunLike.{u1, u3, u2} F α β] {f : F} {g : F}, Iff (Eq.{imax u3 u2} (forall (a : α), β a) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => β _x) i f) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => β _x) i g)) (Eq.{u1} F f g)
-Case conversion may be inaccurate. Consider using '#align fun_like.coe_fn_eq FunLike.coe_fn_eqₓ'. -/
@[simp, norm_cast]
theorem coe_fn_eq {f g : F} : (f : ∀ a : α, β a) = (g : ∀ a : α, β a) ↔ f = g :=
⟨fun h => @coe_injective _ _ _ i _ _ h, fun h => by cases h <;> rfl⟩
#align fun_like.coe_fn_eq FunLike.coe_fn_eq
-/- warning: fun_like.ext' -> FunLike.ext' is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, (Eq.{imax u2 u3} ((fun (_x : F) => forall (a : α), β a) f) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g)) -> (Eq.{u1} F f g)
-but is expected to have type
- forall {F : Sort.{u1}} {α : Sort.{u3}} {β : α -> Sort.{u2}} [i : FunLike.{u1, u3, u2} F α β] {f : F} {g : F}, (Eq.{imax u3 u2} (forall (a : α), β a) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => β _x) i f) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => β _x) i g)) -> (Eq.{u1} F f g)
-Case conversion may be inaccurate. Consider using '#align fun_like.ext' FunLike.ext'ₓ'. -/
theorem ext' {f g : F} (h : (f : ∀ a : α, β a) = (g : ∀ a : α, β a)) : f = g :=
coe_injective h
#align fun_like.ext' FunLike.ext'
-/- warning: fun_like.ext'_iff -> FunLike.ext'_iff is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, Iff (Eq.{u1} F f g) (Eq.{imax u2 u3} ((fun (_x : F) => forall (a : α), β a) f) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : α -> Sort.{u1}} [i : FunLike.{u3, u2, u1} F α β] {f : F} {g : F}, Iff (Eq.{u3} F f g) (Eq.{imax u2 u1} (forall (a : α), β a) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => β _x) i f) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => β _x) i g))
-Case conversion may be inaccurate. Consider using '#align fun_like.ext'_iff FunLike.ext'_iffₓ'. -/
theorem ext'_iff {f g : F} : f = g ↔ (f : ∀ a : α, β a) = (g : ∀ a : α, β a) :=
coe_fn_eq.symm
#align fun_like.ext'_iff FunLike.ext'_iff
-/- warning: fun_like.ext -> FunLike.ext is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] (f : F) (g : F), (forall (x : α), Eq.{u3} (β x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g x)) -> (Eq.{u1} F f g)
-but is expected to have type
- forall {F : Sort.{u2}} {α : Sort.{u1}} {β : α -> Sort.{u3}} [i : FunLike.{u2, u1, u3} F α β] (f : F) (g : F), (forall (x : α), Eq.{u3} (β x) (FunLike.coe.{u2, u1, u3} F α (fun (_x : α) => β _x) i f x) (FunLike.coe.{u2, u1, u3} F α (fun (_x : α) => β _x) i g x)) -> (Eq.{u2} F f g)
-Case conversion may be inaccurate. Consider using '#align fun_like.ext FunLike.extₓ'. -/
theorem ext (f g : F) (h : ∀ x : α, f x = g x) : f = g :=
coe_injective (funext h)
#align fun_like.ext FunLike.ext
-/- warning: fun_like.ext_iff -> FunLike.ext_iff is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, Iff (Eq.{u1} F f g) (forall (x : α), Eq.{u3} (β x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g x))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u1}} {β : α -> Sort.{u2}} [i : FunLike.{u3, u1, u2} F α β] {f : F} {g : F}, Iff (Eq.{u3} F f g) (forall (x : α), Eq.{u2} (β x) (FunLike.coe.{u3, u1, u2} F α (fun (_x : α) => β _x) i f x) (FunLike.coe.{u3, u1, u2} F α (fun (_x : α) => β _x) i g x))
-Case conversion may be inaccurate. Consider using '#align fun_like.ext_iff FunLike.ext_iffₓ'. -/
theorem ext_iff {f g : F} : f = g ↔ ∀ x, f x = g x :=
coe_fn_eq.symm.trans Function.funext_iff
#align fun_like.ext_iff FunLike.ext_iff
-/- warning: fun_like.congr_fun -> FunLike.congr_fun is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, (Eq.{u1} F f g) -> (forall (x : α), Eq.{u3} (β x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g x))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u1}} {β : α -> Sort.{u2}} [i : FunLike.{u3, u1, u2} F α β] {f : F} {g : F}, (Eq.{u3} F f g) -> (forall (x : α), Eq.{u2} (β x) (FunLike.coe.{u3, u1, u2} F α (fun (_x : α) => β _x) i f x) (FunLike.coe.{u3, u1, u2} F α (fun (_x : α) => β _x) i g x))
-Case conversion may be inaccurate. Consider using '#align fun_like.congr_fun FunLike.congr_funₓ'. -/
protected theorem congr_fun {f g : F} (h₁ : f = g) (x : α) : f x = g x :=
congr_fun (congr_arg _ h₁) x
#align fun_like.congr_fun FunLike.congr_fun
-/- warning: fun_like.ne_iff -> FunLike.ne_iff is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, Iff (Ne.{u1} F f g) (Exists.{u2} α (fun (a : α) => Ne.{u3} (β a) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f a) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g a)))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : α -> Sort.{u1}} [i : FunLike.{u3, u2, u1} F α β] {f : F} {g : F}, Iff (Ne.{u3} F f g) (Exists.{u2} α (fun (a : α) => Ne.{u1} (β a) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => β _x) i f a) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => β _x) i g a)))
-Case conversion may be inaccurate. Consider using '#align fun_like.ne_iff FunLike.ne_iffₓ'. -/
theorem ne_iff {f g : F} : f ≠ g ↔ ∃ a, f a ≠ g a :=
ext_iff.Not.trans not_forall
#align fun_like.ne_iff FunLike.ne_iff
-/- warning: fun_like.exists_ne -> FunLike.exists_ne is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] {f : F} {g : F}, (Ne.{u1} F f g) -> (Exists.{u2} α (fun (x : α) => Ne.{u3} (β x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => forall (a : α), β a) (FunLike.hasCoeToFun.{u1, u2, u3} F α β i) g x)))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : α -> Sort.{u1}} [i : FunLike.{u3, u2, u1} F α β] {f : F} {g : F}, (Ne.{u3} F f g) -> (Exists.{u2} α (fun (x : α) => Ne.{u1} (β x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => β _x) i f x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => β _x) i g x)))
-Case conversion may be inaccurate. Consider using '#align fun_like.exists_ne FunLike.exists_neₓ'. -/
theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
ne_iff.mp h
#align fun_like.exists_ne FunLike.exists_ne
-/- warning: fun_like.subsingleton_cod -> FunLike.subsingleton_cod is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : α -> Sort.{u3}} [i : FunLike.{u1, u2, u3} F α β] [_inst_1 : forall (a : α), Subsingleton.{u3} (β a)], Subsingleton.{u1} F
-but is expected to have type
- forall {F : Sort.{u1}} {α : Sort.{u3}} {β : α -> Sort.{u2}} [i : FunLike.{u1, u3, u2} F α β] [_inst_1 : forall (a : α), Subsingleton.{u2} (β a)], Subsingleton.{u1} F
-Case conversion may be inaccurate. Consider using '#align fun_like.subsingleton_cod FunLike.subsingleton_codₓ'. -/
/-- This is not an instance to avoid slowing down every single `subsingleton` typeclass search.-/
theorem subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
⟨fun f g => coe_injective <| Subsingleton.elim _ _⟩
@@ -299,22 +227,10 @@ include i
namespace FunLike
-/- warning: fun_like.congr -> FunLike.congr is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : Sort.{u3}} [i : FunLike.{u1, u2, u3} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u1} F f g) -> (Eq.{u2} α x y) -> (Eq.{u3} β (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) g y))
-but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : Sort.{u1}} [i : FunLike.{u3, u2, u1} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u3} F f g) -> (Eq.{u2} α x y) -> (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.616 : α) => β) x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.616 : α) => β) _x) i f x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.616 : α) => β) _x) i g y))
-Case conversion may be inaccurate. Consider using '#align fun_like.congr FunLike.congrₓ'. -/
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
#align fun_like.congr FunLike.congr
-/- warning: fun_like.congr_arg -> FunLike.congr_arg is a dubious translation:
-lean 3 declaration is
- forall {F : Sort.{u1}} {α : Sort.{u2}} {β : Sort.{u3}} [i : FunLike.{u1, u2, u3} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u2} α x y) -> (Eq.{u3} β (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f y))
-but is expected to have type
- forall {F : Sort.{u1}} {α : Sort.{u3}} {β : Sort.{u2}} [i : FunLike.{u1, u3, u2} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u3} α x y) -> (Eq.{u2} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.659 : α) => β) x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.659 : α) => β) _x) i f x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.659 : α) => β) _x) i f y))
-Case conversion may be inaccurate. Consider using '#align fun_like.congr_arg FunLike.congr_argₓ'. -/
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
#align fun_like.congr_arg FunLike.congr_arg
mathlib commit https://github.com/leanprover-community/mathlib/commit/95a87616d63b3cb49d3fe678d416fbe9c4217bf4
@@ -303,7 +303,7 @@ namespace FunLike
lean 3 declaration is
forall {F : Sort.{u1}} {α : Sort.{u2}} {β : Sort.{u3}} [i : FunLike.{u1, u2, u3} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u1} F f g) -> (Eq.{u2} α x y) -> (Eq.{u3} β (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) g y))
but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : Sort.{u1}} [i : FunLike.{u3, u2, u1} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u3} F f g) -> (Eq.{u2} α x y) -> (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.614 : α) => β) x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.614 : α) => β) _x) i f x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.614 : α) => β) _x) i g y))
+ forall {F : Sort.{u3}} {α : Sort.{u2}} {β : Sort.{u1}} [i : FunLike.{u3, u2, u1} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u3} F f g) -> (Eq.{u2} α x y) -> (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.616 : α) => β) x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.616 : α) => β) _x) i f x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.616 : α) => β) _x) i g y))
Case conversion may be inaccurate. Consider using '#align fun_like.congr FunLike.congrₓ'. -/
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
@@ -313,7 +313,7 @@ protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x
lean 3 declaration is
forall {F : Sort.{u1}} {α : Sort.{u2}} {β : Sort.{u3}} [i : FunLike.{u1, u2, u3} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u2} α x y) -> (Eq.{u3} β (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f y))
but is expected to have type
- forall {F : Sort.{u1}} {α : Sort.{u3}} {β : Sort.{u2}} [i : FunLike.{u1, u3, u2} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u3} α x y) -> (Eq.{u2} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.657 : α) => β) x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.657 : α) => β) _x) i f x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.657 : α) => β) _x) i f y))
+ forall {F : Sort.{u1}} {α : Sort.{u3}} {β : Sort.{u2}} [i : FunLike.{u1, u3, u2} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u3} α x y) -> (Eq.{u2} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.659 : α) => β) x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.659 : α) => β) _x) i f x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.659 : α) => β) _x) i f y))
Case conversion may be inaccurate. Consider using '#align fun_like.congr_arg FunLike.congr_argₓ'. -/
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
mathlib commit https://github.com/leanprover-community/mathlib/commit/09079525fd01b3dda35e96adaa08d2f943e1648c
@@ -134,7 +134,7 @@ instead of linearly increasing the work per `my_hom`-related declaration.
-- This instance should have low priority, to ensure we follow the chain
-- `fun_like → has_coe_to_fun`
-attribute [instance] coeFnTrans
+attribute [instance 10] coeFnTrans
/- warning: fun_like -> FunLike is a dubious translation:
lean 3 declaration is
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -303,7 +303,7 @@ namespace FunLike
lean 3 declaration is
forall {F : Sort.{u1}} {α : Sort.{u2}} {β : Sort.{u3}} [i : FunLike.{u1, u2, u3} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u1} F f g) -> (Eq.{u2} α x y) -> (Eq.{u3} β (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) g y))
but is expected to have type
- forall {F : Sort.{u3}} {α : Sort.{u2}} {β : Sort.{u1}} [i : FunLike.{u3, u2, u1} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u3} F f g) -> (Eq.{u2} α x y) -> (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.596 : α) => β) x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.596 : α) => β) _x) i f x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.596 : α) => β) _x) i g y))
+ forall {F : Sort.{u3}} {α : Sort.{u2}} {β : Sort.{u1}} [i : FunLike.{u3, u2, u1} F α (fun (_x : α) => β)] {f : F} {g : F} {x : α} {y : α}, (Eq.{u3} F f g) -> (Eq.{u2} α x y) -> (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.614 : α) => β) x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.614 : α) => β) _x) i f x) (FunLike.coe.{u3, u2, u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.614 : α) => β) _x) i g y))
Case conversion may be inaccurate. Consider using '#align fun_like.congr FunLike.congrₓ'. -/
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
@@ -313,7 +313,7 @@ protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x
lean 3 declaration is
forall {F : Sort.{u1}} {α : Sort.{u2}} {β : Sort.{u3}} [i : FunLike.{u1, u2, u3} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u2} α x y) -> (Eq.{u3} β (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f x) (coeFn.{u1, imax u2 u3} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{u1, u2, u3} F α (fun (_x : α) => β) i) f y))
but is expected to have type
- forall {F : Sort.{u1}} {α : Sort.{u3}} {β : Sort.{u2}} [i : FunLike.{u1, u3, u2} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u3} α x y) -> (Eq.{u2} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.637 : α) => β) x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.637 : α) => β) _x) i f x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.637 : α) => β) _x) i f y))
+ forall {F : Sort.{u1}} {α : Sort.{u3}} {β : Sort.{u2}} [i : FunLike.{u1, u3, u2} F α (fun (_x : α) => β)] (f : F) {x : α} {y : α}, (Eq.{u3} α x y) -> (Eq.{u2} ((fun (x._@.Mathlib.Data.FunLike.Basic._hyg.657 : α) => β) x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.657 : α) => β) _x) i f x) (FunLike.coe.{u1, u3, u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Basic._hyg.657 : α) => β) _x) i f y))
Case conversion may be inaccurate. Consider using '#align fun_like.congr_arg FunLike.congr_argₓ'. -/
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.
@@ -218,7 +218,7 @@ theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
ne_iff.mp h
#align fun_like.exists_ne DFunLike.exists_ne
-/-- This is not an instance to avoid slowing down every single `Subsingleton` typeclass search.-/
+/-- This is not an instance to avoid slowing down every single `Subsingleton` typeclass search. -/
lemma subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
⟨fun _ _ ↦ coe_injective <| Subsingleton.elim _ _⟩
#align fun_like.subsingleton_cod DFunLike.subsingleton_cod
Fully update the module docstrings (in particular, the examples given therein) after #8386.
This includes switching to where syntax, but also replacing Lean 3 syntax, replacing => by "\mapsto" while at it and indenting code per the style guide. As such, it's also a follow-up to #11301.
Co-authored-by: @Vierkantor
Co-authored-by: Vierkantor <vierkantor@vierkantor.com>
@@ -21,27 +21,23 @@ A typical type of morphisms should be declared as:
```
structure MyHom (A B : Type*) [MyClass A] [MyClass B] :=
(toFun : A → B)
- (map_op' : ∀ {x y : A}, toFun (MyClass.op x y) = MyClass.op (toFun x) (toFun y))
+ (map_op' : ∀ (x y : A), toFun (MyClass.op x y) = MyClass.op (toFun x) (toFun y))
namespace MyHom
variable (A B : Type*) [MyClass A] [MyClass B]
--- This instance is optional if you follow the "morphism class" design below:
-instance : FunLike (MyHom A B) A B :=
- { coe := MyHom.toFun, coe_injective' := fun f g h => by cases f; cases g; congr' }
-
-/-- Helper instance for when there's too many metavariables to apply
-`DFunLike.coe` directly. -/
-instance : CoeFun (MyHom A B) (fun _ => A → B) := ⟨MyHom.toFun⟩
+instance : FunLike (MyHom A B) A B where
+ coe := MyHom.toFun
+ coe_injective' := fun f g h => by cases f; cases g; congr
@[ext] theorem ext {f g : MyHom A B} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h
/-- Copy of a `MyHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
-protected def copy (f : MyHom A B) (f' : A → B) (h : f' = ⇑f) : MyHom A B :=
- { toFun := f',
- map_op' := h.symm ▸ f.map_op' }
+protected def copy (f : MyHom A B) (f' : A → B) (h : f' = ⇑f) : MyHom A B where
+ toFun := f'
+ map_op' := h.symm ▸ f.map_op'
end MyHom
```
@@ -51,8 +47,8 @@ extensionality and simp lemmas.
## Morphism classes extending `DFunLike` and `FunLike`
-The `DFunLike` design provides further benefits if you put in a bit more work.
-The first step is to extend `DFunLike` to create a class of those types satisfying
+The `FunLike` design provides further benefits if you put in a bit more work.
+The first step is to extend `FunLike` to create a class of those types satisfying
the axioms of your new type of morphisms.
Continuing the example above:
@@ -60,20 +56,20 @@ Continuing the example above:
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam Type*) [MyClass A] [MyClass B]
- [FunLike F A B] : Prop :=
-(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
+ [FunLike F A B] : Prop :=
+ (map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
-@[simp] lemma map_op {F A B : Type*} [MyClass A] [MyClass B] [MyHomClass F A B]
- (f : F) (x y : A) : f (MyClass.op x y) = MyClass.op (f x) (f y) :=
-MyHomClass.map_op
+@[simp]
+lemma map_op {F A B : Type*} [MyClass A] [MyClass B] [FunLike F A B] [MyHomClass F A B]
+ (f : F) (x y : A) :
+ f (MyClass.op x y) = MyClass.op (f x) (f y) :=
+ MyHomClass.map_op _ _ _
-- You can add the below instance next to `MyHomClass.instFunLike`:
-instance : MyHomClass (MyHom A B) A B :=
- { coe := MyHom.toFun,
- coe_injective' := λ f g h, by cases f; cases g; congr',
- map_op := MyHom.map_op' }
+instance : MyHomClass (MyHom A B) A B where
+ map_op := MyHom.map_op'
--- [Insert `CoeFun`, `ext` and `copy` here]
+-- [Insert `ext` and `copy` here]
```
Note that `A B` are marked as `outParam` even though they are not purely required to be so
@@ -85,28 +81,28 @@ The second step is to add instances of your new `MyHomClass` for all types exten
Typically, you can just declare a new class analogous to `MyHomClass`:
```
-structure CoolerHom (A B : Type*) [CoolClass A] [CoolClass B]
- extends MyHom A B :=
-(map_cool' : toFun CoolClass.cool = CoolClass.cool)
+structure CoolerHom (A B : Type*) [CoolClass A] [CoolClass B] extends MyHom A B :=
+ (map_cool' : toFun CoolClass.cool = CoolClass.cool)
class CoolerHomClass (F : Type*) (A B : outParam Type*) [CoolClass A] [CoolClass B]
- [FunLike F A B]
- extends MyHomClass F A B :=
-(map_cool : ∀ (f : F), f CoolClass.cool = CoolClass.cool)
-
-@[simp] lemma map_cool {F A B : Type*} [CoolClass A] [CoolClass B] [FunLike F A (fun _ => B)]
- [CoolerHomClass F A B] (f : F) :
- f CoolClass.cool = CoolClass.cool :=
-MyHomClass.map_op
-
--- You can add the below instance next to `MyHom.instFunLike`:
-instance : CoolerHomClass (CoolHom A B) A B :=
- { coe := CoolHom.toFun,
- coe_injective' := λ f g h, by cases f; cases g; congr',
- map_op := CoolHom.map_op',
- map_cool := CoolHom.map_cool' }
-
--- [Insert `CoeFun`, `ext` and `copy` here]
+ [FunLike F A B] extends MyHomClass F A B :=
+ (map_cool : ∀ (f : F), f CoolClass.cool = CoolClass.cool)
+
+@[simp] lemma map_cool {F A B : Type*} [CoolClass A] [CoolClass B] [FunLike F A B]
+ [CoolerHomClass F A B] (f : F) : f CoolClass.cool = CoolClass.cool :=
+ CoolerHomClass.map_cool _
+
+variable {A B : Type*} [CoolClass A] [CoolClass B]
+
+instance : FunLike (CoolerHom A B) A B where
+ coe f := f.toFun
+ coe_injective' := fun f g h ↦ by cases f; cases g; congr; apply DFunLike.coe_injective; congr
+
+instance : CoolerHomClass (CoolerHom A B) A B where
+ map_op f := f.map_op'
+ map_cool f := f.map_cool'
+
+-- [Insert `ext` and `copy` here]
```
Then any declaration taking a specific type of morphisms as parameter can instead take the
variables
, universes
' syntax in doc comments (#11404)
It's deprecated in favour of variable
; likely a leftover from the port.
Also replace universes
, which is invalid now.
@@ -25,7 +25,7 @@ structure MyHom (A B : Type*) [MyClass A] [MyClass B] :=
namespace MyHom
-variables (A B : Type*) [MyClass A] [MyClass B]
+variable (A B : Type*) [MyClass A] [MyClass B]
-- This instance is optional if you follow the "morphism class" design below:
instance : FunLike (MyHom A B) A B :=
This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0
branch as we update to intermediate nightlies.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>
@@ -178,7 +178,7 @@ instance (priority := 100) hasCoeToFun : CoeFun F (fun _ ↦ ∀ a : α, β a) w
coe := @DFunLike.coe _ _ β _ -- need to make explicit to beta reduce for non-dependent functions
run_cmd Lean.Elab.Command.liftTermElabM do
- Std.Tactic.Coe.registerCoercion ``DFunLike.coe
+ Lean.Meta.registerCoercion ``DFunLike.coe
(some { numArgs := 5, coercee := 4, type := .coeFun })
-- @[simp] -- Porting note: this loops in lean 4
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -181,7 +181,7 @@ run_cmd Lean.Elab.Command.liftTermElabM do
Std.Tactic.Coe.registerCoercion ``DFunLike.coe
(some { numArgs := 5, coercee := 4, type := .coeFun })
--- @[simp] -- porting note: this loops in lean 4
+-- @[simp] -- Porting note: this loops in lean 4
theorem coe_eq_coe_fn : (DFunLike.coe (F := F)) = (fun f => ↑f) := rfl
#align fun_like.coe_eq_coe_fn DFunLike.coe_eq_coe_fn
#eval
by run_cmd
in Funlike/Basic
(#10848)
This is the only #eval
used in Mathlib
.
@@ -177,7 +177,7 @@ variable {F α β} [i : DFunLike F α β]
instance (priority := 100) hasCoeToFun : CoeFun F (fun _ ↦ ∀ a : α, β a) where
coe := @DFunLike.coe _ _ β _ -- need to make explicit to beta reduce for non-dependent functions
-#eval Lean.Elab.Command.liftTermElabM do
+run_cmd Lean.Elab.Command.liftTermElabM do
Std.Tactic.Coe.registerCoercion ``DFunLike.coe
(some { numArgs := 5, coercee := 4, type := .coeFun })
The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun
instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike
is EquivLike
, since that has a custom coe_injective'
field that is easier to implement. All other classes should take FunLike
or EquivLike
as a parameter.
Previously, morphism classes would be Type
-valued and extend FunLike
:
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
After this PR, they should be Prop
-valued and take FunLike
as a parameter:
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
[FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
(Note that A B
stay marked as outParam
even though they are not purely required to be so due to the FunLike
parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam
is slightly faster.)
Similarly, MyEquivClass
should take EquivLike
as a parameter.
As a result, every mention of [MyHomClass F A B]
should become [FunLike F A B] [MyHomClass F A B]
.
While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul
is more expensive. This is due to suboptimal processing of arguments. For example:
variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)
theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y
example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _
Before this PR, applying map_mul f
gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]
. Since M
and N
are out_param
s, [MulHomClass F ?M ?N]
is synthesized first, supplies values for ?M
and ?N
and then the Mul M
and Mul N
instances can be found.
After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]
. Now [FunLike F ?M ?N]
is synthesized first, supplies values for ?M
and ?N
and then the Mul M
and Mul N
instances can be found, before trying MulHomClass F M N
which fails. Since the Mul
hierarchy is very big, this can be slow to fail, especially when there is no such Mul
instance.
A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul
to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N]
because MulHomClass
fails or succeeds much faster than the others.
As a consequence, the simpNF
linter is much slower since by design it tries and fails to apply many map_
lemmas. The same issue occurs a few times in existing calls to simp [map_mul]
, where map_mul
is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.
simp
not firing sometimesThis affects map_smulₛₗ
and related definitions. For simp
lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw
can find every argument to map_smulₛₗ
successfully but simp
can't: leanprover/lean4#3701.
Especially in the category theory library, we might sometimes have a type A
which is also accessible as a synonym (Bundled A hA).1
. Instance synthesis doesn't always work if we have f : A →* B
but x * y : (Bundled A hA).1
or vice versa. This seems to be mostly fixed by keeping A B
as outParam
s in MulHomClass F A B
. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1
instead of using the syntax in the discrimination tree.)
The timeouts can be worked around for now by specifying which map_mul
we mean, either as map_mul f
for some explicit f
, or as e.g. MonoidHomClass.map_mul
.
map_smulₛₗ
not firing as simp
lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ
a simp
lemma instead of the generic map_smulₛₗ
. Writing simp [map_smulₛₗ _]
also works.
Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@@ -13,7 +13,9 @@ import Mathlib.Util.CompileInductive
This typeclass is primarily for use by homomorphisms like `MonoidHom` and `LinearMap`.
-## Basic usage of `DFunLike`
+There is the "D"ependent version `DFunLike` and the non-dependent version `FunLike`.
+
+## Basic usage of `DFunLike` and `FunLike`
A typical type of morphisms should be declared as:
```
@@ -26,12 +28,12 @@ namespace MyHom
variables (A B : Type*) [MyClass A] [MyClass B]
-- This instance is optional if you follow the "morphism class" design below:
-instance : DFunLike (MyHom A B) A (λ _, B) :=
- { coe := MyHom.toFun, coe_injective' := λ f g h, by cases f; cases g; congr' }
+instance : FunLike (MyHom A B) A B :=
+ { coe := MyHom.toFun, coe_injective' := fun f g h => by cases f; cases g; congr' }
/-- Helper instance for when there's too many metavariables to apply
`DFunLike.coe` directly. -/
-instance : CoeFun (MyHom A B) (λ _, A → B) := ⟨MyHom.toFun⟩
+instance : CoeFun (MyHom A B) (fun _ => A → B) := ⟨MyHom.toFun⟩
@[ext] theorem ext {f g : MyHom A B} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h
@@ -47,7 +49,7 @@ end MyHom
This file will then provide a `CoeFun` instance and various
extensionality and simp lemmas.
-## Morphism classes extending `DFunLike`
+## Morphism classes extending `DFunLike` and `FunLike`
The `DFunLike` design provides further benefits if you put in a bit more work.
The first step is to extend `DFunLike` to create a class of those types satisfying
@@ -57,15 +59,15 @@ Continuing the example above:
```
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
-class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
- extends DFunLike F A (λ _, B) :=
+class MyHomClass (F : Type*) (A B : outParam Type*) [MyClass A] [MyClass B]
+ [FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
@[simp] lemma map_op {F A B : Type*} [MyClass A] [MyClass B] [MyHomClass F A B]
(f : F) (x y : A) : f (MyClass.op x y) = MyClass.op (f x) (f y) :=
MyHomClass.map_op
--- You can replace `MyHom.DFunLike` with the below instance:
+-- You can add the below instance next to `MyHomClass.instFunLike`:
instance : MyHomClass (MyHom A B) A B :=
{ coe := MyHom.toFun,
coe_injective' := λ f g h, by cases f; cases g; congr',
@@ -74,6 +76,11 @@ instance : MyHomClass (MyHom A B) A B :=
-- [Insert `CoeFun`, `ext` and `copy` here]
```
+Note that `A B` are marked as `outParam` even though they are not purely required to be so
+due to the `FunLike` parameter already filling them in. This is required to see through
+type synonyms, which is important in the category theory library. Also, it appears having them as
+`outParam` is slightly faster.
+
The second step is to add instances of your new `MyHomClass` for all types extending `MyHom`.
Typically, you can just declare a new class analogous to `MyHomClass`:
@@ -82,15 +89,17 @@ structure CoolerHom (A B : Type*) [CoolClass A] [CoolClass B]
extends MyHom A B :=
(map_cool' : toFun CoolClass.cool = CoolClass.cool)
-class CoolerHomClass (F : Type*) (A B : outParam <| Type*) [CoolClass A] [CoolClass B]
+class CoolerHomClass (F : Type*) (A B : outParam Type*) [CoolClass A] [CoolClass B]
+ [FunLike F A B]
extends MyHomClass F A B :=
(map_cool : ∀ (f : F), f CoolClass.cool = CoolClass.cool)
-@[simp] lemma map_cool {F A B : Type*} [CoolClass A] [CoolClass B] [CoolerHomClass F A B]
- (f : F) : f CoolClass.cool = CoolClass.cool :=
+@[simp] lemma map_cool {F A B : Type*} [CoolClass A] [CoolClass B] [FunLike F A (fun _ => B)]
+ [CoolerHomClass F A B] (f : F) :
+ f CoolClass.cool = CoolClass.cool :=
MyHomClass.map_op
--- You can also replace `MyHom.DFunLike` with the below instance:
+-- You can add the below instance next to `MyHom.instFunLike`:
instance : CoolerHomClass (CoolHom A B) A B :=
{ coe := CoolHom.toFun,
coe_injective' := λ f g h, by cases f; cases g; congr',
@@ -104,13 +113,22 @@ Then any declaration taking a specific type of morphisms as parameter can instea
class you just defined:
```
-- Compare with: lemma do_something (f : MyHom A B) : sorry := sorry
-lemma do_something {F : Type*} [MyHomClass F A B] (f : F) : sorry := sorry
+lemma do_something {F : Type*} [FunLike F A B] [MyHomClass F A B] (f : F) : sorry :=
+ sorry
```
This means anything set up for `MyHom`s will automatically work for `CoolerHomClass`es,
and defining `CoolerHomClass` only takes a constant amount of effort,
instead of linearly increasing the work per `MyHom`-related declaration.
+## Design rationale
+
+The current form of FunLike was set up in pull request #8386:
+https://github.com/leanprover-community/mathlib4/pull/8386
+We made `FunLike` *unbundled*: child classes don't extend `FunLike`, they take a `[FunLike F A B]`
+parameter instead. This suits the instance synthesis algorithm better: it's easy to verify a type
+does **not** have a `FunLike` instance by checking the discrimination tree once instead of searching
+the entire `extends` hierarchy.
-/
-- This instance should have low priority, to ensure we follow the chain
FunLike
(#9833)
This follows up from #9785, which renamed FunLike
to DFunLike
, by introducing a new abbreviation FunLike F α β := DFunLike F α (fun _ => β)
, to make the non-dependent use of FunLike
easier.
I searched for the pattern DFunLike.*fun
and DFunLike.*λ
in all files to replace expressions of the form DFunLike F α (fun _ => β)
with FunLike F α β
. I did this everywhere except for extends
clauses for two reasons: it would conflict with #8386, and more importantly extends
must directly refer to a structure with no unfolding of def
s or abbrev
s.
@@ -122,6 +122,8 @@ instead of linearly increasing the work per `MyHom`-related declaration.
/-- The class `DFunLike F α β` expresses that terms of type `F` have an
injective coercion to (dependent) functions from `α` to `β`.
+For non-dependent functions you can also use the abbreviation `FunLike`.
+
This typeclass is used in the definition of the homomorphism typeclasses,
such as `ZeroHomClass`, `MulHomClass`, `MonoidHomClass`, ....
-/
@@ -136,6 +138,14 @@ class DFunLike (F : Sort*) (α : outParam (Sort*)) (β : outParam <| α → Sort
-- https://github.com/leanprover/lean4/issues/2096
compile_def% DFunLike.coe
+/-- The class `FunLike F α β` (`Fun`ction-`Like`) expresses that terms of type `F`
+have an injective coercion to functions from `α` to `β`.
+`FunLike` is the non-dependent version of `DFunLike`.
+This typeclass is used in the definition of the homomorphism typeclasses,
+such as `ZeroHomClass`, `MulHomClass`, `MonoidHomClass`, ....
+-/
+abbrev FunLike F α β := DFunLike F α fun _ => β
+
section Dependent
/-! ### `DFunLike F α β` where `β` depends on `a : α` -/
@@ -205,9 +215,9 @@ end Dependent
section NonDependent
-/-! ### `DFunLike F α (λ _, β)` where `β` does not depend on `a : α` -/
+/-! ### `FunLike F α β` where `β` does not depend on `a : α` -/
-variable {F α β : Sort*} [i : DFunLike F α fun _ ↦ β]
+variable {F α β : Sort*} [i : FunLike F α β]
namespace DFunLike
FunLike
to DFunLike
(#9785)
This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.
This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:
sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@@ -13,7 +13,7 @@ import Mathlib.Util.CompileInductive
This typeclass is primarily for use by homomorphisms like `MonoidHom` and `LinearMap`.
-## Basic usage of `FunLike`
+## Basic usage of `DFunLike`
A typical type of morphisms should be declared as:
```
@@ -26,14 +26,14 @@ namespace MyHom
variables (A B : Type*) [MyClass A] [MyClass B]
-- This instance is optional if you follow the "morphism class" design below:
-instance : FunLike (MyHom A B) A (λ _, B) :=
+instance : DFunLike (MyHom A B) A (λ _, B) :=
{ coe := MyHom.toFun, coe_injective' := λ f g h, by cases f; cases g; congr' }
/-- Helper instance for when there's too many metavariables to apply
-`FunLike.coe` directly. -/
+`DFunLike.coe` directly. -/
instance : CoeFun (MyHom A B) (λ _, A → B) := ⟨MyHom.toFun⟩
-@[ext] theorem ext {f g : MyHom A B} (h : ∀ x, f x = g x) : f = g := FunLike.ext f g h
+@[ext] theorem ext {f g : MyHom A B} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h
/-- Copy of a `MyHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
@@ -47,10 +47,10 @@ end MyHom
This file will then provide a `CoeFun` instance and various
extensionality and simp lemmas.
-## Morphism classes extending `FunLike`
+## Morphism classes extending `DFunLike`
-The `FunLike` design provides further benefits if you put in a bit more work.
-The first step is to extend `FunLike` to create a class of those types satisfying
+The `DFunLike` design provides further benefits if you put in a bit more work.
+The first step is to extend `DFunLike` to create a class of those types satisfying
the axioms of your new type of morphisms.
Continuing the example above:
@@ -58,14 +58,14 @@ Continuing the example above:
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
- extends FunLike F A (λ _, B) :=
+ extends DFunLike F A (λ _, B) :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
@[simp] lemma map_op {F A B : Type*} [MyClass A] [MyClass B] [MyHomClass F A B]
(f : F) (x y : A) : f (MyClass.op x y) = MyClass.op (f x) (f y) :=
MyHomClass.map_op
--- You can replace `MyHom.FunLike` with the below instance:
+-- You can replace `MyHom.DFunLike` with the below instance:
instance : MyHomClass (MyHom A B) A B :=
{ coe := MyHom.toFun,
coe_injective' := λ f g h, by cases f; cases g; congr',
@@ -90,7 +90,7 @@ class CoolerHomClass (F : Type*) (A B : outParam <| Type*) [CoolClass A] [CoolCl
(f : F) : f CoolClass.cool = CoolClass.cool :=
MyHomClass.map_op
--- You can also replace `MyHom.FunLike` with the below instance:
+-- You can also replace `MyHom.DFunLike` with the below instance:
instance : CoolerHomClass (CoolHom A B) A B :=
{ coe := CoolHom.toFun,
coe_injective' := λ f g h, by cases f; cases g; congr',
@@ -114,111 +114,111 @@ instead of linearly increasing the work per `MyHom`-related declaration.
-/
-- This instance should have low priority, to ensure we follow the chain
--- `FunLike → CoeFun`
+-- `DFunLike → CoeFun`
-- Porting note: this is an elaboration detail from Lean 3, we are going to disable it
-- until it is clearer what the Lean 4 elaborator needs.
-- attribute [instance, priority 10] coe_fn_trans
-/-- The class `FunLike F α β` expresses that terms of type `F` have an
-injective coercion to functions from `α` to `β`.
+/-- The class `DFunLike F α β` expresses that terms of type `F` have an
+injective coercion to (dependent) functions from `α` to `β`.
This typeclass is used in the definition of the homomorphism typeclasses,
such as `ZeroHomClass`, `MulHomClass`, `MonoidHomClass`, ....
-/
@[notation_class * toFun Simps.findCoercionArgs]
-class FunLike (F : Sort*) (α : outParam (Sort*)) (β : outParam <| α → Sort*) where
+class DFunLike (F : Sort*) (α : outParam (Sort*)) (β : outParam <| α → Sort*) where
/-- The coercion from `F` to a function. -/
coe : F → ∀ a : α, β a
/-- The coercion to functions must be injective. -/
coe_injective' : Function.Injective coe
-#align fun_like FunLike
+#align fun_like DFunLike
-- https://github.com/leanprover/lean4/issues/2096
-compile_def% FunLike.coe
+compile_def% DFunLike.coe
section Dependent
-/-! ### `FunLike F α β` where `β` depends on `a : α` -/
+/-! ### `DFunLike F α β` where `β` depends on `a : α` -/
variable (F α : Sort*) (β : α → Sort*)
-namespace FunLike
+namespace DFunLike
-variable {F α β} [i : FunLike F α β]
+variable {F α β} [i : DFunLike F α β]
instance (priority := 100) hasCoeToFun : CoeFun F (fun _ ↦ ∀ a : α, β a) where
- coe := @FunLike.coe _ _ β _ -- need to make explicit to beta reduce for non-dependent functions
+ coe := @DFunLike.coe _ _ β _ -- need to make explicit to beta reduce for non-dependent functions
#eval Lean.Elab.Command.liftTermElabM do
- Std.Tactic.Coe.registerCoercion ``FunLike.coe
+ Std.Tactic.Coe.registerCoercion ``DFunLike.coe
(some { numArgs := 5, coercee := 4, type := .coeFun })
-- @[simp] -- porting note: this loops in lean 4
-theorem coe_eq_coe_fn : (FunLike.coe (F := F)) = (fun f => ↑f) := rfl
-#align fun_like.coe_eq_coe_fn FunLike.coe_eq_coe_fn
+theorem coe_eq_coe_fn : (DFunLike.coe (F := F)) = (fun f => ↑f) := rfl
+#align fun_like.coe_eq_coe_fn DFunLike.coe_eq_coe_fn
theorem coe_injective : Function.Injective (fun f : F ↦ (f : ∀ a : α, β a)) :=
- FunLike.coe_injective'
-#align fun_like.coe_injective FunLike.coe_injective
+ DFunLike.coe_injective'
+#align fun_like.coe_injective DFunLike.coe_injective
@[simp]
theorem coe_fn_eq {f g : F} : (f : ∀ a : α, β a) = (g : ∀ a : α, β a) ↔ f = g :=
- ⟨fun h ↦ FunLike.coe_injective' h, fun h ↦ by cases h; rfl⟩
-#align fun_like.coe_fn_eq FunLike.coe_fn_eq
+ ⟨fun h ↦ DFunLike.coe_injective' h, fun h ↦ by cases h; rfl⟩
+#align fun_like.coe_fn_eq DFunLike.coe_fn_eq
theorem ext' {f g : F} (h : (f : ∀ a : α, β a) = (g : ∀ a : α, β a)) : f = g :=
- FunLike.coe_injective' h
-#align fun_like.ext' FunLike.ext'
+ DFunLike.coe_injective' h
+#align fun_like.ext' DFunLike.ext'
theorem ext'_iff {f g : F} : f = g ↔ (f : ∀ a : α, β a) = (g : ∀ a : α, β a) :=
coe_fn_eq.symm
-#align fun_like.ext'_iff FunLike.ext'_iff
+#align fun_like.ext'_iff DFunLike.ext'_iff
theorem ext (f g : F) (h : ∀ x : α, f x = g x) : f = g :=
- FunLike.coe_injective' (funext h)
-#align fun_like.ext FunLike.ext
+ DFunLike.coe_injective' (funext h)
+#align fun_like.ext DFunLike.ext
theorem ext_iff {f g : F} : f = g ↔ ∀ x, f x = g x :=
coe_fn_eq.symm.trans Function.funext_iff
-#align fun_like.ext_iff FunLike.ext_iff
+#align fun_like.ext_iff DFunLike.ext_iff
protected theorem congr_fun {f g : F} (h₁ : f = g) (x : α) : f x = g x :=
congr_fun (congr_arg _ h₁) x
-#align fun_like.congr_fun FunLike.congr_fun
+#align fun_like.congr_fun DFunLike.congr_fun
theorem ne_iff {f g : F} : f ≠ g ↔ ∃ a, f a ≠ g a :=
ext_iff.not.trans not_forall
-#align fun_like.ne_iff FunLike.ne_iff
+#align fun_like.ne_iff DFunLike.ne_iff
theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
ne_iff.mp h
-#align fun_like.exists_ne FunLike.exists_ne
+#align fun_like.exists_ne DFunLike.exists_ne
/-- This is not an instance to avoid slowing down every single `Subsingleton` typeclass search.-/
lemma subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
⟨fun _ _ ↦ coe_injective <| Subsingleton.elim _ _⟩
-#align fun_like.subsingleton_cod FunLike.subsingleton_cod
+#align fun_like.subsingleton_cod DFunLike.subsingleton_cod
-end FunLike
+end DFunLike
end Dependent
section NonDependent
-/-! ### `FunLike F α (λ _, β)` where `β` does not depend on `a : α` -/
+/-! ### `DFunLike F α (λ _, β)` where `β` does not depend on `a : α` -/
-variable {F α β : Sort*} [i : FunLike F α fun _ ↦ β]
+variable {F α β : Sort*} [i : DFunLike F α fun _ ↦ β]
-namespace FunLike
+namespace DFunLike
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
-#align fun_like.congr FunLike.congr
+#align fun_like.congr DFunLike.congr
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
-#align fun_like.congr_arg FunLike.congr_arg
+#align fun_like.congr_arg DFunLike.congr_arg
-end FunLike
+end DFunLike
end NonDependent
$
with <|
(#9319)
See Zulip thread for the discussion.
@@ -196,7 +196,7 @@ theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
/-- This is not an instance to avoid slowing down every single `Subsingleton` typeclass search.-/
lemma subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
- ⟨fun _ _ ↦ coe_injective $ Subsingleton.elim _ _⟩
+ ⟨fun _ _ ↦ coe_injective <| Subsingleton.elim _ _⟩
#align fun_like.subsingleton_cod FunLike.subsingleton_cod
end FunLike
@@ -146,7 +146,8 @@ namespace FunLike
variable {F α β} [i : FunLike F α β]
-instance (priority := 100) hasCoeToFun : CoeFun F fun _ ↦ ∀ a : α, β a where coe := FunLike.coe
+instance (priority := 100) hasCoeToFun : CoeFun F (fun _ ↦ ∀ a : α, β a) where
+ coe := @FunLike.coe _ _ β _ -- need to make explicit to beta reduce for non-dependent functions
#eval Lean.Elab.Command.liftTermElabM do
Std.Tactic.Coe.registerCoercion ``FunLike.coe
@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.Logic.Function.Basic
-import Mathlib.Tactic.NormCast
import Mathlib.Util.CompileInductive
#align_import data.fun_like.basic from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
@@ -5,6 +5,7 @@ Authors: Anne Baanen
-/
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.NormCast
+import Mathlib.Util.CompileInductive
#align_import data.fun_like.basic from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -17,13 +17,13 @@ This typeclass is primarily for use by homomorphisms like `MonoidHom` and `Linea
A typical type of morphisms should be declared as:
```
-structure MyHom (A B : Type _) [MyClass A] [MyClass B] :=
+structure MyHom (A B : Type*) [MyClass A] [MyClass B] :=
(toFun : A → B)
(map_op' : ∀ {x y : A}, toFun (MyClass.op x y) = MyClass.op (toFun x) (toFun y))
namespace MyHom
-variables (A B : Type _) [MyClass A] [MyClass B]
+variables (A B : Type*) [MyClass A] [MyClass B]
-- This instance is optional if you follow the "morphism class" design below:
instance : FunLike (MyHom A B) A (λ _, B) :=
@@ -57,11 +57,11 @@ Continuing the example above:
```
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
-class MyHomClass (F : Type _) (A B : outParam <| Type _) [MyClass A] [MyClass B]
+class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
extends FunLike F A (λ _, B) :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
-@[simp] lemma map_op {F A B : Type _} [MyClass A] [MyClass B] [MyHomClass F A B]
+@[simp] lemma map_op {F A B : Type*} [MyClass A] [MyClass B] [MyHomClass F A B]
(f : F) (x y : A) : f (MyClass.op x y) = MyClass.op (f x) (f y) :=
MyHomClass.map_op
@@ -78,15 +78,15 @@ The second step is to add instances of your new `MyHomClass` for all types exten
Typically, you can just declare a new class analogous to `MyHomClass`:
```
-structure CoolerHom (A B : Type _) [CoolClass A] [CoolClass B]
+structure CoolerHom (A B : Type*) [CoolClass A] [CoolClass B]
extends MyHom A B :=
(map_cool' : toFun CoolClass.cool = CoolClass.cool)
-class CoolerHomClass (F : Type _) (A B : outParam <| Type _) [CoolClass A] [CoolClass B]
+class CoolerHomClass (F : Type*) (A B : outParam <| Type*) [CoolClass A] [CoolClass B]
extends MyHomClass F A B :=
(map_cool : ∀ (f : F), f CoolClass.cool = CoolClass.cool)
-@[simp] lemma map_cool {F A B : Type _} [CoolClass A] [CoolClass B] [CoolerHomClass F A B]
+@[simp] lemma map_cool {F A B : Type*} [CoolClass A] [CoolClass B] [CoolerHomClass F A B]
(f : F) : f CoolClass.cool = CoolClass.cool :=
MyHomClass.map_op
@@ -104,7 +104,7 @@ Then any declaration taking a specific type of morphisms as parameter can instea
class you just defined:
```
-- Compare with: lemma do_something (f : MyHom A B) : sorry := sorry
-lemma do_something {F : Type _} [MyHomClass F A B] (f : F) : sorry := sorry
+lemma do_something {F : Type*} [MyHomClass F A B] (f : F) : sorry := sorry
```
This means anything set up for `MyHom`s will automatically work for `CoolerHomClass`es,
@@ -126,7 +126,7 @@ This typeclass is used in the definition of the homomorphism typeclasses,
such as `ZeroHomClass`, `MulHomClass`, `MonoidHomClass`, ....
-/
@[notation_class * toFun Simps.findCoercionArgs]
-class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sort _) where
+class FunLike (F : Sort*) (α : outParam (Sort*)) (β : outParam <| α → Sort*) where
/-- The coercion from `F` to a function. -/
coe : F → ∀ a : α, β a
/-- The coercion to functions must be injective. -/
@@ -140,7 +140,7 @@ section Dependent
/-! ### `FunLike F α β` where `β` depends on `a : α` -/
-variable (F α : Sort _) (β : α → Sort _)
+variable (F α : Sort*) (β : α → Sort*)
namespace FunLike
@@ -206,7 +206,7 @@ section NonDependent
/-! ### `FunLike F α (λ _, β)` where `β` does not depend on `a : α` -/
-variable {F α β : Sort _} [i : FunLike F α fun _ ↦ β]
+variable {F α β : Sort*} [i : FunLike F α fun _ ↦ β]
namespace FunLike
@@ -2,15 +2,12 @@
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-
-! This file was ported from Lean 3 source module data.fun_like.basic
-! leanprover-community/mathlib commit a148d797a1094ab554ad4183a4ad6f130358ef64
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.NormCast
+#align_import data.fun_like.basic from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
+
/-!
# Typeclass for a type `F` with an injective map to `A → B`
@@ -21,8 +21,8 @@ This typeclass is primarily for use by homomorphisms like `MonoidHom` and `Linea
A typical type of morphisms should be declared as:
```
structure MyHom (A B : Type _) [MyClass A] [MyClass B] :=
-(toFun : A → B)
-(map_op' : ∀ {x y : A}, toFun (MyClass.op x y) = MyClass.op (toFun x) (toFun y))
+ (toFun : A → B)
+ (map_op' : ∀ {x y : A}, toFun (MyClass.op x y) = MyClass.op (toFun x) (toFun y))
namespace MyHom
@@ -30,7 +30,7 @@ variables (A B : Type _) [MyClass A] [MyClass B]
-- This instance is optional if you follow the "morphism class" design below:
instance : FunLike (MyHom A B) A (λ _, B) :=
-{ coe := MyHom.toFun, coe_injective' := λ f g h, by cases f; cases g; congr' }
+ { coe := MyHom.toFun, coe_injective' := λ f g h, by cases f; cases g; congr' }
/-- Helper instance for when there's too many metavariables to apply
`FunLike.coe` directly. -/
@@ -41,8 +41,8 @@ instance : CoeFun (MyHom A B) (λ _, A → B) := ⟨MyHom.toFun⟩
/-- Copy of a `MyHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : MyHom A B) (f' : A → B) (h : f' = ⇑f) : MyHom A B :=
-{ toFun := f',
- map_op' := h.symm ▸ f.map_op' }
+ { toFun := f',
+ map_op' := h.symm ▸ f.map_op' }
end MyHom
```
@@ -70,9 +70,9 @@ MyHomClass.map_op
-- You can replace `MyHom.FunLike` with the below instance:
instance : MyHomClass (MyHom A B) A B :=
-{ coe := MyHom.toFun,
- coe_injective' := λ f g h, by cases f; cases g; congr',
- map_op := MyHom.map_op' }
+ { coe := MyHom.toFun,
+ coe_injective' := λ f g h, by cases f; cases g; congr',
+ map_op := MyHom.map_op' }
-- [Insert `CoeFun`, `ext` and `copy` here]
```
@@ -95,10 +95,10 @@ MyHomClass.map_op
-- You can also replace `MyHom.FunLike` with the below instance:
instance : CoolerHomClass (CoolHom A B) A B :=
-{ coe := CoolHom.toFun,
- coe_injective' := λ f g h, by cases f; cases g; congr',
- map_op := CoolHom.map_op',
- map_cool := CoolHom.map_cool' }
+ { coe := CoolHom.toFun,
+ coe_injective' := λ f g h, by cases f; cases g; congr',
+ map_op := CoolHom.map_op',
+ map_cool := CoolHom.map_cool' }
-- [Insert `CoeFun`, `ext` and `copy` here]
```
@@ -198,7 +198,7 @@ theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
/-- This is not an instance to avoid slowing down every single `Subsingleton` typeclass search.-/
lemma subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
-⟨fun _ _ ↦ coe_injective $ Subsingleton.elim _ _⟩
+ ⟨fun _ _ ↦ coe_injective $ Subsingleton.elim _ _⟩
#align fun_like.subsingleton_cod FunLike.subsingleton_cod
end FunLike
compile_inductive%
and compile_def%
commands (#4097)
Add a #compile inductive
command to compile the recursors of an inductive type, which works by creating a recursive definition and using @[csimp]
.
Co-authored-by: Parth Shastri <31370288+cppio@users.noreply.github.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -136,6 +136,9 @@ class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sor
coe_injective' : Function.Injective coe
#align fun_like FunLike
+-- https://github.com/leanprover/lean4/issues/2096
+compile_def% FunLike.coe
+
section Dependent
/-! ### `FunLike F α β` where `β` depends on `a : α` -/
@[simps]
for the definition of an AddGroup
, it will now generate the correct lemmas for 0
, +
, nsmul
and zsmul
using OfNat
and heterogenous operations. This is needed for #2609.
nsmul
, zsmul
and numerals.zpow
and npow
projections, since their argument order is different than that of HPow.pow
(that was likely done for the sake of to_additive
, but we can consider to revisit that choice).nvMonoid
bug encountered in #2609
toDiv
is a prefix of toDivInvMonoid
_toDiv
is a prefix of your projection with _
prepended (e.g. _toDivInvMonoid
), now we are checking whether toDiv_
is a prefix of your projection with _
appended (which doesn't match toDivInvMonoid_
).@@ -128,6 +128,7 @@ injective coercion to functions from `α` to `β`.
This typeclass is used in the definition of the homomorphism typeclasses,
such as `ZeroHomClass`, `MulHomClass`, `MonoidHomClass`, ....
-/
+@[notation_class * toFun Simps.findCoercionArgs]
class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sort _) where
/-- The coercion from `F` to a function. -/
coe : F → ∀ a : α, β a
@@ -145,7 +145,7 @@ namespace FunLike
variable {F α β} [i : FunLike F α β]
-instance (priority := 100) : CoeFun F fun _ ↦ ∀ a : α, β a where coe := FunLike.coe
+instance (priority := 100) hasCoeToFun : CoeFun F fun _ ↦ ∀ a : α, β a where coe := FunLike.coe
#eval Lean.Elab.Command.liftTermElabM do
Std.Tactic.Coe.registerCoercion ``FunLike.coe
This PR is the result of a slight variant on the following "algorithm"
_
and make all uppercase letters into lowercase_
and make all uppercase letters into lowercase(original_lean3_name, OriginalLean4Name)
#align
statement just before the next empty line#align
statement to have been inserted too early)@@ -133,6 +133,7 @@ class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sor
coe : F → ∀ a : α, β a
/-- The coercion to functions must be injective. -/
coe_injective' : Function.Injective coe
+#align fun_like FunLike
section Dependent
@@ -152,38 +153,49 @@ instance (priority := 100) : CoeFun F fun _ ↦ ∀ a : α, β a where coe := Fu
-- @[simp] -- porting note: this loops in lean 4
theorem coe_eq_coe_fn : (FunLike.coe (F := F)) = (fun f => ↑f) := rfl
+#align fun_like.coe_eq_coe_fn FunLike.coe_eq_coe_fn
theorem coe_injective : Function.Injective (fun f : F ↦ (f : ∀ a : α, β a)) :=
FunLike.coe_injective'
+#align fun_like.coe_injective FunLike.coe_injective
@[simp]
theorem coe_fn_eq {f g : F} : (f : ∀ a : α, β a) = (g : ∀ a : α, β a) ↔ f = g :=
⟨fun h ↦ FunLike.coe_injective' h, fun h ↦ by cases h; rfl⟩
+#align fun_like.coe_fn_eq FunLike.coe_fn_eq
theorem ext' {f g : F} (h : (f : ∀ a : α, β a) = (g : ∀ a : α, β a)) : f = g :=
FunLike.coe_injective' h
+#align fun_like.ext' FunLike.ext'
theorem ext'_iff {f g : F} : f = g ↔ (f : ∀ a : α, β a) = (g : ∀ a : α, β a) :=
coe_fn_eq.symm
+#align fun_like.ext'_iff FunLike.ext'_iff
theorem ext (f g : F) (h : ∀ x : α, f x = g x) : f = g :=
FunLike.coe_injective' (funext h)
+#align fun_like.ext FunLike.ext
theorem ext_iff {f g : F} : f = g ↔ ∀ x, f x = g x :=
coe_fn_eq.symm.trans Function.funext_iff
+#align fun_like.ext_iff FunLike.ext_iff
protected theorem congr_fun {f g : F} (h₁ : f = g) (x : α) : f x = g x :=
congr_fun (congr_arg _ h₁) x
+#align fun_like.congr_fun FunLike.congr_fun
theorem ne_iff {f g : F} : f ≠ g ↔ ∃ a, f a ≠ g a :=
ext_iff.not.trans not_forall
+#align fun_like.ne_iff FunLike.ne_iff
theorem exists_ne {f g : F} (h : f ≠ g) : ∃ x, f x ≠ g x :=
ne_iff.mp h
+#align fun_like.exists_ne FunLike.exists_ne
/-- This is not an instance to avoid slowing down every single `Subsingleton` typeclass search.-/
lemma subsingleton_cod [∀ a, Subsingleton (β a)] : Subsingleton F :=
⟨fun _ _ ↦ coe_injective $ Subsingleton.elim _ _⟩
+#align fun_like.subsingleton_cod FunLike.subsingleton_cod
end FunLike
@@ -199,9 +211,11 @@ namespace FunLike
protected theorem congr {f g : F} {x y : α} (h₁ : f = g) (h₂ : x = y) : f x = g y :=
congr (congr_arg _ h₁) h₂
+#align fun_like.congr FunLike.congr
protected theorem congr_arg (f : F) {x y : α} (h₂ : x = y) : f x = f y :=
congr_arg _ h₂
+#align fun_like.congr_arg FunLike.congr_arg
end FunLike
Type*
to Type _
(#1866)
A bunch of docstrings were still mentioning Type*
. This changes them to Type _
.
@@ -20,13 +20,13 @@ This typeclass is primarily for use by homomorphisms like `MonoidHom` and `Linea
A typical type of morphisms should be declared as:
```
-structure MyHom (A B : Type*) [MyClass A] [MyClass B] :=
+structure MyHom (A B : Type _) [MyClass A] [MyClass B] :=
(toFun : A → B)
(map_op' : ∀ {x y : A}, toFun (MyClass.op x y) = MyClass.op (toFun x) (toFun y))
namespace MyHom
-variables (A B : Type*) [MyClass A] [MyClass B]
+variables (A B : Type _) [MyClass A] [MyClass B]
-- This instance is optional if you follow the "morphism class" design below:
instance : FunLike (MyHom A B) A (λ _, B) :=
@@ -60,11 +60,11 @@ Continuing the example above:
```
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
-class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
+class MyHomClass (F : Type _) (A B : outParam <| Type _) [MyClass A] [MyClass B]
extends FunLike F A (λ _, B) :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
-@[simp] lemma map_op {F A B : Type*} [MyClass A] [MyClass B] [MyHomClass F A B]
+@[simp] lemma map_op {F A B : Type _} [MyClass A] [MyClass B] [MyHomClass F A B]
(f : F) (x y : A) : f (MyClass.op x y) = MyClass.op (f x) (f y) :=
MyHomClass.map_op
@@ -81,15 +81,15 @@ The second step is to add instances of your new `MyHomClass` for all types exten
Typically, you can just declare a new class analogous to `MyHomClass`:
```
-structure CoolerHom (A B : Type*) [CoolClass A] [CoolClass B]
+structure CoolerHom (A B : Type _) [CoolClass A] [CoolClass B]
extends MyHom A B :=
(map_cool' : toFun CoolClass.cool = CoolClass.cool)
-class CoolerHomClass (F : Type*) (A B : outParam <| Type*) [CoolClass A] [CoolClass B]
+class CoolerHomClass (F : Type _) (A B : outParam <| Type _) [CoolClass A] [CoolClass B]
extends MyHomClass F A B :=
(map_cool : ∀ (f : F), f CoolClass.cool = CoolClass.cool)
-@[simp] lemma map_cool {F A B : Type*} [CoolClass A] [CoolClass B] [CoolerHomClass F A B]
+@[simp] lemma map_cool {F A B : Type _} [CoolClass A] [CoolClass B] [CoolerHomClass F A B]
(f : F) : f CoolClass.cool = CoolClass.cool :=
MyHomClass.map_op
@@ -107,7 +107,7 @@ Then any declaration taking a specific type of morphisms as parameter can instea
class you just defined:
```
-- Compare with: lemma do_something (f : MyHom A B) : sorry := sorry
-lemma do_something {F : Type*} [MyHomClass F A B] (f : F) : sorry := sorry
+lemma do_something {F : Type _} [MyHomClass F A B] (f : F) : sorry := sorry
```
This means anything set up for `MyHom`s will automatically work for `CoolerHomClass`es,
Fix a lot of wrong casing mostly in the docstrings but also sometimes in def/theorem names. E.g. fin 2 --> Fin 2
, add_monoid_hom --> AddMonoidHom
Remove \n
from to_additive
docstrings that were inserted by mathport.
Move files and directories with Gcd
and Smul
to GCD
and SMul
@@ -126,7 +126,7 @@ instead of linearly increasing the work per `MyHom`-related declaration.
injective coercion to functions from `α` to `β`.
This typeclass is used in the definition of the homomorphism typeclasses,
-such as `zero_hom_class`, `mul_hom_class`, `monoid_hom_class`, ....
+such as `ZeroHomClass`, `MulHomClass`, `MonoidHomClass`, ....
-/
class FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sort _) where
/-- The coercion from `F` to a function. -/
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
@@ -2,6 +2,11 @@
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
+
+! This file was ported from Lean 3 source module data.fun_like.basic
+! leanprover-community/mathlib commit a148d797a1094ab554ad4183a4ad6f130358ef64
+! Please do not edit these lines, except to modify the commit id
+! if you have ported upstream changes.
-/
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.NormCast
All dependencies are ported!