order.category.HeytAlgMathlib.Order.Category.HeytAlg

This file has been ported!

Changes since the initial port

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

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(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)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -60,7 +60,7 @@ instance bundledHom : BundledHom HeytingHom
   toFun α β [HeytingAlgebra α] [HeytingAlgebra β] := (coeFn : HeytingHom α β → α → β)
   id := HeytingHom.id
   comp := @HeytingHom.comp
-  hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := FunLike.coe_injective
+  hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := DFunLike.coe_injective
 #align HeytAlg.bundled_hom HeytAlg.bundledHom
 -/
 
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Yaël Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yaël Dillies
 -/
-import Mathbin.Order.Category.BddDistLat
-import Mathbin.Order.Heyting.Hom
+import Order.Category.BddDistLat
+import Order.Heyting.Hom
 
 #align_import order.category.HeytAlg from "leanprover-community/mathlib"@"8af7091a43227e179939ba132e54e54e9f3b089a"
 
@@ -22,70 +22,70 @@ universe u
 
 open CategoryTheory Opposite Order
 
-#print HeytAlgCat /-
+#print HeytAlg /-
 /-- The category of Heyting algebras. -/
-def HeytAlgCat :=
+def HeytAlg :=
   Bundled HeytingAlgebra
-#align HeytAlg HeytAlgCat
+#align HeytAlg HeytAlg
 -/
 
-namespace HeytAlgCat
+namespace HeytAlg
 
-instance : CoeSort HeytAlgCat (Type _) :=
+instance : CoeSort HeytAlg (Type _) :=
   Bundled.hasCoeToSort
 
-instance (X : HeytAlgCat) : HeytingAlgebra X :=
+instance (X : HeytAlg) : HeytingAlgebra X :=
   X.str
 
-#print HeytAlgCat.of /-
+#print HeytAlg.of /-
 /-- Construct a bundled `HeytAlg` from a `heyting_algebra`. -/
-def of (α : Type _) [HeytingAlgebra α] : HeytAlgCat :=
+def of (α : Type _) [HeytingAlgebra α] : HeytAlg :=
   Bundled.of α
-#align HeytAlg.of HeytAlgCat.of
+#align HeytAlg.of HeytAlg.of
 -/
 
-#print HeytAlgCat.coe_of /-
+#print HeytAlg.coe_of /-
 @[simp]
 theorem coe_of (α : Type _) [HeytingAlgebra α] : ↥(of α) = α :=
   rfl
-#align HeytAlg.coe_of HeytAlgCat.coe_of
+#align HeytAlg.coe_of HeytAlg.coe_of
 -/
 
-instance : Inhabited HeytAlgCat :=
+instance : Inhabited HeytAlg :=
   ⟨of PUnit⟩
 
-#print HeytAlgCat.bundledHom /-
+#print HeytAlg.bundledHom /-
 instance bundledHom : BundledHom HeytingHom
     where
   toFun α β [HeytingAlgebra α] [HeytingAlgebra β] := (coeFn : HeytingHom α β → α → β)
   id := HeytingHom.id
   comp := @HeytingHom.comp
   hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := FunLike.coe_injective
-#align HeytAlg.bundled_hom HeytAlgCat.bundledHom
+#align HeytAlg.bundled_hom HeytAlg.bundledHom
 -/
 
-deriving instance LargeCategory, ConcreteCategory for HeytAlgCat
+deriving instance LargeCategory, ConcreteCategory for HeytAlg
 
-#print HeytAlgCat.hasForgetToLat /-
+#print HeytAlg.hasForgetToLat /-
 @[simps]
-instance hasForgetToLat : HasForget₂ HeytAlgCat BddDistLatCat
+instance hasForgetToLat : HasForget₂ HeytAlg BddDistLat
     where forget₂ :=
-    { obj := fun X => BddDistLatCat.of X
+    { obj := fun X => BddDistLat.of X
       map := fun X Y f => (f : BoundedLatticeHom X Y) }
-#align HeytAlg.has_forget_to_Lat HeytAlgCat.hasForgetToLat
+#align HeytAlg.has_forget_to_Lat HeytAlg.hasForgetToLat
 -/
 
-#print HeytAlgCat.Iso.mk /-
+#print HeytAlg.Iso.mk /-
 /-- Constructs an isomorphism of Heyting algebras from an order isomorphism between them. -/
 @[simps]
-def Iso.mk {α β : HeytAlgCat.{u}} (e : α ≃o β) : α ≅ β
+def Iso.mk {α β : HeytAlg.{u}} (e : α ≃o β) : α ≅ β
     where
   Hom := e
   inv := e.symm
   hom_inv_id' := by ext; exact e.symm_apply_apply _
   inv_hom_id' := by ext; exact e.apply_symm_apply _
-#align HeytAlg.iso.mk HeytAlgCat.Iso.mk
+#align HeytAlg.iso.mk HeytAlg.Iso.mk
 -/
 
-end HeytAlgCat
+end HeytAlg
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Yaël Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yaël Dillies
-
-! This file was ported from Lean 3 source module order.category.HeytAlg
-! leanprover-community/mathlib commit 8af7091a43227e179939ba132e54e54e9f3b089a
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Order.Category.BddDistLat
 import Mathbin.Order.Heyting.Hom
 
+#align_import order.category.HeytAlg from "leanprover-community/mathlib"@"8af7091a43227e179939ba132e54e54e9f3b089a"
+
 /-!
 # The category of Heyting algebras
 
Diff
@@ -25,58 +25,70 @@ universe u
 
 open CategoryTheory Opposite Order
 
+#print HeytAlgCat /-
 /-- The category of Heyting algebras. -/
-def HeytAlg :=
+def HeytAlgCat :=
   Bundled HeytingAlgebra
-#align HeytAlg HeytAlg
+#align HeytAlg HeytAlgCat
+-/
 
-namespace HeytAlg
+namespace HeytAlgCat
 
-instance : CoeSort HeytAlg (Type _) :=
+instance : CoeSort HeytAlgCat (Type _) :=
   Bundled.hasCoeToSort
 
-instance (X : HeytAlg) : HeytingAlgebra X :=
+instance (X : HeytAlgCat) : HeytingAlgebra X :=
   X.str
 
+#print HeytAlgCat.of /-
 /-- Construct a bundled `HeytAlg` from a `heyting_algebra`. -/
-def of (α : Type _) [HeytingAlgebra α] : HeytAlg :=
+def of (α : Type _) [HeytingAlgebra α] : HeytAlgCat :=
   Bundled.of α
-#align HeytAlg.of HeytAlg.of
+#align HeytAlg.of HeytAlgCat.of
+-/
 
+#print HeytAlgCat.coe_of /-
 @[simp]
 theorem coe_of (α : Type _) [HeytingAlgebra α] : ↥(of α) = α :=
   rfl
-#align HeytAlg.coe_of HeytAlg.coe_of
+#align HeytAlg.coe_of HeytAlgCat.coe_of
+-/
 
-instance : Inhabited HeytAlg :=
+instance : Inhabited HeytAlgCat :=
   ⟨of PUnit⟩
 
+#print HeytAlgCat.bundledHom /-
 instance bundledHom : BundledHom HeytingHom
     where
   toFun α β [HeytingAlgebra α] [HeytingAlgebra β] := (coeFn : HeytingHom α β → α → β)
   id := HeytingHom.id
   comp := @HeytingHom.comp
   hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := FunLike.coe_injective
-#align HeytAlg.bundled_hom HeytAlg.bundledHom
+#align HeytAlg.bundled_hom HeytAlgCat.bundledHom
+-/
 
-deriving instance LargeCategory, ConcreteCategory for HeytAlg
+deriving instance LargeCategory, ConcreteCategory for HeytAlgCat
 
+#print HeytAlgCat.hasForgetToLat /-
 @[simps]
-instance hasForgetToLat : HasForget₂ HeytAlg BddDistLat
+instance hasForgetToLat : HasForget₂ HeytAlgCat BddDistLatCat
     where forget₂ :=
-    { obj := fun X => BddDistLat.of X
+    { obj := fun X => BddDistLatCat.of X
       map := fun X Y f => (f : BoundedLatticeHom X Y) }
-#align HeytAlg.has_forget_to_Lat HeytAlg.hasForgetToLat
+#align HeytAlg.has_forget_to_Lat HeytAlgCat.hasForgetToLat
+-/
 
+#print HeytAlgCat.Iso.mk /-
 /-- Constructs an isomorphism of Heyting algebras from an order isomorphism between them. -/
 @[simps]
-def Iso.mk {α β : HeytAlg.{u}} (e : α ≃o β) : α ≅ β
+def Iso.mk {α β : HeytAlgCat.{u}} (e : α ≃o β) : α ≅ β
     where
   Hom := e
   inv := e.symm
   hom_inv_id' := by ext; exact e.symm_apply_apply _
   inv_hom_id' := by ext; exact e.apply_symm_apply _
-#align HeytAlg.iso.mk HeytAlg.Iso.mk
+#align HeytAlg.iso.mk HeytAlgCat.Iso.mk
+-/
 
-end HeytAlg
+end HeytAlgCat
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yaël Dillies
 
 ! This file was ported from Lean 3 source module order.category.HeytAlg
-! leanprover-community/mathlib commit e8ac6315bcfcbaf2d19a046719c3b553206dac75
+! leanprover-community/mathlib commit 8af7091a43227e179939ba132e54e54e9f3b089a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.Order.Heyting.Hom
 /-!
 # The category of Heyting algebras
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file defines `HeytAlg`, the category of Heyting algebras.
 -/
 
Diff
@@ -71,12 +71,8 @@ def Iso.mk {α β : HeytAlg.{u}} (e : α ≃o β) : α ≅ β
     where
   Hom := e
   inv := e.symm
-  hom_inv_id' := by
-    ext
-    exact e.symm_apply_apply _
-  inv_hom_id' := by
-    ext
-    exact e.apply_symm_apply _
+  hom_inv_id' := by ext; exact e.symm_apply_apply _
+  inv_hom_id' := by ext; exact e.apply_symm_apply _
 #align HeytAlg.iso.mk HeytAlg.Iso.mk
 
 end HeytAlg
Diff
@@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yaël Dillies
 
 ! This file was ported from Lean 3 source module order.category.HeytAlg
-! leanprover-community/mathlib commit 51cbe88849c5bcf9eaf8e38f2bbdf1a44bbabe0c
+! leanprover-community/mathlib commit e8ac6315bcfcbaf2d19a046719c3b553206dac75
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.Order.Category.BoundedDistribLattice
+import Mathbin.Order.Category.BddDistLat
 import Mathbin.Order.Heyting.Hom
 
 /-!
@@ -59,11 +59,11 @@ instance bundledHom : BundledHom HeytingHom
 deriving instance LargeCategory, ConcreteCategory for HeytAlg
 
 @[simps]
-instance hasForgetToLattice : HasForget₂ HeytAlg BoundedDistribLattice
+instance hasForgetToLat : HasForget₂ HeytAlg BddDistLat
     where forget₂ :=
-    { obj := fun X => BoundedDistribLattice.of X
+    { obj := fun X => BddDistLat.of X
       map := fun X Y f => (f : BoundedLatticeHom X Y) }
-#align HeytAlg.has_forget_to_Lattice HeytAlg.hasForgetToLattice
+#align HeytAlg.has_forget_to_Lat HeytAlg.hasForgetToLat
 
 /-- Constructs an isomorphism of Heyting algebras from an order isomorphism between them. -/
 @[simps]

Changes in mathlib4

mathlib3
mathlib4
refactor(Data/FunLike): use unbundled inheritance from FunLike (#8386)

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.

Zulip thread

Important changes

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].

Remaining issues

Slower (failing) search

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_params, [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 sometimes

This 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.

Missing instances due to unification failing

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 outParams 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.)

Workaround for issues

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>

Diff
@@ -61,6 +61,10 @@ instance : ConcreteCategory HeytAlg := by
   dsimp [HeytAlg]
   infer_instance
 
+-- Porting note: No idea why it does not find this instance...
+instance {X Y : HeytAlg.{u}} : FunLike (X ⟶ Y) ↑X ↑Y :=
+  HeytingHom.instFunLike
+
 -- Porting note: No idea why it does not find this instance...
 instance {X Y : HeytAlg.{u}} : HeytingHomClass (X ⟶ Y) ↑X ↑Y :=
   HeytingHom.instHeytingHomClass
chore(*): rename 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>

Diff
@@ -47,10 +47,10 @@ instance : Inhabited HeytAlg :=
   ⟨of PUnit⟩
 
 instance bundledHom : BundledHom HeytingHom where
-  toFun α β [HeytingAlgebra α] [HeytingAlgebra β] := (FunLike.coe : HeytingHom α β → α → β)
+  toFun α β [HeytingAlgebra α] [HeytingAlgebra β] := (DFunLike.coe : HeytingHom α β → α → β)
   id := @HeytingHom.id
   comp := @HeytingHom.comp
-  hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := FunLike.coe_injective
+  hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := DFunLike.coe_injective
 #align HeytAlg.bundled_hom HeytAlg.bundledHom
 
 deriving instance LargeCategory for HeytAlg
chore: Remove Cat suffixes (#3730)

These names needn't change in the first place.

Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 Yaël Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yaël Dillies
 -/
-import Mathlib.Order.Category.BddDistLatCat
+import Mathlib.Order.Category.BddDistLat
 import Mathlib.Order.Heyting.Hom
 
 #align_import order.category.HeytAlg from "leanprover-community/mathlib"@"e8ac6315bcfcbaf2d19a046719c3b553206dac75"
@@ -21,29 +21,29 @@ universe u
 open CategoryTheory Opposite Order
 
 /-- The category of Heyting algebras. -/
-def HeytAlgCat :=
+def HeytAlg :=
   Bundled HeytingAlgebra
-#align HeytAlg HeytAlgCat
+#align HeytAlg HeytAlg
 
-namespace HeytAlgCat
+namespace HeytAlg
 
-instance : CoeSort HeytAlgCat (Type*) :=
+instance : CoeSort HeytAlg (Type*) :=
   Bundled.coeSort
 
-instance (X : HeytAlgCat) : HeytingAlgebra X :=
+instance (X : HeytAlg) : HeytingAlgebra X :=
   X.str
 
-/-- Construct a bundled `HeytAlgCat` from a `HeytingAlgebra`. -/
-def of (α : Type*) [HeytingAlgebra α] : HeytAlgCat :=
+/-- Construct a bundled `HeytAlg` from a `HeytingAlgebra`. -/
+def of (α : Type*) [HeytingAlgebra α] : HeytAlg :=
   Bundled.of α
-#align HeytAlg.of HeytAlgCat.of
+#align HeytAlg.of HeytAlg.of
 
 @[simp]
 theorem coe_of (α : Type*) [HeytingAlgebra α] : ↥(of α) = α :=
   rfl
-#align HeytAlg.coe_of HeytAlgCat.coe_of
+#align HeytAlg.coe_of HeytAlg.coe_of
 
-instance : Inhabited HeytAlgCat :=
+instance : Inhabited HeytAlg :=
   ⟨of PUnit⟩
 
 instance bundledHom : BundledHom HeytingHom where
@@ -51,34 +51,34 @@ instance bundledHom : BundledHom HeytingHom where
   id := @HeytingHom.id
   comp := @HeytingHom.comp
   hom_ext α β [HeytingAlgebra α] [HeytingAlgebra β] := FunLike.coe_injective
-#align HeytAlg.bundled_hom HeytAlgCat.bundledHom
+#align HeytAlg.bundled_hom HeytAlg.bundledHom
 
-deriving instance LargeCategory for HeytAlgCat
+deriving instance LargeCategory for HeytAlg
 
 -- Porting note: deriving failed.
 -- see https://github.com/leanprover-community/mathlib4/issues/5020
-instance : ConcreteCategory HeytAlgCat := by
-  dsimp [HeytAlgCat]
+instance : ConcreteCategory HeytAlg := by
+  dsimp [HeytAlg]
   infer_instance
 
 -- Porting note: No idea why it does not find this instance...
-instance {X Y : HeytAlgCat.{u}} : HeytingHomClass (X ⟶ Y) ↑X ↑Y :=
+instance {X Y : HeytAlg.{u}} : HeytingHomClass (X ⟶ Y) ↑X ↑Y :=
   HeytingHom.instHeytingHomClass
 
 @[simps]
-instance hasForgetToLat : HasForget₂ HeytAlgCat BddDistLatCat where
+instance hasForgetToLat : HasForget₂ HeytAlg BddDistLat where
   forget₂ :=
-    { obj := fun X => BddDistLatCat.of X
+    { obj := fun X => BddDistLat.of X
       map := fun {X Y} f => (f : BoundedLatticeHom X Y) }
-#align HeytAlg.has_forget_to_Lat HeytAlgCat.hasForgetToLat
+#align HeytAlg.has_forget_to_Lat HeytAlg.hasForgetToLat
 
 /-- Constructs an isomorphism of Heyting algebras from an order isomorphism between them. -/
 @[simps]
-def Iso.mk {α β : HeytAlgCat.{u}} (e : α ≃o β) : α ≅ β where
+def Iso.mk {α β : HeytAlg.{u}} (e : α ≃o β) : α ≅ β where
   hom := (e : HeytingHom _ _)
   inv := (e.symm : HeytingHom _ _)
   hom_inv_id := by ext; exact e.symm_apply_apply _
   inv_hom_id := by ext; exact e.apply_symm_apply _
-#align HeytAlg.iso.mk HeytAlgCat.Iso.mk
+#align HeytAlg.iso.mk HeytAlg.Iso.mk
 
-end HeytAlgCat
+end HeytAlg
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -27,19 +27,19 @@ def HeytAlgCat :=
 
 namespace HeytAlgCat
 
-instance : CoeSort HeytAlgCat (Type _) :=
+instance : CoeSort HeytAlgCat (Type*) :=
   Bundled.coeSort
 
 instance (X : HeytAlgCat) : HeytingAlgebra X :=
   X.str
 
 /-- Construct a bundled `HeytAlgCat` from a `HeytingAlgebra`. -/
-def of (α : Type _) [HeytingAlgebra α] : HeytAlgCat :=
+def of (α : Type*) [HeytingAlgebra α] : HeytAlgCat :=
   Bundled.of α
 #align HeytAlg.of HeytAlgCat.of
 
 @[simp]
-theorem coe_of (α : Type _) [HeytingAlgebra α] : ↥(of α) = α :=
+theorem coe_of (α : Type*) [HeytingAlgebra α] : ↥(of α) = α :=
   rfl
 #align HeytAlg.coe_of HeytAlgCat.coe_of
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

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

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Yaël Dillies. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yaël Dillies
-
-! This file was ported from Lean 3 source module order.category.HeytAlg
-! leanprover-community/mathlib commit e8ac6315bcfcbaf2d19a046719c3b553206dac75
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Order.Category.BddDistLatCat
 import Mathlib.Order.Heyting.Hom
 
+#align_import order.category.HeytAlg from "leanprover-community/mathlib"@"e8ac6315bcfcbaf2d19a046719c3b553206dac75"
+
 /-!
 # The category of Heyting algebras
 
feat: port Order.Category.HeytAlgCat (#5021)

Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>

Dependencies 130

131 files ported (100.0%)
49618 lines ported (100.0%)

All dependencies are ported!