# Toy model piece #1: Partial preferences revisited

**EDIT**: This model is currently obsolete, see [here](https://www.lesswrong.com/posts/ucG63yw3JgP3rW7tH/toy-model-piece-5-combining-partial-preferences) for the most current version.

I'm working towards a toy model that will illustrate all the steps in the [research agenda](https://www.lesswrong.com/posts/CSEdLLEkap2pubjof/research-agenda-v0-9-synthesising-a-human-s-preferences-into). It will start with some algorithmic stand-in for the "human", and proceed to create the $U_H$, following all the steps in that research agenda. So I'll be posting a series of "toy model pieces", that will then be ultimately combined in a full toy model. Along the way, I hope to get a better understanding of how to do the research agenda in practice, and maybe even modify that agenda based on insights making the toy model.

In this post, I'll revisit and re-formalise [partial preferences](https://www.lesswrong.com/posts/CiB3myyeEhFRgmKPL/partial-preferences-and-models), and then transform them into utility functions.

# The problem with the old definition

My [previous model](https://www.lesswrong.com/posts/CiB3myyeEhFRgmKPL/partial-preferences-and-models) of partial preferences can't capture some very simple mental models, such as $P=$"the more people smile, the better the world is".

This is because the partial preference decomposes the space of worlds locally as $Y \times Z$, fixes two values $y_-$ and $y_+$ in $Y$, and only compares worlds of type $(y_-,z)$ and $(y_+,z)$ for fixed $z$. This means that we can only compare worlds with the same $z$ value, and only two of these worlds can be compared: so we can't say $w_1 < w_2 < w_3$ for three distinct worlds. Thus we can't say that three people smiling is better than two, which is better than one. Not being able to capture preferences like $P$ is a major flaw.

# New definition: preorder

So now model a partial preference as [preorder](https://en.wikipedia.org/wiki/Preorder). A preorder $\leq$ is a type of ordering that is transitive (if $w_1 \leq w_2$ and $w_2 \leq w_3$, then $w_1 \leq w_3$) and reflexive ($w \leq w$ for all worlds $w$).

The previous type of partial preference can be made into a preorder quite easily: $w_1 < w_2$ implies $w_1 \leq w_2$, and add $w \leq w$ for all worlds $w$.

Now we can easily express $P=$"the more people smile, the better the world is". Let $w(n,v)$ be a world with $n$ smiling people in it, with $v$ representing all the other relevant variables describing the world. The $P$ is described by the preorder:

* $w(n,v) \leq w(n,v')$ if and only if $v=v'$ and $n \leq m$.

For a general preorder $\leq$, define $w < w'$ to mean $w \leq w'$ but it not being the case that $w' \leq w$.


# Circular preferences and utility functions

Unfortunately, unlike the previous partial preferences, preorders can allow for circular preferences $w_1 \leq w_2 \leq w_3 \leq w_1$. In practice, most sensible partial preferences will not have circular preferences, and will instead resemble $P$: just a collection of orderings among separate sets of worlds.

But, it will might be possible to have circular partial preferences, maybe of the type "in Australia, the cities gets nicer as you go clockwise along the coast".

So you need a way of dealing with circular preferences, and with complicated sets of partial preferences that might include some circular preferences.

We also want a way to transform all of these preorders into a full preference, given as a utility function over all worlds. The research agenda calls for [aggregating](https://www.lesswrong.com/posts/CSEdLLEkap2pubjof/research-agenda-v0-9-synthesising-a-human-s-preferences-into) similar preferences before making them into full preferences, but we still need some way of doing this in the cases where we have a single partial preference. The rest of this section will show one way of doing this.

## The sensible case

In the simplest case, we'd have a partial preference such as "these ten worlds are good, in this order", and we'd map them to a utility function with equal spaces between each world. And we wouldn't say these ten worlds were all better or all worse than the other worlds not mentioned.

And we can do that, in the most likely and sensible case. Take $P$ and its preorder $\leq$ (and $<$): under this partial preference, the worlds decompose into simple ordered chains. That means that if $\mathcal{W}$ is the set of worlds, then it decomposes as a disjoint union $\mathcal{W} = \bigcup_{i\in I} \mathcal{W}_i$ (for some indexing set $I$). These sets are incomparable: if $w_i \in \mathcal{W}_i$ and $w_j \in \mathcal{W}_j$, then neither $w_i \leq w_j$ nor $w_j \leq w_i$.

Moreover, each of these $\mathcal{W}_i$ is totally ordered by $<$: so we can index any $w_i \in \mathcal{W}_i$ by some natural number $k$, as $w_{ik}$, and say that $w_{ik} < w_{il}$ if and only if $k<l$. Let $n_i = ||\mathcal{W}_i||-1$ be the size of $\mathcal{W}_i$ minus one, and order the elements of it from $0$ upwards: so the set is ordered as $w_{i0} < w_{i1} < \ldots < w_{in_i}$.

Then here is how we construct a utility function $U$ that extends the partial order:

* For all $i\in I$, $k\in\mathbb{N}$, set $U(w_{ik})$ to $2k - n_i$.

This means that if $w$ is incomparable with all other worlds (ie, is not relevant to the partial preference), the $U(w)=0$, and that all chains $\mathcal{W}_i$ have utilities $U(w_{i0}) = -n_i$, $U(w_{i1})=-n_i +2$, $\ldots$, $U(w_{in_i})=n_i$. So they are symmetric around $0$.


## The general case

Here I'll give a way of generalising the above procedure to the case of any preorder. Note that this situation should only come up very rarely, since most preorders derived from mental models will be more sensible. Still, for completeness, here is a process that extends the simple model:

First, to get rid of circular preferences, project the set of worlds $\mathcal{W}$ to $\overline{\mathcal{W}}$, by using the equivalence relation $w \cong w'$ means $w \leq w'$ and $w'\leq w$. Call this projection $p$. The preorder on $\mathcal{W}$ descends via $p$ to a [partial order](https://en.wikipedia.org/wiki/Partially_ordered_set). So we now work in $\overline{\mathcal{W}}$, which has no circular preferences. Then if we assign a utility $U$ to $\overline{\mathcal{W}}$, we can extend this to $\mathcal{W}$ by setting $U(w)=U(p(w))$.

Now working in $\overline{\mathcal{W}}$, define a link between two (equivalence class of) worlds $w$ and $w'$. Write $w \leftarrow w$ to say that $w < w'$, and that there does not exist any world $v\in\overline{\mathcal{W}}$ with $w < v < w'$.

Now, decompose $\overline{\mathcal{W}}$ as collection of disjoint sets $\bigcup_{i\in I} \mathcal{W}_i$ (for some indexing set $I$). Two worlds $w$ and $w'$ are in the set $\mathcal{W}_i$ if you can get from one to another following links; ie if there exists worlds $w_{ik}$ with $w=w_{i0}$ and $w'=w_{il}$ and for all $k$, either $w_{ik} \leftarrow w_{i(k+1)}$ or $w_{i(k+1)} \leftarrow w_{ik}$.

Let $n_i$ be the number of links in $\mathcal{W}_i$. We'll now assign utility to elements of $\mathcal{W}_i$, as a constrained optimisation process; in the following, all worlds are assumed to be in $\mathcal{W}_i$:

* **minimise** $g(U)=\sum_{w \leftarrow w'} (U(w')-U(w))^2$, subject to the constraints that:
1. if $w < w'$, then $U(w) \leq U(w')$.
2. $\sum_{w \leftarrow w'} U(w')-U(w) = 2n_i$,
3. $\sum_{w} U(w) = 0$.

As long as $U$ is not constant on $\mathcal{W}_i$, then conditions 2. and 3. just fix a scaling and a translation of $U$. Condition 1. means that condition 2. is equivalent to $\sum_{w \leftarrow w'} |U(w')-U(w)| = 2n_i$, since $U(w) \leq U(w')$ for all $w < w'$, which includes all $w \leftarrow w'$.

This is a [convex optimisation problem](https://en.wikipedia.org/wiki/Convex_optimization) in the values of the $U(w)$, since $g(U)$ is convex in these values. Note that it is not strictly convex, since translations leave it unchanged: $g(U) = g(U+c)$. Nevertheless, it can be seen[^rough] that this equation is strictly convex on the subspace defined by condition 3. Therefore there is a single solution to the minimisation problem above.

[^rough]: Very rough argument: choose some ordering for the worlds in $\mathcal{W}_i$, write $x_i$ for $U(w_i)$, and set $\overline{x}=(x_0,\ldots x_m)$. Then, since $g$ is a quadratic with only quadratic terms, we can write it as its own Hessian: $g(\overline{x})= \overline{x}^T \frac{H(g)}{2} \overline{x}$.

    Now assume that $\overline{x}^T \frac{H(g)}{2} \overline{x} = 0$, for $\overline{x}=(r_0,r_1,\ldots r_m)$. However, $g$ is the sum of non-negative terms, so this is only possible if all of the $\sum_{w \leftarrow w'} (U(w')-U(w))^2$ are zero. This is only possible if $U(w')=U(w)$ whenever $w \leftarrow w'$; thus, since $\mathcal{W}_i$ is connected by links, $U$ must be constant on $\mathcal{W}_i$. In other words, only $\overline{x}=(r,r,\ldots r)$ allows $\overline{x}^T \frac{H(g)}{2} \overline{x} = 0$.

    Thus $H(g)$ has only one zero eigenvector, corresponding to translations. Since condition 3. precludes additional translations, $H(g)$ is strictly positive definite on the subspace it defines. Hence $g$ is strictly convex on this space.

## Extending the sensible case

It's not hard to see that this extends the sensible model above, which has $U(w')-U(w)=2$ for all $w \leftarrow w'$ (a little more work is required to show that having all those values equal minimises the sum $\sum_{w \leftarrow w'} (U(w')-U(w))^2$).

# The final version of partial preferences

Is this the final version of partial preferences? No, certainly not. But to get a better generalisation, we're going to have to have a look at how people actually model things inside their brains and thought processes. Hence the question of how best to model partial models will be an empirical one. But this very general definition will suffice for the moment.