Documentation

Semantic.CC.Semantics.Heap

A set of capability labels, representing an "authority": they are the set of capabilities a program at most uses.

Instances For
    Instances For
      Instances For
        theorem CC.CapabilitySet.subset_preserves_mem {C1 C2 : CapabilitySet} {x : } (hsub : C1 C2) (hmem : x C1) :
        x C2

        If an element is in a set, then the singleton of that element is a subset of the set.

        theorem CC.CapabilitySet.subset_trans {C1 C2 C3 : CapabilitySet} (h1 : C1 C2) (h2 : C2 C3) :
        C1 C3
        theorem CC.CapabilitySet.union_subset_of_subset_of_subset {C1 C2 C : CapabilitySet} (h1 : C1 C) (h2 : C2 C) :
        C1 C2 C
        Equations
        Instances For
          theorem CC.CapabilitySet.equiv_symm {C1 C2 : CapabilitySet} (h : C1 C2) :
          C2 C1
          theorem CC.CapabilitySet.equiv_trans {C1 C2 C3 : CapabilitySet} (h1 : C1 C2) (h2 : C2 C3) :
          C1 C3
          theorem CC.CapabilitySet.union_assoc_equiv {C1 C2 C3 : CapabilitySet} :
          C1 C2 C3 C1 (C2 C3)
          theorem CC.CapabilitySet.subset_of_equiv_subset {C1 C2 C : CapabilitySet} (heq : C1 C2) (hsub : C2 C) :
          C1 C

          If C1 ≈ C2 and C2 ⊆ C, then C1 ⊆ C. This allows transferring subset through equivalence.

          structure CC.HeapVal :

          A heap value. It must be a simple value, with a reachability set computed.

          Instances For
            theorem CC.Exp.IsSimpleVal.to_IsVal {s : Sig} {e : Exp s} (h : e.IsSimpleVal) :

            Convert IsSimpleVal to IsVal

            Underlying info of a capability.

            Instances For
              inductive CC.Cell :

              A heap cell.

              Instances For
                Equations
                Instances For
                  Equations
                  Instances For
                    def CC.Heap.extend (h : Heap) (l : ) (v : HeapVal) :
                    Equations
                    Instances For
                      def CC.Heap.extend_cap (h : Heap) (l : ) :
                      Equations
                      Instances For
                        def CC.Heap.update_cell (h : Heap) (l : ) (c : Cell) :

                        Update a cell in the heap with a new cell value.

                        Equations
                        Instances For

                          Auxiliary relation: one cell subsumes another. For mutable cells, the boolean value is irrelevant.

                          Equations
                          Instances For
                            theorem CC.Cell.subsumes_trans {c1 c2 c3 : Cell} (h12 : c1.subsumes c2) (h23 : c2.subsumes c3) :
                            c1.subsumes c3
                            def CC.Heap.subsumes (big small : Heap) :
                            Equations
                            Instances For

                              Heap predicate.

                              Equations
                              Instances For

                                Postcondition.

                                Equations
                                Instances For

                                  Monotonicity of postconditions.

                                  Equations
                                  Instances For
                                    def CC.Hpost.entails (Q1 Q2 : Hpost) :
                                    Equations
                                    Instances For
                                      Equations
                                      • = hQ
                                      Instances For
                                        def CC.Heap.subsumes_trans {h1 h2 h3 : Heap} (h12 : h1.subsumes h2) (h23 : h2.subsumes h3) :
                                        h1.subsumes h3
                                        Equations
                                        • =
                                        Instances For

                                          Updating an mcell with another mcell creates a heap that subsumes the original.

                                          theorem CC.Heap.extend_lookup_eq (h : Heap) (l : ) (v : HeapVal) :
                                          h.extend l v l = some (Cell.val v)
                                          theorem CC.Heap.extend_subsumes {v : HeapVal} {H : Heap} {l : } (hfresh : H l = none) :
                                          (H.extend l v).subsumes H
                                          inductive CC.CaptureSet.WfInHeap {s : Sig} :
                                          CaptureSet sHeapProp
                                          Instances For
                                            inductive CC.Var.WfInHeap {k : Kind} {s : Sig} :
                                            Var k sHeapProp
                                            Instances For
                                              Instances For
                                                inductive CC.Ty.WfInHeap {sort : TySort} {s : Sig} :
                                                Ty sort sHeapProp
                                                Instances For
                                                  inductive CC.Exp.WfInHeap {s : Sig} :
                                                  Exp sHeapProp
                                                  Instances For
                                                    theorem CC.Var.wf_of_closed {k : Kind} {s : Sig} {x : Var k s} {H : Heap} (hclosed : x.IsClosed) :

                                                    Closedness implies well-formedness for variables.

                                                    theorem CC.CaptureSet.wf_of_closed {s : Sig} {cs : CaptureSet s} {H : Heap} (hclosed : cs.IsClosed) :

                                                    Closedness implies well-formedness for capture sets.

                                                    theorem CC.CaptureBound.wf_of_closed {s : Sig} {cb : CaptureBound s} {H : Heap} (hclosed : cb.IsClosed) :

                                                    Closedness implies well-formedness for capture bounds.

                                                    theorem CC.Ty.wf_of_closed {sort : TySort} {s : Sig} {T : Ty sort s} {H : Heap} (hclosed : T.IsClosed) :

                                                    Closedness implies well-formedness for types.

                                                    theorem CC.Exp.wf_of_closed {s : Sig} {e : Exp s} {H : Heap} (hclosed : e.IsClosed) :

                                                    Closedness implies well-formedness for expressions.

                                                    theorem CC.Var.wf_monotonic {a✝ : Kind} {a✝¹ : Sig} {x : Var a✝ a✝¹} {h1 h2 : Heap} (hsub : h2.subsumes h1) (hwf : x.WfInHeap h1) :
                                                    theorem CC.CaptureSet.wf_monotonic {a✝ : Sig} {cs : CaptureSet a✝} {h1 h2 : Heap} (hsub : h2.subsumes h1) (hwf : cs.WfInHeap h1) :
                                                    cs.WfInHeap h2
                                                    theorem CC.CaptureBound.wf_monotonic {a✝ : Sig} {cb : CaptureBound a✝} {h1 h2 : Heap} (hsub : h2.subsumes h1) (hwf : cb.WfInHeap h1) :
                                                    cb.WfInHeap h2
                                                    theorem CC.Ty.wf_monotonic {a✝ : TySort} {a✝¹ : Sig} {T : Ty a✝ a✝¹} {h1 h2 : Heap} (hsub : h2.subsumes h1) (hwf : T.WfInHeap h1) :
                                                    theorem CC.Exp.wf_monotonic {a✝ : Sig} {e : Exp a✝} {h1 h2 : Heap} (hsub : h2.subsumes h1) (hwf : e.WfInHeap h1) :
                                                    theorem CC.Exp.wf_inv_letin {s : Sig} {e1 : Exp s} {e2 : Exp (s,x)} {H : Heap} (hwf : (e1.letin e2).WfInHeap H) :

                                                    Inversion for let-in: if let x = e1 in e2 is well-formed, then both e1 and e2 are well-formed.

                                                    theorem CC.Exp.wf_inv_unpack {s : Sig} {e1 : Exp s} {e2 : Exp (s,C,x)} {H : Heap} (hwf : (e1.unpack e2).WfInHeap H) :

                                                    Inversion for unpack: if unpack e1 in e2 is well-formed, then both e1 and e2 are well-formed.

                                                    theorem CC.Exp.wf_inv_cond {s : Sig} {x : Var Kind.var s} {e2 e3 : Exp s} {H : Heap} (hwf : (cond x e2 e3).WfInHeap H) :

                                                    Inversion for conditionals.

                                                    theorem CC.Exp.wf_inv_abs {s : Sig} {cs : CaptureSet s} {T : Ty TySort.capt s} {e : Exp (s,x)} {H : Heap} (hwf : (abs cs T e).WfInHeap H) :

                                                    Inversion for lambda abstraction: if λ(cs) (x : T). e is well-formed, then its capture set, type, and body are all well-formed.

                                                    theorem CC.Exp.wf_inv_tabs {s : Sig} {cs : CaptureSet s} {T : Ty TySort.shape s} {e : Exp (s,X)} {H : Heap} (hwf : (tabs cs T e).WfInHeap H) :

                                                    Inversion for type abstraction: if Λ(cs) (X <: T). e is well-formed, then its capture set, type bound, and body are all well-formed.

                                                    theorem CC.Exp.wf_inv_cabs {s : Sig} {cs : CaptureSet s} {cb : CaptureBound s} {e : Exp (s,C)} {H : Heap} (hwf : (cabs cs cb e).WfInHeap H) :

                                                    Inversion for capture abstraction: if λ[cs] (C <: cb). e is well-formed, then its capture set, capture bound, and body are all well-formed.

                                                    structure CC.Subst.WfInHeap {s1 s2 : Sig} (s : Subst s1 s2) (H : Heap) :
                                                    Instances For

                                                      Lookup the reachability set of a location.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        Resolve reachability of each element of the capture set.

                                                        Equations
                                                        Instances For
                                                          Equations
                                                          Instances For
                                                            theorem CC.resolve_monotonic {e v : Exp } {H1 H2 : Heap} (hsub : H2.subsumes H1) (hres : resolve H1 e = some v) :
                                                            resolve H2 e = some v
                                                            theorem CC.reachability_of_loc_monotonic {v : Cell} {h1 h2 : Heap} (hsub : h2.subsumes h1) (l : ) (hex : h1 l = some v) :
                                                            theorem CC.expand_captures_monotonic {h1 h2 : Heap} (hsub : h2.subsumes h1) (cs : CaptureSet ) (hwf : cs.WfInHeap h1) :

                                                            Expanding a capture set in a bigger heap yields the same result. Proof by induction on cs. Requires all free locations in cs to exist in h1.

                                                            theorem CC.resolve_reachability_monotonic {H1 H2 : Heap} (hsub : H2.subsumes H1) (e : Exp ) (hwf : e.WfInHeap H1) :
                                                            theorem CC.compute_reachability_monotonic {h1 h2 : Heap} (hsub : h2.subsumes h1) (v : Exp ) (hv : v.IsSimpleVal) (hwf : v.WfInHeap h1) :

                                                            Computing reachability of a value in a bigger heap yields the same result. Proof by cases on hv, using expand_captures_monotonic.

                                                            Updating an mcell preserves reachability_of_loc for all locations.

                                                            Updating an mcell preserves expand_captures.

                                                            Updating an mcell preserves compute_reachability.

                                                            structure CC.Heap.WfHeap (H : Heap) :

                                                            A heap is well-formed if all values stored in it contain well-formed expressions.

                                                            Instances For

                                                              The empty heap is well-formed.

                                                              theorem CC.Heap.wf_extend {H : Heap} {l : } {v : HeapVal} (hwf_H : H.WfHeap) (hwf_v : v.unwrap.WfInHeap H) (hreach : v.reachability = compute_reachability H v.unwrap ) (hfresh : H l = none) :
                                                              (H.extend l v).WfHeap

                                                              Extending a well-formed heap with a well-formed value preserves well-formedness.

                                                              theorem CC.Heap.wf_lookup {H : Heap} {l : } {hv : HeapVal} (hwf_H : H.WfHeap) (hlookup : H l = some (Cell.val hv)) :

                                                              If a heap is well-formed and we look up a value, the expression is well-formed.

                                                              theorem CC.Var.wf_rename {k : Kind} {s1 s2 : Sig} {x : Var k s1} {f : Rename s1 s2} {H : Heap} (hwf : x.WfInHeap H) :

                                                              Renaming preserves well-formedness of variables.

                                                              theorem CC.CaptureSet.wf_rename {s1 s2 : Sig} {cs : CaptureSet s1} {f : Rename s1 s2} {H : Heap} (hwf : cs.WfInHeap H) :
                                                              (cs.rename f).WfInHeap H

                                                              Renaming preserves well-formedness of capture sets.

                                                              theorem CC.CaptureBound.wf_rename {s1 s2 : Sig} {cb : CaptureBound s1} {f : Rename s1 s2} {H : Heap} (hwf : cb.WfInHeap H) :
                                                              (cb.rename f).WfInHeap H

                                                              Renaming preserves well-formedness of capture bounds.

                                                              theorem CC.Ty.wf_rename {sort : TySort} {s1 s2 : Sig} {T : Ty sort s1} {f : Rename s1 s2} {H : Heap} (hwf : T.WfInHeap H) :

                                                              Renaming preserves well-formedness of types.

                                                              theorem CC.Exp.wf_rename {s1 s2 : Sig} {e : Exp s1} {f : Rename s1 s2} {H : Heap} (hwf : e.WfInHeap H) :

                                                              Renaming preserves well-formedness of expressions.

                                                              theorem CC.CaptureSet.wf_of_var {s : Sig} {x : Var Kind.var s} {H : Heap} (hwf : x.WfInHeap H) :

                                                              A well-formed variable yields a well-formed capture set.

                                                              theorem CC.Subst.wf_lift {s1 s2 : Sig} {k : Kind} {σ : Subst s1 s2} {H : Heap} (hwf_σ : σ.WfInHeap H) :

                                                              Lifting a well-formed substitution preserves well-formedness.

                                                              theorem CC.Var.wf_subst {s1 s2 : Sig} {x : Var Kind.var s1} {σ : Subst s1 s2} {H : Heap} (hwf_x : x.WfInHeap H) (hwf_σ : σ.WfInHeap H) :
                                                              (x.subst σ).WfInHeap H

                                                              Well-formed substitutions preserve well-formedness of variables.

                                                              theorem CC.CaptureSet.wf_subst {s1 s2 : Sig} {cs : CaptureSet s1} {σ : Subst s1 s2} {H : Heap} (hwf_cs : cs.WfInHeap H) (hwf_σ : σ.WfInHeap H) :
                                                              (cs.subst σ).WfInHeap H

                                                              Well-formed substitutions preserve well-formedness of capture sets.

                                                              theorem CC.CaptureBound.wf_subst {s1 s2 : Sig} {cb : CaptureBound s1} {σ : Subst s1 s2} {H : Heap} (hwf_cb : cb.WfInHeap H) (hwf_σ : σ.WfInHeap H) :
                                                              (cb.subst σ).WfInHeap H

                                                              Well-formed substitutions preserve well-formedness of capture bounds.

                                                              theorem CC.Ty.wf_subst {sort : TySort} {s1 s2 : Sig} {T : Ty sort s1} {σ : Subst s1 s2} {H : Heap} (hwf_T : T.WfInHeap H) (hwf_σ : σ.WfInHeap H) :
                                                              (T.subst σ).WfInHeap H

                                                              Well-formed substitutions preserve well-formedness of types.

                                                              theorem CC.Exp.wf_subst {s1 s2 : Sig} {e : Exp s1} {σ : Subst s1 s2} {H : Heap} (hwf_e : e.WfInHeap H) (hwf_σ : σ.WfInHeap H) :
                                                              (e.subst σ).WfInHeap H

                                                              Well-formed substitutions preserve well-formedness of expressions.

                                                              theorem CC.Subst.wf_openVar {s : Sig} {x : Var Kind.var s} {H : Heap} (hwf_x : x.WfInHeap H) :

                                                              Opening substitution for variables is well-formed if the variable is well-formed.

                                                              theorem CC.Subst.wf_openTVar {s : Sig} {U : Ty TySort.shape s} {H : Heap} (hwf_U : U.WfInHeap H) :

                                                              Opening substitution for type variables is well-formed if the type is well-formed.

                                                              theorem CC.Subst.wf_openCVar {s : Sig} {C : CaptureSet s} {H : Heap} (hwf_C : C.WfInHeap H) :

                                                              Opening substitution for capture variables is well-formed if the capture set is well-formed.

                                                              theorem CC.Subst.wf_unpack {s : Sig} {C : CaptureSet s} {x : Var Kind.var s} {H : Heap} (hwf_C : C.WfInHeap H) (hwf_x : x.WfInHeap H) :

                                                              Unpack substitution is well-formed if both the capture set and variable are well-formed.

                                                              Equations
                                                              Instances For
                                                                Equations
                                                                • =
                                                                Instances For
                                                                  theorem CC.Heap.extend_has_fin_dom {H : Heap} {dom : Finset } {l : } {v : HeapVal} (hdom : H.HasFinDom dom) (hfresh : H l = none) :
                                                                  (H.extend l v).HasFinDom (dom {l})
                                                                  theorem CC.Heap.extend_cap_has_fin_dom {H : Heap} {dom : Finset } {l : } (hdom : H.HasFinDom dom) (hfresh : H l = none) :
                                                                  (H.extend_cap l).HasFinDom (dom {l})
                                                                  structure CC.Memory :

                                                                  Memory is a well-formed heap.

                                                                  Instances For

                                                                    Create an empty memory.

                                                                    Equations
                                                                    Instances For

                                                                      Lookup a value in memory.

                                                                      Equations
                                                                      Instances For
                                                                        def CC.Memory.extend (m : Memory) (l : ) (v : HeapVal) (hwf_v : v.unwrap.WfInHeap m.heap) (hreach : v.reachability = compute_reachability m.heap v.unwrap ) (hfresh : m.heap l = none) :

                                                                        Extend memory with a new value. Requires proof that the value is well-formed and the location is fresh.

                                                                        Equations
                                                                        Instances For
                                                                          theorem CC.Memory.Heap.extend_cap_subsumes {H : Heap} {l : } (hfresh : H l = none) :

                                                                          Heap extension with capability subsumes original heap.

                                                                          def CC.Memory.extend_cap (m : Memory) (l : ) (hfresh : m.heap l = none) :

                                                                          Extend memory with a capability cell.

                                                                          Equations
                                                                          Instances For
                                                                            def CC.Memory.extend_val (m : Memory) (l : ) (v : HeapVal) (hwf_v : v.unwrap.WfInHeap m.heap) (hreach : v.reachability = compute_reachability m.heap v.unwrap ) (hfresh : m.heap l = none) :

                                                                            Extend memory with a value that's well-formed in the current heap. This is often more convenient than extend in practice.

                                                                            Equations
                                                                            Instances For
                                                                              def CC.Memory.update_mcell (m : Memory) (l : ) (b : Bool) (hexists : ∃ (b0 : Bool), m.heap l = some (Cell.capability (CapabilityInfo.mcell b0))) :

                                                                              Update a mutable cell in memory with a new boolean value. Requires proof that the location contains a mutable cell.

                                                                              Equations
                                                                              Instances For

                                                                                Memory subsumption: m1 subsumes m2 if m1's heap subsumes m2's heap.

                                                                                Equations
                                                                                Instances For

                                                                                  Reflexivity of memory subsumption.

                                                                                  theorem CC.Memory.subsumes_trans {m1 m2 m3 : Memory} (h12 : m1.subsumes m2) (h23 : m2.subsumes m3) :
                                                                                  m1.subsumes m3

                                                                                  Transitivity of memory subsumption.

                                                                                  theorem CC.Memory.update_mcell_subsumes (m : Memory) (l : ) (b : Bool) (hexists : ∃ (b0 : Bool), m.heap l = some (Cell.capability (CapabilityInfo.mcell b0))) :
                                                                                  (m.update_mcell l b hexists).subsumes m

                                                                                  Updating a mutable cell creates a memory that subsumes the original.

                                                                                  theorem CC.Memory.update_mcell_subsumes_compat {m1 m2 : Memory} (l : ) (b : Bool) (hexists1 : ∃ (b0 : Bool), m1.heap l = some (Cell.capability (CapabilityInfo.mcell b0))) (hexists2 : ∃ (b0 : Bool), m2.heap l = some (Cell.capability (CapabilityInfo.mcell b0))) (hsub : m2.subsumes m1) :
                                                                                  (m2.update_mcell l b hexists2).subsumes (m1.update_mcell l b hexists1)

                                                                                  Updating mcells in subsuming memories preserves subsumption.

                                                                                  theorem CC.Memory.extend_lookup_eq (m : Memory) (l : ) (v : HeapVal) (hwf_v : v.unwrap.WfInHeap m.heap) (hreach : v.reachability = compute_reachability m.heap v.unwrap ) (hfresh : m.heap l = none) :
                                                                                  (m.extend l v hwf_v hreach hfresh).lookup l = some (Cell.val v)

                                                                                  Looking up from a memory after extension at the same location returns the value.

                                                                                  theorem CC.Memory.extend_subsumes (m : Memory) (l : ) (v : HeapVal) (hwf_v : v.unwrap.WfInHeap m.heap) (hreach : v.reachability = compute_reachability m.heap v.unwrap ) (hfresh : m.heap l = none) :
                                                                                  (m.extend l v hwf_v hreach hfresh).subsumes m

                                                                                  Extension subsumes the original memory.

                                                                                  theorem CC.Memory.extend_val_subsumes (m : Memory) (l : ) (v : HeapVal) (hwf_v : v.unwrap.WfInHeap m.heap) (hreach : v.reachability = compute_reachability m.heap v.unwrap ) (hfresh : m.heap l = none) :
                                                                                  (m.extend_val l v hwf_v hreach hfresh).subsumes m

                                                                                  Extension with extend_val subsumes the original memory.

                                                                                  theorem CC.Memory.extend_cap_subsumes (m : Memory) (l : ) (hfresh : m.heap l = none) :
                                                                                  (m.extend_cap l hfresh).subsumes m

                                                                                  Capability extension subsumes the original memory.

                                                                                  theorem CC.Memory.wf_monotonic {e : Exp } {m1 m2 : Memory} (hsub : m2.subsumes m1) (hwf : e.WfInHeap m1.heap) :

                                                                                  Well-formedness is preserved under memory subsumption.

                                                                                  theorem CC.Memory.wf_lookup {m : Memory} {l : } {hv : HeapVal} (hlookup : m.lookup l = some (Cell.val hv)) :

                                                                                  Looking up a value from a memory yields a well-formed expression.

                                                                                  Memory predicate.

                                                                                  Equations
                                                                                  Instances For

                                                                                    Memory postcondition.

                                                                                    Equations
                                                                                    Instances For

                                                                                      Monotonicity of memory postconditions.

                                                                                      Equations
                                                                                      Instances For
                                                                                        def CC.Mpost.entails (Q1 Q2 : Mpost) :

                                                                                        Entailment between memory postconditions.

                                                                                        Equations
                                                                                        Instances For
                                                                                          Equations
                                                                                          • = hQ
                                                                                          Instances For
                                                                                            theorem CC.Memory.exists_fresh (m : Memory) :
                                                                                            ∃ (l : ), m.lookup l = none

                                                                                            A heap has a capability domain if all capabilities on this heap lives in the given domain.

                                                                                            Equations
                                                                                            Instances For

                                                                                              Masks capabilities in the heap outside of the given domain.

                                                                                              Equations
                                                                                              Instances For

                                                                                                Turns a capability set into a finite set of natural numbers.

                                                                                                Equations
                                                                                                Instances For