2 minute read

The main question is, how do we define two programs are equal, and how do we prove it.

So for setup we have type int, and k which is a int, and e1+e2.

Observational EquavalencePermalink

We say that 2 programs are equal iff you can’t tell them apart, which means:

  • For 2 closed programs of type int, ee iff k such that ek,ek. This is called Kleeve equivalence.
  • For e,e:τ,e=τobse iff o:τP:int,P[e]P[e], were P is a program context, defined as an expression: o:τP:int, where o can said as a “hole”, and P[e] means [e/o]P. For example, in 2+(o+1), o is type int; in 2+(o7+1), o is type intint. To rephrase the rule, it means that two programs are equal if we plug them in a larger program P, 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: eτe is consistent iff einte implies ee. In other words, it means it implies at int.

Congruence: if eτ1e, then C[e]τ2C[e] for any context, where context is o:τ1C:τ2.

Coarsest: if eτe by any consistent congruence, then e=τobse

Proof:

  • Consistent

We want to show if e=intobse,then ee, which is obvious by the definition of =obs, just take P to be o itself. (identity)

  • Congruence

We want to show if e=τ1obsethen C[e]=τ2obsC[e]. e=τ1obse means Po:τ1,P[e]P[e]. C[e]=τ2obsC[e] means Po:τ2,P[C[e]]P[C[e]]. We take P to be P[C/o], so P[e] is just P[C[e]] (composition)

  • Coarsest

By congruence, we have P[e]P[e].

By consistency, we have P[e]P[e]. 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 =log to do that, so that we have a rule:

e=τobse iff eτloge

Logical EquivalencePermalink

It is equivalence defined by logical relations.

  • e=intloge iff ee
  • e=τ1τ2loge iff e1,e1:τ1,if e1=τ1loge1,then ee1=τ2logee1

Thm:

e:τ implies e=intobse

Proof e=τobse iff eτloge:

From left to right should be easier because we are coming from to int and τ1τ2, 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: o:τ1C:τ2,if e=τ1loge,then C[e]=τ2logC[e]. We need a generalized version of Thm(v3) from here:

Foundamental Theorm of Logical RelationsPermalink

If Γe:τ,and γ=Γlogγ,then γ^(e)=τlogγ^(e)

Closure under Converse EvalutaionPermalink

Lemma:

If ee0,e0=τloge,then e=τloge

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 ;)

Relationship to Hereditary TerminationPermalink

e=τobse iff HTτ(e)

Comments