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 19
- Petri Nets 9
- Epidemiology 4
- 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 69
- Azimuth Code Project 110
- Statistical methods 4
- Drafts 2
- Math Syntax Demos 15
- Wiki - Latest Changes 3
- Strategy 113
- Azimuth Project 1.1K
- - Spam 1
- News and Information 148
- Azimuth Blog 149
- - Conventions and Policies 21
- - Questions 43
- Azimuth Wiki 713

Options

YouTube link.

## Comments

How do we know that Fix is an initial algebra? As I understand, Lambek's lemma tells us that if it's an initial algebra, then it will be a fixed point (because F(X) is isomorphic to X). But how do we know that the converse is true? Just because something is a fixed point, does that also mean it will be an initial algebra?

`How do we know that Fix is an initial algebra? As I understand, Lambek's lemma tells us that if it's an initial algebra, then it will be a fixed point (because F(X) is isomorphic to X). But how do we know that the converse is true? Just because something is a fixed point, does that also mean it will be an initial algebra?`

@EricRogstad Recall that a morphism in the category of F-algebras is a function

`m :: a -> b`

mapping`f :: f a -> a`

to`g :: f b -> b`

by obeying the law:In order to show that

`Fix :: f (Fix f) -> Fix f`

is initial, we need to find for every other algebra`h :: f c -> c`

some`m :: Fix f -> c`

where the rule above is obeyed...[EDIT: Formatting, fixing F-algebra morphism law]

`@EricRogstad Recall that a morphism in the category of F-algebras is a function `m :: a -> b` mapping `f :: f a -> a` to `g :: f b -> b` by obeying the law: m . f = g . fmap m In order to show that `Fix :: f (Fix f) -> Fix f` is initial, we need to find for every other algebra `h :: f c -> c` some `m :: Fix f -> c` where the rule above is obeyed... [EDIT: Formatting, fixing F-algebra morphism law]`

The answer is that, in general, we don't know. If there is a unique fixed point then it must be both the initial algebra and the terminal coalgebra. Infinite streams are an example of a terminal coalgebra for the product functor

`Pair a x`

, but an initial algebra for it is`Void`

.`The answer is that, in general, we don't know. If there is a unique fixed point then it must be both the initial algebra and the terminal coalgebra. Infinite streams are an example of a terminal coalgebra for the product functor `Pair a x`, but an initial algebra for it is `Void`.`

@EricRogstad - I want to follow up and ellaborate on your question (and clear things up, mostly for my own edification).

Bartosz just pointed out that we

don't always knowif`Fix :: f (Fix f) -> Fix f`

is initial, because we don't always know if the type`Fix f`

is inhabited. For example if we define the type...then neither

`Fix (Pair a)`

nor`Pair a (Fix (Pair a)`

are inhabited by a terminating program. So you couldn't do anything meaningful with one in PureScript, and we have to leverage lazy evaluation in Haskell to make use of it.The restriction that we only consider terminating programs comes from page 33 of the companion notes, as mentioned elsewhere on this forum.

Since

`Fix (Pair a)`

has no inhabitants, it's like`Void`

.`Void`

is the empty datatype defined like this:I started answering this yesterday but I'll finish today, starting from the top. Define:

And let's suppose that

`f`

is a functor and the type`Fix f`

is inhabited. We want to show that the F-algebrais initial.

Proof.In order to show it's initial, then for each F-algebra`g :: f a -> a`

we must find a function`m :: Fix f -> a`

such that`m . Fix = g . fmap m`

Here's how we do it. First define

`cata`

as follows (I'm stealing this from Bartosz's writings on www.schoolofhaskell.com):This is exactly what we need!Let

`m`

be`cata g :: Fix f -> a`

. We need to show that`cata g . Fix = g . fmap (cata g)`

, which is pretty straight-forward:...since

`unFix . Fix = id`

. So there we go, we have a constructive proof that`Fix :: f (Fix f) -> Fix f`

is initial. \(\Box\)[EDIT: typos]

`@EricRogstad - I want to follow up and ellaborate on your question (and clear things up, mostly for my own edification). > How do we know that Fix is an initial algebra? Bartosz just pointed out that we _don't always know_ if `Fix :: f (Fix f) -> Fix f` is initial, because we don't always know if the type `Fix f` is inhabited. For example if we define the type data Pair a b = Pair a b ...then neither `Fix (Pair a)` nor `Pair a (Fix (Pair a)` are inhabited by a terminating program. So you couldn't do anything meaningful with one in PureScript, and we have to leverage lazy evaluation in Haskell to make use of it. The restriction that we only consider terminating programs comes from page 33 of [the companion notes](http://brendanfong.com/programmingcats_files/cats4progs-DRAFT.pdf), as mentioned elsewhere on this forum. Since `Fix (Pair a)` has no inhabitants, it's like `Void`. `Void` is the empty datatype defined like this: data Void ---------------------------------------- > But how do we know that the converse is true? Just because something is a fixed point, does that also mean it will be an initial algebra? I started answering this yesterday but I'll finish today, starting from the top. Define: data Fix f = Fix { unfix :: f (Fix f) } And let's suppose that `f` is a functor and the type `Fix f` is inhabited. We want to show that the F-algebra Fix :: f (Fix f) -> Fix f is initial. **Proof.** In order to show it's initial, then for each F-algebra `g :: f a -> a` we must find a function `m :: Fix f -> a` such that `m . Fix = g . fmap m` Here's how we do it. First define `cata` as follows (I'm stealing this from Bartosz's writings on [www.schoolofhaskell.com](https://www.schoolofhaskell.com/user/bartosz/understanding-algebras#catamorphisms)): cata :: Functor f => (f a -> a) -> Fix f -> a cata alg = alg . fmap (cata alg) . unFix _**This is exactly what we need!**_ Let `m` be `cata g :: Fix f -> a`. We need to show that `cata g . Fix = g . fmap (cata g)`, which is pretty straight-forward: cata g . Fix = g . fmap (cata g) . unFix . Fix = g . fmap (cata g) ...since `unFix . Fix = id`. So there we go, we have a constructive proof that `Fix :: f (Fix f) -> Fix f` is initial. \\(\Box\\) [EDIT: typos]`

Thanks!

`Thanks!`

@MatthewDotty : Strictly speaking, you'd also have to prove that the catamorphism is unique.

`@MatthewDotty : Strictly speaking, you'd also have to prove that the catamorphism is unique.`

@Bartosz - You are absolutely right!

But I can't really think of sufficient conditions for

`f`

which let us get that`cata g`

is unique...`@Bartosz - You are absolutely right! But I can't really think of sufficient conditions for `f` which let us get that `cata g` is unique...`

Is this question even for this lecture (I wonder :) ) First let me say hi from Amsterdam, and complement all of you on this magnificent project. Things are slowly clicking in my mind, but now I am pondering this question (after watching this lecture hence) if I have carrier i and structure map F i -> i as my initial algebra and another algebra F a -> a and they commute (as they would) does a needs to be of the same type as i? Or could it be completely different. Thanks in advance for any answer. Regards Laurens

`Is this question even for this lecture (I wonder :) ) First let me say hi from Amsterdam, and complement all of you on this magnificent project. Things are slowly clicking in my mind, but now I am pondering this question (after watching this lecture hence) if I have carrier i and structure map F i -> i as my initial algebra and another algebra F a -> a and they commute (as they would) does a needs to be of the same type as i? Or could it be completely different. Thanks in advance for any answer. Regards Laurens`

The answer is I guess that the structure map is not a ploymorphic function and thus i and a in the above question are of the same type.

`The answer is I guess that the structure map is not a ploymorphic function and thus i and a in the above question are of the same type.`