Equational Reasoning
The main question is, how do we define two programs are equal, and how do we prove it.
So for setup we have type , and which is a , and .
Observational EquavalencePermalink
We say that 2 programs are equal you can’t tell them apart, which means:
- For 2 closed programs of type , such that . This is called Kleeve equivalence.
- For , were is a program context, defined as an expression: , where can said as a “hole”, and means . For example, in , is type ; in , is type . To rephrase the rule, it means that two programs are equal if we plug them in a larger program , we get the same result. This is called observational equivalence.
Observational equivalence is characterized by a universal property:
- Observatinoal equivalence is the coarsest consistent congruence.
Consistent: is consistent implies . In other words, it means it implies at .
Congruence: if , then for any context, where context is .
Coarsest: if by any consistent congruence, then
Proof:
- Consistent
We want to show , which is obvious by the definition of , just take to be itself. (identity)
- Congruence
We want to show . means . means . We take to be , so is just (composition)
- Coarsest
By congruence, we have .
By consistency, we have . So we are done.
So we proved the properties of observational equivalence, by how do we prove observational equivalence itself in the first place? Afterall, we need to show the rule holds for all contexts. The idea is to cutdown contexts that you need to consider using types. We need to introduce a new notion below to do that, so that we have a rule:
Logical EquivalencePermalink
It is equivalence defined by logical relations.
Thm:
Proof :
From left to right should be easier because we are coming from to and , so we are not gonna do it here.
From right to left:
Because observational equivalence is the coarsest consistent congruence, so we only need to show logical equivalence is a consistent congruence. Consistency comes for free, so we only need congruence.
We want to proof: . We need a generalized version of from here:
Foundamental Theorm of Logical RelationsPermalink
Closure under Converse EvalutaionPermalink
Lemma:
where is the transition in dynamics from here.
Then we can proof it by the above therom and lemma, we will just skip it here ;)
Comments