Strong behavior refinement #
Terminating, Diverging, Aborting and Blocking are the four shapes a behavior refinement
takes, one per way a target run can end. StrongRefinement bundles all four for a single pass;
the Comp, Trans, Mono, star and sequential lemmas are their algebra.
Each definition is a commuting square, drawn in its doc comment:
- top edge — the pre-relation
Rbetween a source configurationσₛand a targetσₜ; - verticals — one step of each semantics, right-labelled by the trace it emits (
ε'source,εtarget); the left label names the source semantics taken,sem_sthe one being matched (reducing, diverging or blocking) andsem_s'the aborting one; - bottom row — where each side lands:
σₛ'/σₜ'a configuration,↯an abort,∞a divergence,∅a stuck configuration.@.is no edge.
The source trace is existentially quantified and only ever related to the target's — by Rτ on a
matched step, by ≼[Rτ] (a sequentially consistent prefix, not a syntactic one; \preceq in the
squares) on an abort — never shared. In each square the top and right edges are the hypothesis and
the bottom and left are what the definition supplies; amscd draws every edge solid, so that
split is not visible.
Behavior refinement for a target run that terminates.
From R σₛ σₜ and a semₜ step (σₜ, ε, σₜ'), the source either takes a matching semₛ step
to some σₛ' with S σₛ' σₜ' and Rτ ε' ε, or aborts via semₛ' on a trace with
ε' ≼[Rτ] ε. S is the post-relation, usually R again.
$$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s}V{\varepsilon'}V @V{\mathit{sem}_t}V{\varepsilon}V \\ \sigma_s' @>S>> \sigma_t' \end{CD} $$ or $$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s'}V{\varepsilon' \preceq \varepsilon}V @V{\mathit{sem}_t}V{\varepsilon}V \\ \unicode{x21AF} @. \sigma_t' \end{CD} $$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Vertical composition: a Terminating refinement of semₛ ∘ᵣ₂ semᵤ against semₜ ∘ᵣ₂ semᵥ,
from one refinement of each factor sharing the middle relation S. Trace relation stays Rτ;
the composite aborting set is semₛ' ∪ semₛ ∘ᵣ₁ semᵤ'.
Monotone in the state sets: widen either source set, shrink the target set.
Both reducing sets cut to the runs whose final state satisfies a predicate. hback carries
the target predicate back across R; without it, restricting the source set would not be
monotone. Turns a reachability relation into a terminating semantics on both sides at once.
A target with no reducing behavior is refined by anything: the empty target set vacates the premise, so the pre- and post-relations and both source sets are unconstrained.
Doing nothing refines doing nothing: Relation.Idle on the source refines Relation.Idle
on the target, at any aborting set.
⋃₀ on all three sets: every target reducing set in B is refined by some source reducing
set in A and some source aborting set in C.
Binary union on the reducing sets, aborting set shared and summands paired positionally.
The two-element case of Terminating.sup.
Terminating refinement for Relation.star: from a step-level refinement that answers one
target step with a source Relation.star semₛ run, a refinement of Relation.star semₜ with
aborting set Relation.star semₛ ∘ᵣ₁ Yₛ. The operator-preservation law standing in for induction
over Algebra.reducing's least fixed point.
The hypothesis answers a target step with a source run, not a source step, so a pass whose
target has steps with no source counterpart still fits it by instantiating semₛ at a star;
Terminating.starStutter packages that instantiation.
Terminating.star with the source instantiated at Relation.star stepₛ and the resulting
doubled star collapsed, so a target step is answered by a source run — possibly empty — and the
conclusion still reads at Relation.star stepₛ.
Behavior refinement for a target run that diverges.
From R σₛ σₜ and a diverging semₜ run (σₜ, ε), the source either diverges too via semₛ
with Rτ ε' ε, or aborts via semₛ' with ε' ≼[Rτ] ε.
$$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s}V{\varepsilon'}V @V{\mathit{sem}_t}V{\varepsilon}V \\ \infty @. \infty \end{CD} $$ or $$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s'}V{\varepsilon' \preceq \varepsilon}V @V{\mathit{sem}_t}V{\varepsilon}V \\ \unicode{x21AF} @. \infty \end{CD} $$
Equations
Instances For
Vertical composition: a divergence of the first factor, or a terminating run of the first
then a divergence of the second, is a divergence of semₛ'' ∪ semₛ ∘ᵣ₁ semᵤ'' against
semₜ'' ∪ semₜ ∘ᵣ₁ semᵥ''. Aborting set semₛ' ∪ semₛ ∘ᵣ₁ semᵤ'.
Monotone: widen either source set, shrink the target diverging set.
Divergence refinement for Relation.omega, standing in for coinduction. From a step-level
Terminating refinement, a refinement of Relation.omega semₜ: the source either keeps pace
with the target forever, its trace the infinite product related by Rτ_omega, or aborts at the
first index it cannot. The aborting set is fixed to the closed form Relation.star semₛ ∘ᵣ₁ Yₛ,
so its absorption law holds by Relation.star.lcomp₁_absorb rather than as a hypothesis.
Divergence refinement for a stuttering source, where instantiating semₛ at a star is not
available (Relation.omega (Relation.star stepₛ) ≤ Relation.omega stepₛ is false). The
hypothesis is a stuttering simulation: per target step the source takes one step, or none while
a well-founded measure μ on target configurations strictly drops, or aborts. The idle branch
requires the target trace to be 1 there — a step the source does not answer must be
unobservable.
Divergence refinement for Relation.star semₛ ∘ᵣ₁ Yₛ: finitely many steps, then a
divergence. With Diverging.omega it covers the general closed form — gfp (λ x, Y ∪ X ∘ᵣ₁ x)
denotes (X* ∘ᵣ₁ Y) ∪ X^∞, and omega alone would force Y = ∅.
Binary union on the diverging sets, aborting set shared.
The closed form in one piece: gfp (λ x, Y ∪ X ∘ᵣ₁ x) denotes (X* ∘ᵣ₁ Y) ∪ X^∞, and this
refines it as such. Diverging.omega is the Y = ∅ special case.
Behavior refinement for a target run that aborts.
From R σₛ σₜ and an aborting semₜ' run (σₜ, ε), the source aborts too via semₛ' with
ε' ≼[Rτ] ε. No bottom edge — an abort has no "after".
$$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s'}V{\varepsilon' \preceq \varepsilon}V @V{\mathit{sem}_t'}V{\varepsilon}V \\ \unicode{x21AF} @. \unicode{x21AF} \end{CD} $$
Equations
Instances For
An abort is a divergence that always takes the aborting branch; the reducing set is
unconstrained. hle places the witness in whichever aborting set the diverging statement carries.
The converse of Aborting.toDiverging when the two source sets coincide: the matched branch
weakens into the aborting one, so the disjunction collapses.
Horizontal composition through an intermediate language with trace type εₘ. The first leg's
trace relation must be left-total and closed (bundled as T₁); the second leg's needs nothing.
Horizontal composition through an intermediate language, Terminating.Trans for divergence:
only the first leg's trace relation needs laws (bundled as T₁).
Vertical composition: an abort of the first factor, or a terminating run of the first then an
abort of the second, is an abort of semₛ' ∪ semₛ ∘ᵣ₁ semᵤ' against semₜ' ∪ semₜ ∘ᵣ₁ semᵥ'.
Horizontal composition through an intermediate language, Terminating.Trans for aborts.
Monotone: widen the source aborting set, shrink the target aborting set.
⋃₀ on both sets: every target aborting set in B is refined by some source aborting set
in A.
Binary union on both aborting sets, summands paired positionally. The two-element case of
Aborting.sup.
Aborting refinement for Relation.star semₛ ∘ᵣ₁ Yₛ: finitely many steps, then an abort —
the shape of Algebra.aborting (step* ∘ᵣ₁ immediate). The operator-preservation law standing
in for induction over its least fixed point.
The step-level hypothesis names Relation.star semₛ ∘ᵣ₁ Yₛ as its aborting set — the
conclusion's own left-hand side. Not circular: its absorption law holds by
Relation.star.lcomp₁_absorb, so it is not an added assumption.
Aborting.star with the source instantiated at Relation.star stepₛ and the doubled star
collapsed, so a target step is answered by a source run and the conclusion still reads at
Relation.star stepₛ ∘ᵣ₁ Yₛ.
Behavior refinement for a target run that blocks: a finite run ending in a configuration that is stuck — nothing steps, nothing aborts — and is not terminal.
From R σₛ σₜ and a blocking semₜ_blk run (σₜ, ε), the source either blocks too via
semₛ_blk with Rτ ε' ε, or aborts via semₛ_abt with ε' ≼[Rτ] ε. ∅ marks the stuck
configuration; no bottom edge.
$$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s}V{\varepsilon'}V @V{\mathit{sem}_t}V{\varepsilon}V \\ \emptyset @. \emptyset \end{CD} $$ or $$ \begin{CD} \sigma_s @>R>> \sigma_t \\ @V{\mathit{sem}_s'}V{\varepsilon' \preceq \varepsilon}V @V{\mathit{sem}_t}V{\varepsilon}V \\ \unicode{x21AF} @. \emptyset \end{CD} $$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Vertical composition: a blocking run of the second factor after a terminating run of the
first is a blocking run of the sequence, with the aborting sets as shared fallback. Same
conclusion shape as Diverging.Comp.
Horizontal composition through an intermediate language: a blocking run of the composite pass is matched by a blocking run of the first leg, with an abort of the middle language as fallback.
Monotone: widen either source set or shrink the target blocking set.
An empty target blocking set is refined by anything.
Binary union on the blocking sets, aborting set shared.
Blocking refinement distributes over an arbitrary union of target blocking sets: each target summand is matched by a source blocking set and a source aborting set of its own.
Blocking refinement for Relation.star semₛ ∘ᵣ₁ Yₛ: finitely many steps, then a block — the
shape of an algorithm's blocking semantics (step* ∘ᵣ₁ immediateBlock). Operator-preservation
standing in for induction over its least fixed point; same conclusion shape as Diverging.star.
Blocking.star with the source instantiated at Relation.star stepₛ and the doubled star
collapsed, so a target step is answered by a source run and the conclusion still reads at
Relation.star stepₛ ∘ᵣ₁ Yₛ.
All four behavior refinements for one pass, sharing the pre-relation R and trace relation Rτ.
The aborting sets semₛ₂/semₜ₂ are the fallback for the terminating, diverging and
blocking components alike; semₛ₁/semₜ₁ reduce, semₛ₃/semₜ₃ diverge, semₛ₄/semₜ₄
block.
- terminating : StrongRefinement.Terminating R R Rτ semₛ₁ semₛ₂ semₜ₁
- aborting : StrongRefinement.Aborting R Rτ semₛ₂ semₜ₂
- diverging : StrongRefinement.Diverging R Rτ semₛ₃ semₛ₂ semₜ₃
- blocking : StrongRefinement.Blocking R Rτ semₛ₄ semₛ₂ semₜ₄
Instances For
Vertical composition of two full refinements, staying at the trace relation Rτ. Composing a
chain stays at Rτ however long the chain.
A full refinement from just the terminating and aborting components, with the target diverging and blocking sets empty.
A full refinement from just the terminating component, with every other target set empty.
Horizontal composition of two full refinements through an intermediate language. T₁ bundles
the first leg's trace relation and its laws. No union in the conclusion, unlike Comp: every run
passes through the middle language.
Monotone in all eight state sets: widen the four source sets, shrink the four target sets.
Assembles per-step refinements into a full StrongRefinement at the shapes a step-and-iterate
semantics takes: step*, step* ∘ᵣ₁ immediate, (step* ∘ᵣ₁ Y) ∪ step^∞,
step* ∘ᵣ₁ blocking. Standing in for induction over Algebra's fixed points.
Four hypotheses, each about one step: a Terminating for the step, and Aborting/Diverging/
Blocking for the sets a step can abort, diverge or block into. Yₛ/Yₜ are the
immediate-divergence sets — general because whether a step can diverge is a property of the
semantics, not this framework. sequentialOmega is the Y = ∅ case that Algebra uses.
sequential at Y = ∅, so the diverging component is just step^∞. The algorithm layer's
case — an atomic block has no diverging semantics — where the conclusion is then definitionally
Algebra.reducing/.aborting/.diverging, applied without rewriting.