Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 27ae77c

Browse files
kim-emmergify[bot]
authored andcommitted
feat(tactic/tidy): lower the priority of ext in tidy (#1178)
* feat(category_theory/adjunction): additional simp lemmas * experimenting with deferring ext in tidy * abbreviate some proofs * refactoring CommRing/adjunctions * renaming
1 parent 4af3976 commit 27ae77c

File tree

3 files changed

+25
-56
lines changed

3 files changed

+25
-56
lines changed

src/algebra/CommRing/adjunctions.lean

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import algebra.CommRing.basic
1010
import category_theory.adjunction.basic
1111
import data.mv_polynomial
1212

13+
noncomputable theory
14+
1315
universe u
1416

1517
open mv_polynomial
@@ -19,23 +21,27 @@ namespace CommRing
1921

2022
local attribute [instance, priority 0] classical.prop_decidable
2123

22-
noncomputable def polynomial_ring : Type u ⥤ CommRing.{u} :=
23-
{ obj := λ α, ⟨mv_polynomial α ℤ⟩,
24-
map := λ α β f, ⟨rename f, by apply_instance⟩ }
24+
private def free_obj (α : Type u) : CommRing.{u} := ⟨mv_polynomial α ℤ⟩
25+
26+
def free : Type u ⥤ CommRing.{u} :=
27+
{ obj := free_obj,
28+
map := λ α β f, ⟨rename f, by apply_instance⟩, }
29+
30+
@[simp] lemma free_obj_α {α : Type u} :
31+
(free.obj α).α = mv_polynomial α ℤ := rfl
2532

26-
@[simp] lemma polynomial_ring_obj_α {α : Type u} :
27-
(polynomial_ring.obj α).α = mv_polynomial α ℤ := rfl
33+
@[simp] lemma free_map_valβ : Type u} {f : α → β} :
34+
(free.map f).val = rename f := rfl
2835

29-
@[simp] lemma polynomial_ring_map_val {α β : Type u} {f : α → β} :
30-
(polynomial_ring.map f).val = rename f := rfl
36+
def hom_equiv (α : Type u) (R : CommRing.{u}) : (free.obj α ⟶ R) ≃ (α ⟶ forget.obj R) :=
37+
{ to_fun := λ f, f ∘ X,
38+
inv_fun := λ f, ⟨eval₂ (λ n : ℤ, (n : R)) f, by { unfold_coes, apply_instance }⟩,
39+
left_inv := λ f, bundled.hom_ext (@eval₂_hom_X _ _ _ _ _ _ f.val _),
40+
right_inv := λ x, by { ext1, unfold_coes, simp only [function.comp_app, eval₂_X] } }
3141

32-
noncomputable def adj : polynomial_ring ⊣ (forget : CommRing ⥤ Type u) :=
42+
def adj : free ⊣ (forget : CommRing ⥤ Type u) :=
3343
adjunction.mk_of_hom_equiv
34-
{ hom_equiv := λ α R,
35-
{ to_fun := λ f, f ∘ X,
36-
inv_fun := λ f, ⟨eval₂ (λ n : ℤ, (n : R)) f, by { unfold_coes, apply_instance }⟩,
37-
left_inv := λ f, bundled.hom_ext (@eval₂_hom_X _ _ _ _ _ _ f.val _),
38-
right_inv := λ x, by { ext1, unfold_coes, simp only [function.comp_app, eval₂_X] } },
44+
{ hom_equiv := hom_equiv,
3945
hom_equiv_naturality_left_symm' :=
4046
λ X X' Y f g, by { ext1, dsimp, apply eval₂_cast_comp } }.
4147

src/category_theory/adjunction/limits.lean

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,8 @@ def functoriality_is_left_adjoint :
2929
{ right := (cocones.functoriality G) ⋙ (cocones.precompose
3030
(K.right_unitor.inv ≫ (whisker_left K adj.unit) ≫ (associator _ _ _).inv)),
3131
adj := mk_of_unit_counit
32-
{ unit :=
33-
{ app := λ c,
34-
{ hom := adj.unit.app c.X,
35-
w' := λ j, by have := adj.unit.naturality (c.ι.app j); tidy },
36-
naturality' := λ _ _ f, by have := adj.unit.naturality (f.hom); tidy },
37-
counit :=
38-
{ app := λ c,
39-
{ hom := adj.counit.app c.X,
40-
w' :=
41-
begin
42-
intro j,
43-
dsimp,
44-
erw [category.comp_id, category.id_comp, F.map_comp, category.assoc,
45-
adj.counit.naturality (c.ι.app j), ← category.assoc,
46-
adj.left_triangle_components, category.id_comp],
47-
refl,
48-
end },
49-
naturality' := λ _ _ f, by have := adj.counit.naturality (f.hom); tidy } } }
32+
{ unit := { app := λ c, { hom := adj.unit.app c.X } },
33+
counit := { app := λ c, { hom := adj.counit.app c.X } } } }
5034

5135
/-- A left adjoint preserves colimits. -/
5236
def left_adjoint_preserves_colimits : preserves_colimits F :=
@@ -67,24 +51,8 @@ def functoriality_is_right_adjoint :
6751
{ left := (cones.functoriality F) ⋙ (cones.postcompose
6852
((associator _ _ _).hom ≫ (whisker_left K adj.counit) ≫ K.right_unitor.hom)),
6953
adj := mk_of_unit_counit
70-
{ unit :=
71-
{ app := λ c,
72-
{ hom := adj.unit.app c.X,
73-
w' :=
74-
begin
75-
intro j,
76-
dsimp,
77-
erw [category.comp_id, category.id_comp, G.map_comp, ← category.assoc,
78-
← adj.unit.naturality (c.π.app j), category.assoc,
79-
adj.right_triangle_components, category.comp_id],
80-
refl,
81-
end },
82-
naturality' := λ _ _ f, by have := adj.unit.naturality (f.hom); tidy },
83-
counit :=
84-
{ app := λ c,
85-
{ hom := adj.counit.app c.X,
86-
w' := λ j, by have := adj.counit.naturality (c.π.app j); tidy },
87-
naturality' := λ _ _ f, by have := adj.counit.naturality (f.hom); tidy } } }
54+
{ unit := { app := λ c, { hom := adj.unit.app c.X, } },
55+
counit := { app := λ c, { hom := adj.counit.app c.X, } } } }
8856

8957
/-- A right adjoint preserves limits. -/
9058
def right_adjoint_preserves_limits : preserves_limits G :=
@@ -110,12 +78,7 @@ nat_iso.of_components (λ Y,
11078
erw [← adj.hom_equiv_naturality_left_symm, ← adj.hom_equiv_naturality_right_symm, t.naturality],
11179
dsimp, simp
11280
end } } )
113-
begin
114-
intros Y₁ Y₂ f,
115-
ext1 t,
116-
ext1 j,
117-
apply adj.hom_equiv_naturality_right
118-
end
81+
(by tidy)
11982

12083
-- Note: this is natural in K, but we do not yet have the tools to formulate that.
12184
def cones_iso {J : Type v} [small_category J] {K : J ⥤ D} :

src/tactic/tidy.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ meta def default_tactics : list (tactic string) :=
4444
[ reflexivity >> pure "refl",
4545
`[exact dec_trivial] >> pure "exact dec_trivial",
4646
propositional_goal >> assumption >> pure "assumption",
47-
ext1_wrapper,
4847
intros1 >>= λ ns, pure ("intros " ++ (" ".intercalate (ns.map (λ e, e.to_string)))),
4948
auto_cases,
5049
`[apply_auto_param] >> pure "apply_auto_param",
5150
`[dsimp at *] >> pure "dsimp at *",
5251
`[simp at *] >> pure "simp at *",
52+
ext1_wrapper,
5353
fsplit >> pure "fsplit",
5454
injections_and_clear >> pure "injections_and_clear",
5555
propositional_goal >> (`[solve_by_elim]) >> pure "solve_by_elim",

0 commit comments

Comments
 (0)