It looks like you're new here. If you want to get involved, click one of these buttons!

- All Categories 2.3K
- Chat 499
- Study Groups 17
- Petri Nets 8
- Epidemiology 3
- Leaf Modeling 1
- Review Sections 9
- MIT 2020: Programming with Categories 51
- MIT 2020: Lectures 20
- MIT 2020: Exercises 25
- MIT 2019: Applied Category Theory 339
- MIT 2019: Lectures 79
- MIT 2019: Exercises 149
- MIT 2019: Chat 50
- UCR ACT Seminar 4
- General 67
- Azimuth Code Project 110
- Statistical methods 3
- Drafts 2
- Math Syntax Demos 15
- Wiki - Latest Changes 3
- Strategy 113
- Azimuth Project 1.1K
- - Spam 1
- News and Information 147
- Azimuth Blog 149
- - Conventions and Policies 21
- - Questions 43
- Azimuth Wiki 707

Options

*Constant functors.*

Let \(C\) and \(D\) be categories. Given any object \(d\) in \(D\), we can define the *constant functor* \(K_d: C \rightarrow D\) on \(d\). This functor sends *every* object \(C\) to \(d \in Ob\ D\), and *every* morphism of \(C\) to the identity morphism on \(d\).

(a) Take the set \(B\) = {\(T,F\)}. Show that the constant functor \(K_B: Set \rightarrow Set\) obeys the two functor laws: preservation of composition and preservation of identities.

(b) Implement in Haskell the constant functor on the type Bool.

## Comments

Edit: I was confused because we went from a constant functor from Set_Bool -> Set_Bool to a constant functor from Type -> Type. I get now that the constant that they are looking for is the \(Bool \in Obj_{Hask} \)

`> In b: am confused by what it means by "the constant functor" aren't there two constant functors? Edit: I was confused because we went from a constant functor from Set_Bool -> Set_Bool to a constant functor from Type -> Type. I get now that the constant that they are looking for is the \\(Bool \in Obj_{Hask} \\)`

I just noticed this was written in "draft" and I had forgotten to post it :P

`I just noticed this was written in "draft" and I had forgotten to post it :P > newtype ConstF c a = Const c > instance Functor (ConstF c) where > fmap f (Const c) = Const c > kb :: ConstF Bool a > kb = ConstF True > -- fmap id (Const c) = id (Const c) > -- Const c = Const c <-- applying the definition of fmap > -- fmap (f.g) (Const c) = (fmap f . fmap g) (Const c) > -- Const c = fmap f (fmap g (Const c)) <<- applying the definition of fmap on the left side > -- Const c = fmap f (Const c) <-- applying the definition of fmap on the right side > -- Const c = Const c`

Proof (a).

\(K_B\) is the claimed constant functor which maps every set to \(B\) and every morphism to \(Id_B\).

To prove that \(K_B\) is indeed a functor, it suffices to show that for all sets \(S\), the mapping \(K_S\) satisfies the two functor laws.

The identity law for \(K_S: Set \rightarrow Set\) says that for every \(A \in Ob(Set)\), we have that \(K_S(Id_A) = Id_{K_S(A)}\). Since \(K_S(A) = S\), this requirement restates to \(K_S(Id_A) = Id_S\). This is certainly true, as \(K_S\) maps any morphism whatsoever to \(Id_S\).

The composition law requires that for composable morphisms \(f, g\), we have that \(K_S(f \triangleright g) = K_S(f) \triangleright K_S(g)\). That's equivalent to saying that \(Id_S = Id_S \triangleright Id_S\), which is an axiomatic fact.

`Proof (a). \\(K_B\\) is the claimed constant functor which maps every set to \\(B\\) and every morphism to \\(Id_B\\). To prove that \\(K_B\\) is indeed a functor, it suffices to show that for all sets \\(S\\), the mapping \\(K_S\\) satisfies the two functor laws. The identity law for \\(K_S: Set \rightarrow Set\\) says that for every \\(A \in Ob(Set)\\), we have that \\(K_S(Id_A) = Id_{K_S(A)}\\). Since \\(K_S(A) = S\\), this requirement restates to \\(K_S(Id_A) = Id_S\\). This is certainly true, as \\(K_S\\) maps any morphism whatsoever to \\(Id_S\\). The composition law requires that for composable morphisms \\(f, g\\), we have that \\(K_S(f \triangleright g) = K_S(f) \triangleright K_S(g)\\). That's equivalent to saying that \\(Id_S = Id_S \triangleright Id_S\\), which is an axiomatic fact.`