Documentation

Complexity.Language.Rooted

Existing object roots in source values and environments #

Rootedness only says that a buffer or node reference's object identifier denotes an existing slot. It imposes no stored type, extent, scalar-range or separation condition. A rooted node reference need not denote a correctly typed node or a valid list; preserving a reachable chain additionally needs its contents and the heap's link invariant. Rooted buffers may likewise fail a heap access. Scalars carry no roots. Products retain both fields' roots, and options retain roots only in an actual payload. These source predicates contain no machine addresses or runtime metadata.

A node reference names an existing object slot. This does not assert a successful typed node lookup, valid tail or finite linked-list contents.

Equations
Instances For
    theorem Complexity.Language.NodeRef.Rooted.mono {τ : CellTy} {ref : NodeRef τ} {initial finish : Heap} (rooted : ref.Rooted initial) (growth : initial.ShapeExtends finish) :
    ref.Rooted finish

    Heap shape growth preserves the referenced identity, even when its stored kind is invalid. No claim about its reachable tail follows from rootedness.

    theorem Complexity.Language.ValueRooted.mono {initial finish : Heap} {τ : Ty} {value : Value τ} (rooted : ValueRooted initial value) (growth : initial.ShapeExtends finish) :
    ValueRooted finish value

    Heap growth preserves the object roots of a retained source value.

    def Complexity.Language.Env.Rooted {Γ : List Ty} (env : Env Γ) (heap : Heap) :

    All object references carried by bindings name existing object slots.

    Equations
    Instances For
      @[simp]

      An empty environment retains no object roots.

      theorem Complexity.Language.Env.Rooted.cons {Γ : List Ty} {τ : Ty} {heap : Heap} {env : Env Γ} (rooted : env.Rooted heap) (value : Value τ) (valueRooted : ValueRooted heap value) :
      (Env.cons value env).Rooted heap

      Adding a rooted value preserves rootedness of every lexical binding.

      theorem Complexity.Language.Env.Rooted.head {τ : Ty} {Γ : List Ty} {heap : Heap} {env : Env (τ :: Γ)} (rooted : env.Rooted heap) :
      ValueRooted heap env.head

      The innermost value retains an existing object identifier.

      theorem Complexity.Language.Env.Rooted.tail {τ : Ty} {Γ : List Ty} {heap : Heap} {env : Env (τ :: Γ)} (rooted : env.Rooted heap) :
      env.tail.Rooted heap

      Leaving a lexical scope retains the roots of the outer bindings.

      @[simp]
      theorem Complexity.Language.Env.Rooted.cons_iff {τ : Ty} {Γ : List Ty} (heap : Heap) (value : Value τ) (env : Env Γ) :
      (Env.cons value env).Rooted heap ↔ ValueRooted heap value ∧ env.Rooted heap

      Root obligations decompose along the actual lexical environment.

      theorem Complexity.Language.Env.Rooted.mono {Γ : List Ty} {initial finish : Heap} {env : Env Γ} (rooted : env.Rooted initial) (growth : initial.ShapeExtends finish) :
      env.Rooted finish

      Heap growth also preserves suspended callers' source environments.

      theorem Complexity.Language.Atom.eval_rooted {Γ : List Ty} {τ : Ty} {heap : Heap} {env : Env Γ} (atom : Atom Γ τ) (rooted : env.Rooted heap) :
      ValueRooted heap (atom.eval env)

      Atoms retain an existing variable's roots or produce a root-free scalar.

      theorem Complexity.Language.Prim.eval_rooted {Γ : List Ty} {τ : Ty} {heap : Heap} {env : Env Γ} (prim : Prim Γ τ) (rooted : env.Rooted heap) :
      ValueRooted heap (prim.eval env)

      Primitives cannot construct a new object identifier.

      theorem Complexity.Language.Args.eval_rooted {Γ params : List Ty} {heap : Heap} {env : Env Γ} (args : Args Γ params) (rooted : env.Rooted heap) :
      (args.eval env).Rooted heap

      Actual call operands preserve the roots needed by the callee's environment.

      theorem Complexity.Language.CellTy.toValue_rooted (heap : Heap) (kind : CellTy) (value : CellValue kind) :
      ValueRooted heap (kind.toValue value)

      Shared object cells are scalars and cannot introduce an object root.

      theorem Complexity.Language.Buffer.Rooted.slice {heap : Heap} {kind : CellTy} {buffer view : Buffer kind} {offset length : ℕ} (rooted : buffer.Rooted heap) (sliced : buffer.slice offset length = Except.ok view) :
      view.Rooted heap

      A successful relative slice keeps the original object identifier, even when that object's scalar type or the resulting view extent is invalid.