Documentation

CslibFrontier.Computability.PointerMachine.Embedding

Injective heap embeddings #

An embedding preserves registers and all source records while allowing extra target records. Its address map is injective only on the allocated source heap. Creating a record extends that map at the fresh source address, leaving all old addresses unchanged.

Main definitions #

Main results #

def Cslib.PointerMachine.Record.relabel {M : Model} {L : Layout} (f : ℕ → ℕ) (n : Record M L) :
Record M L

Rename a record's pointers without changing its data.

structure Cslib.PointerMachine.State.Embeds {M : Model} {L : Layout} (f : ℕ → ℕ) (x y : State M L) :

A valid source heap embedded in a valid target heap, with identical control and data. The target may have additional records; the map is constrained only on allocated source addresses.

theorem Cslib.PointerMachine.State.Embeds.with_pc {M : Model} {L : Layout} {f : ℕ → ℕ} {x y : State M L} (h : Embeds f x y) (p : ℕ) :
Embeds f { pc := p, ptr := x.ptr, data := x.data, heap := x.heap } { pc := p, ptr := y.ptr, data := y.data, heap := y.heap }

Changing both control labels preserves an embedding.

theorem Cslib.PointerMachine.State.Embeds.deref {M : Model} {L : Layout} {f : ℕ → ℕ} {x y : State M L} (h : Embeds f x y) (r : Fin L.ptrRegs) :

Embeddings preserve the record obtained by following any register.

theorem Cslib.PointerMachine.State.Embeds.ptr_eq_iff {M : Model} {L : Layout} {f : ℕ → ℕ} {x y : State M L} (h : Embeds f x y) (r s : Fin L.ptrRegs) :
y.ptr r = y.ptr s ↔ x.ptr r = x.ptr s

Pointer equality in registers is both preserved and reflected.

theorem Cslib.PointerMachine.State.Embeds.next {M : Model} {L : Layout} {f : ℕ → ℕ} {x y : State M L} (h : Embeds f x y) (i : Instr M L) :

The next control label is unchanged by a heap embedding.

theorem Cslib.PointerMachine.State.Embeds.effect {M : Model} {L : Layout} {f : ℕ → ℕ} {x y : State M L} (h : Embeds f x y) (i : Instr M L) :
∃ (g : ℕ → ℕ), (∀ a < x.heap.length, g a = f a) ∧ Embeds g (Instr.effect x i) (Instr.effect y i)

Every instruction preserves heap embeddings. Allocation extends the map at the fresh source address and leaves its values on all previously allocated source addresses unchanged.