Documentation

Complexity.Computability.WordRAM.Heap

Finite-footprint memory assertions #

Assertions record a finite footprint and depend only on its cells. Separating conjunction requires disjoint footprints. This is an assertion and frame calculus over the RAM's total memory, not a new allocator or a claim that inaccessible cells cease to exist.

Main definitions #

Main results #

References #

The footprint/frame principle is the standard locality principle of separation logic; this file uses explicit finite supports rather than partial-heap semantics. See J. C. Reynolds, Separation Logic: A Logic for Shared Mutable Data Structures.

The finite set of memory cells owned by the block.

Instances For

    A predicate depending only on a finite set of memory cells.

    • footprint : Finset ℕ

      Cells on which the predicate may depend.

    • holds : (ℕ → ℕ) → Prop

      The asserted property of total RAM memory.

    • supported {m m' : ℕ → ℕ} : (∀ a ∈ self.footprint, m a = m' a) → self.holds m → self.holds m'

      Agreement on owned cells transports the assertion.

    Instances For
      def Cslib.WordRAM.Modifies (writes : Finset ℕ) (m m' : ℕ → ℕ) :

      The two memories agree outside the permitted write footprint.

      Instances For
        theorem Cslib.WordRAM.Modifies.refl (F : Finset ℕ) (m : ℕ → ℕ) :
        Modifies F m m

        An unchanged memory modifies no cells.

        theorem Cslib.WordRAM.Modifies.trans {F G : Finset ℕ} {m m' m'' : ℕ → ℕ} (h : Modifies F m m') (h' : Modifies G m' m'') :
        Modifies (F ∪ G) m m''

        Sequential writes use the union of the permitted regions.

        theorem Cslib.WordRAM.Modifies.update (m : ℕ → ℕ) (a v : ℕ) :

        A single write modifies at most its destination.

        theorem Cslib.WordRAM.Modifies.write_of_owns {base n a : ℕ} {m : ℕ → ℕ} (ha : base ≤ a ∧ a < base + n) (v : ℕ) :
        Modifies { base := base, length := n }.footprint m (Function.update m a v)

        Writing a cell owned by a block modifies at most the block's footprint.

        theorem Cslib.WordRAM.Modifies.block_iff {b : Block} {m m' : ℕ → ℕ} :
        Modifies b.footprint m m' ↔ ∀ (a : ℕ), a < b.base ∨ b.base + b.length ≤ a → m' a = m a

        Modifying at most a block's footprint is equivalent to preserving all cells outside its address interval.

        A memory-free assertion.

        Instances For

          A single owned cell with specified contents.

          Instances For
            def Cslib.WordRAM.HeapAssertion.array (base n : ℕ) (values : Fin n → ℕ) :

            A record, or array, of consecutive owned cells.

            Instances For

              Conjunction of assertions with disjoint ownership.

              Instances For
                theorem Cslib.WordRAM.HeapAssertion.sep_comm (P Q : HeapAssertion) (m : ℕ → ℕ) :
                (P.sep Q).holds m ↔ (Q.sep P).holds m

                Separating conjunction can be reordered.

                theorem Cslib.WordRAM.HeapAssertion.frame {P : HeapAssertion} {F : Finset ℕ} {m m' : ℕ → ℕ} (hP : P.holds m) (hF : Disjoint P.footprint F) (hm : Modifies F m m') :
                P.holds m'

                A disjoint write preserves every assertion supported on the framed region.

                theorem Cslib.WordRAM.HeapAssertion.frame_update {P : HeapAssertion} {m : ℕ → ℕ} (hP : P.holds m) {a : ℕ} (ha : a ∉ P.footprint) (v : ℕ) :

                Updating an unowned cell preserves an assertion.

                A point assertion is updated by the corresponding store.