Skip to content

Conversation

@VietAnh1010
Copy link
Collaborator

Extend the language and the logical relations with shift/reset. Here are some notable observations:

  • To accommodate shift/reset, we introduce meta-context (which plays the role of meta-continuation). Logical relations are extended to include meta-contexts. There are two isomorphic representations of meta-contexts: inside-out and outside-in (just like normal contexts).
  • Working with inside-out representations of meta-contexts and contexts is easier when reasoning about small-step execution (inside-out representations mirror exactly the structure of continuations and meta-continuations). For example, to evaluate reset, we cons the current inside-out context to the front of the current inside-out meta-context, and we set the inside-out context to hole. If we work with outside-in representations instead, we need to append the current outside-in context to the back of the current outside-in meta-context, which complicates reasoning.
  • Working with outside-in representations of meta-contexts and contexts is easier when reasoning about unique decomposition, as their plug function are structurally recursive without accumulator.
  • Proof of unique decomposition is now mostly by equational reasoning. This is achieved by explicitly writing the decomposing function and reasoning with it.
  • fmap and bind of outside-in program contexts are corrected, which allows us to write ctxr_comp that composes two program contexts and simplifies reasoning.

VietAnh1010 and others added 12 commits November 27, 2025 18:28
The reason for this "cheat" is that, in the proof of completeness, given
any arbitrary V, we may not be able to construct ctxr V \empty to instantiate
the hypothesis. We need the two "cheating" constructor to get around this
issue.
The main change is to add meta-context, and update the logrels to
accommodate the addition of meta-context.
The main insight is that: the proof of unique decomposition basically
contains an algorithm to "construct" the unique decomposition:

forall e, (exists v, e = v) \/ (exists! M R e', e = meta_rplug M (rplug R e'))

Notice the quantifier `exists`. In Rocq, we prove `exists` by giving the witness,
and we can only give the witness if we can construct it.

Therefore, a better idea is to extract the decomposition as a separate function,
which is much easier to study; and is useful to state our other lemmas as well.

After obtaining the decomposition function, we prove unique decomposition by
"delegating" to this decomposing function. We just need to prove that, given
a redex, an evaluation context and a meta context, plugging them and decomposing
them is identity. The prove is by pure equational reasoning (!) and it much easier
to understand.
@VietAnh1010 VietAnh1010 marked this pull request as ready for review December 9, 2025 07:50
@VietAnh1010 VietAnh1010 merged commit f5ebdb7 into ctx-equiv Dec 10, 2025
1 check failed
@VietAnh1010 VietAnh1010 deleted the ctx-equiv-Shift-reset branch December 10, 2025 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants