> **Puzzle 89.** Figure out exactly what a **Cost**-category is, starting with the definition above. Again, what matters is not your final answer so much as your process of deducing it!

There is an excellent article by [Simon Willteron](https://golem.ph.utexas.edu/category/2010/08/enriching_over_a_category_of_s.html) which lays out what **Cost**-enriched categories are nicely. Simon mentions Lawvere's [*Metric spaces, generalized logic, and closed categories* (2002)](https://golem.ph.utexas.edu/category/2010/08/enriching_over_a_category_of_s.html) where these ideas originated.

Here is my observation: **Cost**-enriched categories are a generalization of **Bool**-enriched categories.

To start, consider the following monoidal poset which I am calling **Prod**:

$$\langle [0,1], \leq, 1, (\cdot) \rangle$$

...where \\((\cdot)\\) is just ordinary multiplication over \\(\mathbb{R}\\).

Consider the map \\(- \mathrm{ln} : [0,1] \to [0,\infty]\\). This inverse of this map is \\(x \mapsto e^{-x}\\). Moreover, we have the following monoid homomorphisms:

$$

\begin{align}

- \mathrm{ln} (a \cdot b) & = - (\mathrm{ln} (a) + \mathrm{ln} (b)) \\\\

& = - \mathrm{ln} (a) + -\mathrm{ln} (b)

\end{align}

$$

and

$$

\begin{align}

e^{- (a + b)} & = e^{(- a)\, +\, (-b)} \\\\

& = e^{-a} \cdot e^{-b}

\end{align}

$$

Since \\(- \mathrm{ln} \\) and \\(\lambda x. e^{-x}\\) are strictly decreasing, we have

$$\begin{align}

\mathbf{Prod} & \cong \langle [0,1], \leq, 1, (\cdot) \rangle\\\\

& \cong \langle [0,\infty], \geq, 0, + \rangle \\\\

&\cong \mathbf{Cost}

\end{align}$$

We can see that every **Bool**-enriched category is a **Prod**-enriched category, using the following mappings:

$$

\begin{align}

\mathtt{false} & \mapsto 0 \\\\

\mathtt{true} & \mapsto 1 \\\\

(\wedge) & \mapsto (\cdot) \\\\

\end{align}

$$

Morever, say a **Prod**-enriched category \\(\mathcal{X}\\) is *bivalent* if:

$$ \forall x, y. \mathcal{X}(x,y) = 0 \text{ or } \mathcal{X}(x,y) = 1 $$

Then \\(\mathcal{X}\\) is equivalent to a **Bool**-enriched category.

*This is because **Prod** (hence **Cost**) is the fuzzy logic generalization of **Bool** logic called [**Product Logic**](https://plato.stanford.edu/entries/logic-fuzzy/#OtheNotaFuzzLogi).*

**Prod** has inequality in the right direction and feels a lot like **Bool**. But it doesn't have the nice interpretation that **Cost** has.

There is an excellent article by [Simon Willteron](https://golem.ph.utexas.edu/category/2010/08/enriching_over_a_category_of_s.html) which lays out what **Cost**-enriched categories are nicely. Simon mentions Lawvere's [*Metric spaces, generalized logic, and closed categories* (2002)](https://golem.ph.utexas.edu/category/2010/08/enriching_over_a_category_of_s.html) where these ideas originated.

Here is my observation: **Cost**-enriched categories are a generalization of **Bool**-enriched categories.

To start, consider the following monoidal poset which I am calling **Prod**:

$$\langle [0,1], \leq, 1, (\cdot) \rangle$$

...where \\((\cdot)\\) is just ordinary multiplication over \\(\mathbb{R}\\).

Consider the map \\(- \mathrm{ln} : [0,1] \to [0,\infty]\\). This inverse of this map is \\(x \mapsto e^{-x}\\). Moreover, we have the following monoid homomorphisms:

$$

\begin{align}

- \mathrm{ln} (a \cdot b) & = - (\mathrm{ln} (a) + \mathrm{ln} (b)) \\\\

& = - \mathrm{ln} (a) + -\mathrm{ln} (b)

\end{align}

$$

and

$$

\begin{align}

e^{- (a + b)} & = e^{(- a)\, +\, (-b)} \\\\

& = e^{-a} \cdot e^{-b}

\end{align}

$$

Since \\(- \mathrm{ln} \\) and \\(\lambda x. e^{-x}\\) are strictly decreasing, we have

$$\begin{align}

\mathbf{Prod} & \cong \langle [0,1], \leq, 1, (\cdot) \rangle\\\\

& \cong \langle [0,\infty], \geq, 0, + \rangle \\\\

&\cong \mathbf{Cost}

\end{align}$$

We can see that every **Bool**-enriched category is a **Prod**-enriched category, using the following mappings:

$$

\begin{align}

\mathtt{false} & \mapsto 0 \\\\

\mathtt{true} & \mapsto 1 \\\\

(\wedge) & \mapsto (\cdot) \\\\

\end{align}

$$

Morever, say a **Prod**-enriched category \\(\mathcal{X}\\) is *bivalent* if:

$$ \forall x, y. \mathcal{X}(x,y) = 0 \text{ or } \mathcal{X}(x,y) = 1 $$

Then \\(\mathcal{X}\\) is equivalent to a **Bool**-enriched category.

*This is because **Prod** (hence **Cost**) is the fuzzy logic generalization of **Bool** logic called [**Product Logic**](https://plato.stanford.edu/entries/logic-fuzzy/#OtheNotaFuzzLogi).*

**Prod** has inequality in the right direction and feels a lot like **Bool**. But it doesn't have the nice interpretation that **Cost** has.