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

Commit 7056d5b

Browse files
committed
reorganising category_theory/instances/rings.lean
1 parent 29507a4 commit 7056d5b

File tree

3 files changed

+71
-49
lines changed

3 files changed

+71
-49
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/- Copyright (c) 2019 Scott Morrison. All rights reserved.
2+
Released under Apache 2.0 license as described in the file LICENSE.
3+
Authors: Scott Morrison, Johannes Hölzl
4+
5+
Multivariable polynomials on a type is the left adjoint of the
6+
forgetful functor from commutative rings to types.
7+
-/
8+
9+
import category_theory.instances.CommRing.basic
10+
import category_theory.adjunction
11+
import data.mv_polynomial
12+
13+
universe u
14+
15+
open mv_polynomial
16+
open category_theory
17+
open category_theory.instances
18+
19+
namespace category_theory.instances.CommRing
20+
21+
local attribute [instance, priority 0] subtype.fintype set_fintype classical.prop_decidable
22+
23+
noncomputable def polynomial_ring : Type u ⥤ CommRing.{u} :=
24+
{ obj := λ α, ⟨mv_polynomial α ℤ, by apply_instance⟩,
25+
map := λ α β f, ⟨eval₂ C (X ∘ f), by apply_instance⟩,
26+
map_id' := λ α, subtype.ext.mpr $ funext $ eval₂_eta,
27+
map_comp' := λ α β γ f g, subtype.ext.mpr $ funext $ λ p,
28+
by apply mv_polynomial.induction_on p; intros;
29+
simp only [*, eval₂_add, eval₂_mul, eval₂_C, eval₂_X, comp_val,
30+
eq_self_iff_true, function.comp_app, types_comp] at * }
31+
32+
@[simp] lemma polynomial_ring_obj_α {α : Type u} :
33+
(polynomial_ring.obj α).α = mv_polynomial α ℤ := rfl
34+
35+
@[simp] lemma polynomial_ring_map_val {α β : Type u} {f : α → β} :
36+
(polynomial_ring.map f).val = eval₂ C (X ∘ f) := rfl
37+
38+
noncomputable def adj : adjunction polynomial_ring (forget : CommRing ⥤ Type u) :=
39+
adjunction.mk_of_hom_equiv _ _
40+
{ hom_equiv := λ α R,
41+
{ to_fun := λ f, f ∘ X,
42+
inv_fun := λ f, ⟨eval₂ int.cast f, by apply_instance⟩,
43+
left_inv := λ f, subtype.ext.mpr $ funext $ λ p,
44+
begin
45+
have H0 := λ n, (congr (int.eq_cast' (f.val ∘ C)) (rfl : n = n)).symm,
46+
have H1 := λ p₁ p₂, (@is_ring_hom.map_add _ _ _ _ f.val f.2 p₁ p₂).symm,
47+
have H2 := λ p₁ p₂, (@is_ring_hom.map_mul _ _ _ _ f.val f.2 p₁ p₂).symm,
48+
apply mv_polynomial.induction_on p; intros;
49+
simp only [*, eval₂_add, eval₂_mul, eval₂_C, eval₂_X,
50+
eq_self_iff_true, function.comp_app, hom_coe_app] at *
51+
end,
52+
right_inv := by tidy },
53+
hom_equiv_naturality_left_symm' := λ X' X Y f g, subtype.ext.mpr $ funext $ λ p,
54+
begin
55+
apply mv_polynomial.induction_on p; intros;
56+
simp only [*, eval₂_mul, eval₂_add, eval₂_C, eval₂_X,
57+
comp_val, equiv.coe_fn_symm_mk, hom_coe_app, polynomial_ring_map_val,
58+
eq_self_iff_true, function.comp_app, add_right_inj, types_comp] at *
59+
end }
60+
61+
end category_theory.instances.CommRing

src/category_theory/instances/rings.lean renamed to src/category_theory/instances/CommRing/basic.lean

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
33
Authors: Scott Morrison, Johannes Hölzl
44
55
Introduce CommRing -- the category of commutative rings.
6-
7-
Currently only the basic setup.
86
-/
97

108
import category_theory.instances.monoids
119
import category_theory.fully_faithful
12-
import category_theory.adjunction
13-
import data.mv_polynomial
1410
import algebra.ring
11+
import data.int.basic
1512

1613
universes u v
1714

@@ -28,7 +25,7 @@ instance concrete_is_ring_hom : concrete_category @is_ring_hom :=
2825
by introsI α ia; apply_instance,
2926
by introsI α β γ ia ib ic f g hf hg; apply_instance⟩
3027

31-
instance Ring_hom_is_ring_hom {R S : Ring} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2
28+
instance Ring.hom_is_ring_hom {R S : Ring} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2
3229

3330
/-- The category of commutative rings. -/
3431
@[reducible] def CommRing : Type (u+1) := bundled comm_ring
@@ -91,50 +88,6 @@ instance forget_to_CommMon.faithful : faithful (forget_to_CommMon) := {}
9188

9289
example : faithful (forget_to_CommMon ⋙ CommMon.forget_to_Mon) := by apply_instance
9390

94-
section
95-
open mv_polynomial
96-
local attribute [instance, priority 0] subtype.fintype set_fintype classical.prop_decidable
97-
98-
noncomputable def polynomial : Type u ⥤ CommRing.{u} :=
99-
{ obj := λ α, ⟨mv_polynomial α ℤ, by apply_instance⟩,
100-
map := λ α β f, ⟨eval₂ C (X ∘ f), by apply_instance⟩,
101-
map_id' := λ α, subtype.ext.mpr $ funext $ eval₂_eta,
102-
map_comp' := λ α β γ f g, subtype.ext.mpr $ funext $ λ p,
103-
by apply mv_polynomial.induction_on p; intros;
104-
simp only [*, eval₂_add, eval₂_mul, eval₂_C, eval₂_X, comp_val,
105-
eq_self_iff_true, function.comp_app, types_comp] at * }
106-
107-
@[simp] lemma polynomial_obj_α {α : Type u} :
108-
(polynomial.obj α).α = mv_polynomial α ℤ := rfl
109-
110-
@[simp] lemma polynomial_map_val {α β : Type u} {f : α → β} :
111-
(CommRing.polynomial.map f).val = eval₂ C (X ∘ f) := rfl
112-
113-
noncomputable def adj : adjunction polynomial (forget : CommRing ⥤ Type u) :=
114-
adjunction.mk_of_hom_equiv _ _
115-
{ hom_equiv := λ α R,
116-
{ to_fun := λ f, f ∘ X,
117-
inv_fun := λ f, ⟨eval₂ int.cast f, by apply_instance⟩,
118-
left_inv := λ f, subtype.ext.mpr $ funext $ λ p,
119-
begin
120-
have H0 := λ n, (congr (int.eq_cast' (f.val ∘ C)) (rfl : n = n)).symm,
121-
have H1 := λ p₁ p₂, (@is_ring_hom.map_add _ _ _ _ f.val f.2 p₁ p₂).symm,
122-
have H2 := λ p₁ p₂, (@is_ring_hom.map_mul _ _ _ _ f.val f.2 p₁ p₂).symm,
123-
apply mv_polynomial.induction_on p; intros;
124-
simp only [*, eval₂_add, eval₂_mul, eval₂_C, eval₂_X,
125-
eq_self_iff_true, function.comp_app, hom_coe_app] at *
126-
end,
127-
right_inv := by tidy },
128-
hom_equiv_naturality_left_symm' := λ X' X Y f g, subtype.ext.mpr $ funext $ λ p,
129-
begin
130-
apply mv_polynomial.induction_on p; intros;
131-
simp only [*, eval₂_mul, eval₂_add, eval₂_C, eval₂_X,
132-
comp_val, equiv.coe_fn_symm_mk, hom_coe_app, polynomial_map_val,
133-
eq_self_iff_true, function.comp_app, add_right_inj, types_comp] at *
134-
end }
135-
136-
end
137-
13891
end CommRing
13992

14093
end category_theory.instances
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/-
2+
Copyright (c) 2019 Scott Morrison. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Scott Morrison
5+
-/
6+
7+
import category_theory.instances.CommRing.basic
8+
import category_theory.instances.CommRing.adjunctions

0 commit comments

Comments
 (0)