Start working on part 3

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-06-27 22:26:01 -07:00
parent 0b97eb85a1
commit 826a16eb66
3 changed files with 84 additions and 0 deletions

View File

@ -323,6 +323,8 @@ following are the updated Cayley tables for our operations.
\bot & \bot & \bot & \bot & \bot & \bot \\ \bot & \bot & \bot & \bot & \bot & \bot \\
\end{array} \end{array}
{{< /latex >}} {{< /latex >}}
{#sign-lattice}
So, it turns out that our set of possible signs is a semilattice in two So, it turns out that our set of possible signs is a semilattice in two
ways. And if "semi" means "half", does two "semi"s make a whole? Indeed it does! ways. And if "semi" means "half", does two "semi"s make a whole? Indeed it does!

View File

@ -425,6 +425,7 @@ we can create the infinite chain:
On the other hand, our sign lattice _is_ of finite height; the longest chains On the other hand, our sign lattice _is_ of finite height; the longest chains
we can make have three elements and two `<` signs. Here's one: we can make have three elements and two `<` signs. Here's one:
{#sign-length-three}
{{< latex >}} {{< latex >}}
\bot < + < \top \bot < + < \top

View File

@ -0,0 +1,81 @@
---
title: "Implementing and Verifying \"Static Program Analysis\" in Agda, Part 3: Lattices of Finite Height"
series: "Static Program Analysis in Agda"
description: "In this post, I describe the class of finite-height lattices, and prove that lattices we've alread seen are in that class"
date: 2024-05-30T19:37:01-07:00
draft: true
tags: ["Agda", "Programming Languages"]
---
In the previous post, I introduced the class of finite-height lattices:
lattices where chains made from elements and the less-than operator `<`
can only be so long. As a first example,
[natural numbers form a lattice]({{< relref "01_spa_agda_lattices#natural-numbers" >}}),
but they __are not a finite-height lattice__; the following chain can be made
infinitely long:
{{< latex >}}
0 < 1 < 2 < ...
{{< /latex >}}
There isn't a "biggest natural number"! On the other hand, we've seen that our
[sign lattice]({{< relref "01_spa_agda_lattices#sign-lattice" >}}) has a finite
height; the longest chain we can make is three elements long; I showed one
such chain (there are many chains of length three) in
[the previous post]({{< relref "02_spa_agda_combining_lattices#sign-length-three" >}}),
but here it is again:
{{< latex >}}
\bot < + < \top
{{< /latex >}}
It's also true that the [Cartesian product lattice \(L_1 \times L_2\)]({{< relref "02_spa_agda_combining_lattices#the-cartesian-product-lattice" >}})
has a finite height, as long as \(L_1\) and \(L_2\) are themselves finite-height
lattices. In the specific case where both \(L_1\) and \(L_2\) are the sign
lattice (\(L_1 = L_2 = \text{Sign} \)) we can observe that the longest
chains have five elements. The following is one example:
{{< latex >}}
(\bot, \bot) < (\bot, +) < (\bot, \top) < (+, \top) < (\top, \top)
{{< /latex >}}
The fact that \(L_1\) and \(L_2\) are themselves finite-height lattices is
important; if either one of them is not, we can easily construct an infinite
chain of the products. If we allowed \(L_2\) to be natural numbers, we'd
end up with infinite chains like this one:
{{< latex >}}
(\bot, 0) < (\bot, 1) < (\bot, 2) < ...
{{< /latex >}}
Another lattice that has a finite height under certain conditions is
[the map lattice]({{< relref "02_spa_agda_combining_lattices#the-map-lattice" >}}).
The "under certain conditions" part is important; we can easily construct
an infinite chain of map lattice elements in general:
{{< latex >}}
\{ a : 1 \} < \{ a : 1, b : 1 \} < \{ a: 1, b: 1, c: 1 \} < ...
{{< /latex >}}
As long as we have infinite keys to choose from, we can always keep
adding new keys to make bigger and bigger maps. But if we fix the keys in
the map -- say, we use only `a` and `b` -- then suddenly our heights are once
again fixed. In fact, for the two keys I just picked, one longest chain
is remarkably similar to the product chain above.
{{< latex >}}
\{a: \bot, a: \bot\} < \{a: \bot, b: +\} < \{a: \bot, b: \top\} < \{a: +, b: \top\} < \{a: \top, b: \top\}
{{< /latex >}}
The class of finite-height lattices is important for static program analysis,
because it ensures that out our analyses don't take infinite time. Though
there's an intuitive connection ("finite lattices mean finite execution"),
the details of why the former is needed for the latter are nuanced. We'll
talk about them in a subsequent post.
In the meantime, let's dig deeper into the notion of finite height, and
the Agda proofs of the properties I've introduced thus far.
{{< todo >}}
The rest of this.
{{< /todo >}}