Lectures onType Theory
Chapter 44
Chapter 44Optional

Separation Logic and Local Reasoning

Prerequisites. Direct starred prerequisites: Chapter 43. No later core chapter depends on this route.

A command that changes one heap cell should not have to re-establish a description of every other cell. Yet two variables can contain the same address. Knowing that each variable names a cell containing 1 does not show that there are two independently owned cells: both descriptions may name the same cell. What property of the heap distinguishes the two-cell state from this aliased one, and what condition ensures that a command changing one cell leaves the other cell untouched?

The heap split forced by aliasing

Let locations be natural numbers. Values are integers, locations, and the distinguished value null. Fix a countably infinite set V of program variables. Each program, assertion, and derivation uses only finitely many of them, so every finite avoidance set admits a fresh auxiliary. A store σ:VVal is total. Every expression, assertion, and command is well scoped over V, and every assignment target lies in V. A heap h is a finite partial map from non-null locations to values. Thus expression evaluation never fails; the load, store, and free commands are the only rules whose premises can fail because a heap address is absent.

Definition 44.1 — Disjoint heaps

Write h1#h2 when their domains are disjoint: dom(h1)dom(h2)=. When this holds, h1h2 is their union. The empty heap is . A subheap h0h is a restriction of h. Its complement r, determined by h=h0r, is unique.

Lemma 44.2 — Finite-heap algebra

Whenever the displayed unions are defined, h=h,h1h2=h2h1,(h1h2)h3=h1(h2h3). If h=h1h2=h1h2, the two splittings need not agree. They do agree when either component is fixed as a subheap of h.

Proof of Lemma 44.2 — Finite-heap algebra

Proof. The first three claims are the unit, commutativity, and associativity laws for disjoint finite-map union. For the last clause, a complement contains exactly the locations of h that are absent from h0, and it agrees with h at every such location. Hence two complements are the same finite map. For nonuniqueness, let h={1a,2b}. The ordered witnesses ({1a},{2b}) and (h,) give different splittings of the same heap. The difference is not merely the commutativity of : their first components have different domains. ◻

Ordinary conjunction observes one heap twice. A separating conjunction divides the heap into disjoint subheaps and checks one conjunct on each part.

Definition 44.3 — Heap assertions

A heap assertion is a formula generated by P,Q::=truefalseE=FEFempEFPQPQPQPQx.P. They denote sets of store–heap pairs. Write σ,hP for membership in that denotation, and [[E]]σ for the value of the expression E in the store σ. Here PQ is the separating conjunction introduced above, and PQ is separating implication, the assertion that every disjoint extension satisfying P produces a combined heap satisfying Q. These connectives print like the BI connectives of chapter 43, but their operands are heap assertions. The finite-heap algebra uses exact disjoint union rather than a preordered resource witness; the separate macros record that specialization. The clauses that mention the heap are below. In the points-to clause, put =[[E]]σ and v=[[F]]σ. σ,htruealways,σ,hfalsenever,σ,hE=F[[E]]σ=[[F]]σ,σ,hEF[[E]]σ[[F]]σ,σ,hemph=,σ,hEF is a non-null location  h={v},σ,hPQh1,h2. h=h1h2 σ,h1P  σ,h2Q,σ,hPQσ,hP  σ,hQ,σ,hPQσ,hP  σ,hQ,σ,hPQr.(h#r  σ,rPσ,hrQ),σ,hx.PvVal. σ[xv],hP. Here expressions are variables or literal values. The assertion E abbreviates z.Ez, where zVfv(E). Free variables satisfy fv(emp)=,fv(E=F)=fv(E)fv(F),fv(EF)=fv(E)fv(F),fv(PQ)=fv(P)fv(Q),fv(x.P)=fv(P){x},fv(E)=fv(E), where {,,,}.

Proposition 44.4 — Separating algebra

For all assertions P,Q,R, Pemp⊣⊢P,PQ⊣⊢QP,(PQ)R⊣⊢P(QR). If S is pure—its truth depends only on the store—then (PQ)S⊣⊢(PS)Q⊣⊢P(QS).

Proof of Proposition 44.4 — Separating algebra

Proof. For the unit, the emp component is , so its complement is the original heap. Commutativity and associativity transport the witnessing heap split along the corresponding laws of lemma 44.2. For the last display, suppose h=h1h2. Because S ignores the heap, σ,hS, σ,h1S, and σ,h2S are equivalent. The same split therefore moves the pure conjunct to either component; the converse uses the identical argument. ◻

The singleton in the points-to clause is essential. Thus x1y2 entails xy, while (x1)(y2) is false even when xy: one heap cannot be two different singletons.

Proposition 44.5 — The separating adjunction

For all assertions P,Q,R, PQRPQR. Entailment means inclusion of assertion denotations.

Proof of Proposition 44.5 — The separating adjunction

Proof. Suppose PQR, and let σ,hP. For any r disjoint from h with σ,rQ, the union hr satisfies PQ, hence R. Therefore σ,hQR.

Conversely, suppose PQR and σ,hPQ. Choose h=h1h2 with P on h1 and Q on h2. The premise gives QR on h1; applying its definition to h2 gives R on h. ◻

Exercise 44.1

★☆☆ Prove directly from the heap semantics that P(QR)⊣⊢(PQ)(PR)andPfalse⊣⊢false. Record the chosen heap splitting in each nonvacuous direction.

Exercise 44.2

★☆☆ Show that x=y(x1y2)false. Then give a store and heap satisfying x=yx1y1. Explain which assertion expresses ownership of one cell.

A command language that can fault

The frame theorem needs an operational claim about commands, not only an algebra of assertions.

Definition 44.6 — Command semantics

Expressions E,F are variables or literal values. The following grammar therefore keeps expression evaluation separate from the heap operations: c::=skipx:=Ex:=[E][E]:=Fx:=alloc(E)free(E)c1;c2if E=F then c1 else c2. The big-step judgment c,σ,hσ,h is generated by the following rules. Store update is written σ[xv], and heap update by h[v].

skip,σ,hσ,h
E-Skip
v=[[E]]σ
x:=E,σ,hσ[xv],h
E-Assign
=[[E]]σh()=v
x:=[E],σ,hσ[xv],h
E-Load
=[[E]]σdom(h)v=[[F]]σ
[E]:=F,σ,hσ,h[v]
E-Store
v=[[E]]σdom(h)null
x:=alloc(E),σ,hσ[x],h{v}
E-Alloc
=[[E]]σdom(h)
free(E),σ,hσ,h(dom(h){})
E-Free
c1,σ,hσ1,h1c2,σ1,h1σ2,h2
c1;c2,σ,hσ2,h2
E-Seq
[[E]]σ=[[F]]σc1,σ,hσ,h
if E=F then c1 else c2,σ,hσ,h
E-IfT
[[E]]σ[[F]]σc2,σ,hσ,h
if E=F then c1 else c2,σ,hσ,h
E-IfF

Allocation is nondeterministic only in the fresh location chosen.

Absence of a big-step derivation could mean either a fault or divergence in a larger language. This language has no loops, so we define safety directly and do not rely on that coincidence.

Definition 44.7 — Safety and modified variables

Safety is defined by structural recursion on commands:

  • skip, assignment, and allocation are safe;

  • load, store, and free are safe exactly when their evaluated address is in the heap domain;

  • c1;c2 is safe when c1 is safe and c2 is safe after every result of c1;

  • a conditional is safe when its selected branch is safe.

The finite set mod(c) contains variables assigned by c, including load and allocation targets, and is combined by union for compound commands. The set vars(c) contains every variable occurring anywhere in c, including assignment targets: vars(skip)=,vars(x:=E)={x}fv(E),vars(x:=[E])={x}fv(E),vars(x:=alloc(E))={x}fv(E),vars([E]:=F)=fv(E,F),vars(free(E))=fv(E),vars(c1;c2)=vars(c1)vars(c2),vars(if E=F then c1 else c2)=fv(E,F)vars(c1)vars(c2).

The program free(x);y:=[x] is unsafe on every heap satisfying xv. The first command removes the only cell; the address premise of the second is then false. This is a formal use-after-free, not a claim about how a particular machine manifests the error.

Lemma 44.8 — Commands change only modified variables

If c,σ,hσ,h and xmod(c), then σ(x)=σ(x). Consequently, if an assertion R has fv(R)mod(c)=, then σ,rR iff σ,rR for every heap r.

Proof of Lemma 44.8 — Commands change only modified variables

Proof. Induct on the execution derivation. The primitive cases inspect the one possible store update. Sequence uses the induction hypothesis twice and the definition of mod(c1;c2). A conditional uses the induction hypothesis for the selected branch. The assertion consequence is an induction on the assertion syntax; points-to and pure atoms evaluate the same expressions because none of their free variables changed. Separating connectives preserve the same heap splits. ◻

Lemma 44.9 — Fresh-variable coincidence

Let avars(c), and let stores σ,ρ agree on every variable other than a. Then:

  1. c is safe on (σ,h) iff it is safe on (ρ,h);

  2. every execution c,σ,hσ,h has a matching execution c,ρ,hρ,h, and the result stores agree away from a, with the converse correspondence as well; and

  3. if afv(P), then σ,hP iff ρ,hP.

Proof of Lemma 44.9 — Fresh-variable coincidence

Proof. Prove the first two clauses simultaneously by structural induction on c. Every expression in a primitive command has the same value in the two stores. A store update has the same target and value, and its target is not a. The heap operations therefore have identical domain tests and heap results. In the allocation case choose the same fresh location in the matching execution. Sequence composes the two correspondences at the intermediate state, and a conditional selects the same branch. The safety clauses follow from the identical address tests and the induction hypotheses.

For the third clause, induct on P. Pure atoms and points-to inspect only their free variables; the propositional and separating connectives preserve the same truth values and heap splits. For x.P, alpha-rename x away from a and use the same witness in both stores. ◻

Locality and the frame theorem

Locality is the requirement that adjoining a disjoint frame neither creates a fault nor permits that frame to be modified invisibly.

The tempting forward factorization is false for allocation: x:=alloc(E),σ,h0σ[x],h0{v}⟹̸x:=alloc(E),σ,h0rσ[x],h0r{v}. Choose dom(r)dom(h0). The small allocation may choose , but the proposed large result is not a heap because the union is not disjoint. The repair reads a given large execution back to the footprint, so its chosen location is already fresh for the frame.

Definition 44.10 — Local command

A command c is a local command when, for all h0#r:

  1. if c is safe on (σ,h0), then it is safe on (σ,h0r);

  2. if c is safe on (σ,h0) and c,σ,h0rσ,H, then there is an h0 such that H=h0r and c,σ,h0σ,h0.

The second clause reads an execution on the large heap back to its footprint; this orientation handles allocation without quotienting locations.

Proof of Theorem 44.11 — Locality of the command language

Proof. Proceed by structural induction on c, proving both clauses together. Skip and assignment do not change the heap. For load, store, and free, safety on h0 says that the addressed location belongs to dom(h0); disjointness ensures it does not belong to r. The large execution therefore reads, changes, or removes exactly the same cell of h0, and finite-map algebra factors the result as the changed footprint united with r.

For allocation, safety is automatic. Suppose the large execution chooses dom(h0r). Then is fresh for both components. The small execution may choose the same , and (h0r){v}=(h0{v})r.

For a sequence, safety of c1;c2 entails safety of c1 and safety of c2 after every small result of c1. Apply the induction hypothesis for c1 to factor the intermediate large result as h1r. Its corresponding small result is one quantified over in the safety clause, so the induction hypothesis for c2 applies and factors the final result. The conditional selects the same branch on both heaps because its expressions depend only on the store; apply the induction hypothesis to that branch. ◻

Definition 44.12 — Semantic Hoare triple

The assertion {P}c{Q} is a semantic Hoare triple when the following conditions hold. For every σ,h satisfying P, the command c is safe on (σ,h). Every result c,σ,hσ,h satisfies σ,hQ. This is partial correctness plus fault freedom. It makes no termination claim for a language containing loops or recursion.

Theorem 44.13 — Frame rule

If {P}c{Q} is valid, c is local, and mod(c)fv(R)=, then {PR}c{QR} is valid.

Proof of Theorem 44.13 — Frame rule

Proof. Let σ,hPR. Choose h=h0r with σ,h0P and σ,rR. Validity of {P}c{Q} gives safety on (σ,h0); locality then gives safety on (σ,h).

For any large result σ,H, locality gives a small result σ,h0 with H=h0r. The premise triple gives σ,h0Q. By lemma 44.8, σ,rR, since variables free in R were not modified. The displayed split therefore witnesses σ,HQR. ◻

The side condition is not decorative. From {true}x:=0{x=0} one may not frame x=1: the command changes the store fact even though it changes no heap cell.

Exercise 44.3

★☆☆ Use a one-variable store to show that deleting the free-variable side condition from theorem 44.13 derives an invalid triple. Identify the exact line of the proof that then fails.

A small-footprint proof system

The following rules mention only the cells touched by a primitive.

Lemma 44.14 — Assertion substitution

Capture-avoiding assertion substitution satisfies σ,hP[E/x]σ[x[[E]]σ],hP.

Proof of Lemma 44.14 — Assertion substitution

Proof. Induct on P. Equality, disequality, and points-to use the ordinary expression-substitution calculation; the heap is unchanged. Boolean and separating connectives apply the induction hypotheses to the same heap or to each component of the same split. For y.P, alpha-rename y away from x and fv(E), then use the same witness on both sides. These cases exhaust definition 44.3. ◻

Definition 44.15 — Hoare rules

The proof judgment {P}c{Q} is generated by

{P}skip{P}
H-Skip
{P[E/x]}x:=E{P}
H-Assign
{P}c1{R}{R}c2{Q}
{P}c1;c2{Q}
H-Seq
PP{P}c{Q}QQ
{P}c{Q}
H-Conseq
{P}c{Q}avars(c)fv(Q)
{a.P}c{Q}
H-Exists
xfv(E,F)
{EF}x:=[E]{EFx=F}
H-Load
{E}[E]:=F{EF}
H-Store
xfv(F)
{emp}x:=alloc(F){xF}
H-Alloc
{E}free(E){emp}
H-Free
{PE=F}c1{Q}{PEF}c2{Q}
{P}if E=F then c1 else c2{Q}
H-If
{P}c{Q}mod(c)fv(R)=
{PR}c{QR}
H-Frame

Every command is local by theorem 44.11; locality is not a hidden premise of individual derivations.

The adjunction now gives a backward-reasoning use of the wand. Frame (EF)Q around H-Store; its postcondition is (EF)((EF)Q)Q by the counit direction of proposition 44.5. Hence {E((EF)Q)}[E]:=F{Q}.

The conditional rules are exercised by a guarded load. For distinct variables x,y, fix a value v and put Pv=(x=nullemp)(xnullxv),Qv=(x=nullempy=0)(xnullxvy=v),g=if x=null then y:=0 else y:=[x]. The true premise of H-If follows from H-Assign and consequence: Pvx=nullempx=null. Rule H-Assign gives the actual triple {empx=null}y:=0{empx=nully=0}, whose postcondition entails Qv. The false premise begins with Pvxnullxv. Rule H-Load gives {xv}y:=[x]{xvy=v}, and its postcondition entails Qv. Consequence supplies both premises. Therefore H-If derives {Pv}g{Qv}. Operationally, E-IfT followed by E-Assign handles σ(x)=null,h=; E-IfF followed by E-Load handles σ(x)=,h={v}. Thus all three conditional rules occur in a complete verification and its two executions.

Proof of Theorem 44.16 — Soundness of local Hoare reasoning

Proof. Induct on the derivation of {P}c{Q}. Skip follows from E-Skip. For assignment, semantic substitution and E-Assign give σ,hP[E/x]σ[x[[E]]σ],hP. For load, write =[[E]]σ and v=[[F]]σ. The precondition means h={v}, so E-Load returns (σ[xv],h). Since xfv(E,F), both expression values are unchanged, and the result satisfies EFx=F. For store, E-Store changes {v} to {[[F]]σ}; for free, E-Free removes the unique cell and leaves . For allocation, E-Alloc chooses dom(h), extends the heap by {[[F]]σ}, and stores in x. Under the rule’s precondition h=, and xfv(F) preserves the allocated value, so the result satisfies xF.

In the sequence case, validity of the first premise gives safety and R for every intermediate result. Validity of the second premise therefore gives safety and Q for every continuation. This is exactly the recursive safety clause for sequence and rule E-Seq. Consequence uses semantic inclusion. For H-Exists, choose the witness value in the precondition and apply the premise triple in the witness-updated store. Parts 1 and 2 of lemma 44.9 transfer safety and every execution back to the original store; part 3 transfers the postcondition because the auxiliary is not free in it. The conditional evaluates the same pure comparison as its operational rule, so the matching premise applies. The frame case is theorem 44.13, using locality of the command language. ◻

Proposition 44.17 — Swapping two disjoint cells

If tfv(xayb)fv(xbya), then {xayb}t:=[x];[x]:=b;[y]:=t{xbya}. In particular, the precondition entails xy; no separate alias test is needed at run time.

Proof of Proposition 44.17 — Swapping two disjoint cells

Proof. The proof outline records every command between its precondition and postcondition: {xayb}t:=[x];HLoad+HFrame{xa(ybt=a)}[x]:=b;HStore+HFrame{xb(ybt=a)}[y]:=tHStore+HFrame{xbya}. Frame yb around H-Load. Freshness of t yields xaybt=a. By the pure-redistribution and commutativity laws of proposition 44.4, this is equivalent to xa(ybt=a). Frame that entire second factor around H-Store for [x]:=b, obtaining xbybt=a. For the final store, frame xbt=a around the axiom for [y]:=t, again using pure redistribution. The equality is therefore still available, and consequence rewrites the stored value from t to a. Two applications of H-Seq join the three commands. The disjoint heap split in the initial star forces the two addresses to differ. ◻

A linked chain, one cell at a time

The running structure stores only a next pointer. This is enough to expose allocation, deallocation, and the role of separation.

Definition 44.18 — Exact-length chain

For any expression E, define assertions by primitive recursion on n: chain0(E):=empE=null,chainn+1(E):=a. Eachainn(a). At each unfolding, the bound variable a is alpha-renamed away from fv(E) and every binder already in its scope. Thus chainn(E) is the capture-avoiding instance at E. Each successor step consumes one cell disjoint from the tail.

Lemma 44.19 — Exact chain footprint

If σ,hchainn(x), its heap has exactly n locations. At n=0 the head is null; at n>0 it is a non-null member of the heap domain. No location is reused along the recursive tail. Consequently, the cyclic singleton {} satisfies no chainn().

Proof of Lemma 44.19 — Exact chain footprint

Proof. Induct on n. At zero, the definition gives the empty heap and x=null. At a successor, alpha-rename the displayed binder a away from x, choose its witness value v, and choose the split h={σ(x)v}h,σ[av],hchainn(a). Exact points-to and the induction hypothesis give σ(x)null,|dom(h)|=n. Disjointness then gives σ(x)dom(h),|dom(h)|=n+1. Thus no location is reused. For the final claim, zero fails because the cyclic singleton is not empty. At a successor, the head consumes its only cell, leaving the empty heap with the same non-null tail head. The tail cannot be a zero chain because its head is not null, and cannot be a positive chain because its head is absent from the empty domain. ◻

Proposition 44.20 — Prepending a cell

For zx, the program push:=z:=alloc(x);x:=z satisfies {chainn(x)}push{chainn+1(x)}.

Proof of Proposition 44.20 — Prepending a cell

Proof. Rule H-Alloc, framed by chainn(x), gives {empchainn(x)} z:=alloc(x) {zxchainn(x)}. By proposition 44.4, the precondition is equivalent to chainn(x). Before the assignment x:=z, the precondition required by H-Assign for postcondition chainn+1(x) is chainn+1(z). The displayed assertion entails it by choosing the old value of x as the existential tail pointer. Sequence and consequence finish the derivation. ◻

Proposition 44.21 — Removing the head

Let zx, and define pop:=z:=[x];free(x);x:=z. Then {chainn+1(x)}pop{chainn(x)}.

Proof of Proposition 44.21 — Removing the head

Proof. Unfold the precondition and alpha-rename its witness variable a away from x and z: xachainn(a). The complete outline is {xachainn(a)}z:=[x];HLoad+HFrame{xa(chainn(a)z=a)}free(x);HFree+HFrame{chainn(a)z=a}x:=zHAssign{chainn(x)}. Frame chainn(a) around H-Load. The result is xachainn(a)z=a. By consequence, rewrite the last assertion as xa(chainn(a)z=a), and frame the entire second factor around H-Free. The footprint cell disappears, leaving chainn(a)z=a. This entails the assignment precondition chainn(z) for the final command x:=z. Rule H-Seq combines the three derivations, and H-Exists discharges the chosen auxiliary a. ◻

The ordinary-conjunction invariant xachainn(a) cannot support this proof. Its two parts demand the same whole heap, and it neither isolates the cell freed by pop nor proves that the tail survives.

The exact guarantee

Proposition 44.22 — The exact guarantee

For the finite sequential command language, a derivable triple establishes fault freedom and its postcondition for every terminating execution from a state satisfying the precondition. Framed heap cells are unchanged, and framed store facts are unchanged when the modified-variable side condition holds.

Proof of Proposition 44.22 — The exact guarantee

Proof. Soundness is theorem 44.16. The unchanged-heap conclusion is the factorization clause of locality used in theorem 44.13; the store conclusion is lemma 44.8. ◻

Proposition 44.22 is a partial-correctness and fault-freedom result for terminating executions. It contains no loop variant, no interference relation for concurrent steps, and no condition requiring a postcondition to retain every allocated cell. The assertion PQ records only a semantic heap split.

Source note.

O’Hearn, Reynolds, and Yang give the small axioms and frame rule in Section 3, derive larger-footprint laws in Section 4, and isolate the fault-avoiding partial-correctness reading in Section 8 [ORY01]. Reynolds develops the same ingredients together with linked-list examples [Rey02]. The rules in definition 44.15 replay that order: exact one-cell axioms first, then framing and sequencing, and finally the linked-chain proofs of proposition 44.20, proposition 44.21.

The archived Separation Logic Foundations development supplies a mechanized comparison route [Cha25]. The declarations line up as follows; appendix D records the pinned revision and exact file ranges.

book component archived SLF component exact boundary
separating conjunction hstar in Hprop.v same disjoint finite-map split
semantic triple triple in Triples.v book: fault freedom and partial correctness; SLF: omni-big-step total correctness
H-Conseq plus H-Frame triple_conseq_frame in Triples.v same consequence–frame shape
allocation, free, load, store triple_ref, triple_free, triple_get, triple_set in Rules.v SLF commands return values; book commands update named store variables
chainn MList and MList_if in Repr.v same separated head–tail recursion; SLF nodes also carry a data field

The SLF definition of triples and its soundness connection include termination, whereas definition 44.12 asserts fault freedom plus postconditions only for terminating executions. The table is therefore a declaration-by-declaration comparison, not an identification of the two semantic judgments and not a shortcut around theorem 44.11, theorem 44.16. The archived course tree leaves triple_conseq_frame, triple_free’, triple_set, and MList_if as Admitted exercises. Their signatures remain comparison evidence; they are not counted here as checked SLF proofs.

For the command grammar of definition 44.6, locality is theorem 44.11 and Hoare-rule soundness is theorem 44.16. Because that grammar has no parallel command or interleaving reduction, neither theorem states a concurrency result.

Suggested first pass.

Start with exercise 44.4, exercise 44.5, exercise 44.7, exercise 44.9, exercise 44.11; then use the remaining problems to test aliasing and the theorem boundary. No problem in this seminar is a prerequisite for a later chapter.

Exercise 44.4

★☆☆ Write both locality clauses for free(E). In the factorization clause, calculate the domains of the footprint, frame, and result explicitly.

Exercise 44.5

★☆☆ Derive {Ez7}[E]:=F{EFz7}. Name the small-footprint axiom and verify the frame side condition.

Exercise 44.6

★☆☆ Replace both stars in proposition 44.17 by ordinary conjunction. Using the exact points-to semantics of definition 44.3, determine whether the new precondition is satisfiable. Explain why an inexact global points-to predicate would instead require an explicit non-aliasing premise.

Exercise 44.7

★☆☆ Compose proposition 44.21 twice to derive the exact triple for removing two cells. State the smallest admissible input length and the resulting length.

Exercise 44.8

★★☆ If σ,hchainn(x)chainm(y), prove that |dom(h)|=n+m, and that the two heads denote distinct locations whenever n,m>0. Identify the exact use of disjointness.

Exercise 44.9

★★☆ Prove that no valid triple with satisfiable precondition can type the exact sequence free(x);y:=[x]. Give the semantic fault argument and the failed proof-rule premise. Then explain why inserting x:=alloc(v) before the load establishes a new owned address, rather than restoring a guaranteed old address.

Exercise 44.10

★★☆ In the sublanguage whose only command-visible root is x, derive a valid triple for x:=alloc(0);x:=null whose postcondition is true. Explain why this does not contradict proposition 44.22 and which stronger postcondition would expose the unreachable cell.

Exercise 44.11

★☆☆ Using the archived-source locators in appendix D, compare the statements of H-Frame, H-Alloc, H-Free, H-Load, and H-Store with triple_conseq_frame, triple_ref, triple_free, triple_get, and triple_set. Then unfold MList once and compare it with one unfolding of chainn+1. Record the triple semantics, return-value convention, and node layout at every mismatch. Explain why these comparisons do not transfer SLF soundness to this chapter’s command language.

Exercise 44.12

★★★ Practical project.separation-symbolic-executor Implement the finite store, heap, and command evaluator in Kappa together with the exact footprint predicates needed by the worked examples. Maintain these invariants:

  1. heap union is performed only on disjoint domains;

  2. a missing load, store, or free address reports a fault rather than a default value;

  3. allocation returns a location absent from the current heap; and

  4. exact points-to and chain predicates check footprint size as well as stored values.

The oracle must accept a framed cell update, allocation followed by deallocation, push then pop on an exact two-cell chain, and exact singleton points-to; it must report a fault for load after free and reject an aliased separating conjunction. Mutate missing heap lookup to return null; the mutant must type-check and audit cleanly but fail the use-after-free oracle. Appendix E records the four acceptance commands and appendix F gives the implementation stages.

Search the book

Type to search the local edition.