Documentation

CatCryptCore.Invariant.Coupling

Location Couplings for Relational Reasoning #

This file defines location-specific couplings - relations between specific locations across the left and right heaps. These are used as semi-invariants that hold for specific locations.

Main definitions #

Usage #

Location couplings are composed with invariants using to build more precise relational specifications. The ssprove_sync and ssprove_restore tactics manipulate these couplings.

References #

Synchronization #

def CatCrypt.Invariant.syncs (l₀ l₁ : Core.Location) (hty : l₀.ty = l₁.ty) :

Two locations are synchronized: they have equal values

Equations
Instances For

    Same location synchronized on both sides

    Equations
    Instances For
      theorem CatCrypt.Invariant.syncsAt_def (l : Core.Location) (h₀ h₁ : Core.Heap) :
      syncsAt l h₀ h₁ h₀.get l = h₁.get l

      Remembered Values #

      Remembered value on the left: the left heap has value v at location l

      Equations
      Instances For

        Remembered value on the right: the right heap has value v at location l

        Equations
        Instances For

          Remembered value in a specific invariant (left or right)

          Instances For

            Single-Location Predicates #

            Predicate about a single location on the left

            Equations
            Instances For

              Predicate about a single location on the right

              Equations
              Instances For

                Location Couplings #

                def CatCrypt.Invariant.couple_lhs (l₀ l₁ : Core.Location) (R : l₀.tyl₁.tyProp) :

                Relation between two locations on the left heap

                Equations
                Instances For
                  def CatCrypt.Invariant.couple_rhs (l₀ l₁ : Core.Location) (R : l₀.tyl₁.tyProp) :

                  Relation between two locations on the right heap

                  Equations
                  Instances For
                    def CatCrypt.Invariant.couple_cross (l₀ l₁ : Core.Location) (hty : l₀.ty = l₁.ty) (R : l₀.tyl₁.tyProp) :

                    Relation between a location on left and a location on right

                    Equations
                    Instances For
                      def CatCrypt.Invariant.eqCross (l₀ l₁ : Core.Location) (hty : l₀.ty = l₁.ty) :

                      Equality coupling across sides (same as syncs)

                      Equations
                      Instances For

                        Triple Couplings #

                        def CatCrypt.Invariant.triple_lhs (l₀ l₁ l₂ : Core.Location) (R : l₀.tyl₁.tyl₂.tyProp) :

                        Relation between three locations on the left

                        Equations
                        Instances For
                          def CatCrypt.Invariant.triple_rhs (l₀ l₁ l₂ : Core.Location) (R : l₀.tyl₁.tyl₂.tyProp) :

                          Relation between three locations on the right

                          Equations
                          Instances For

                            Set Predicates (for writes) #

                            Setting a value on the left, used in put rules

                            Equations
                            Instances For

                              Setting a value on the right, used in put rules

                              Equations
                              Instances For

                                Lemmas #

                                theorem CatCrypt.Invariant.syncsAt_set_both (l : Core.Location) (v : l.ty) (h₀ h₁ : Core.Heap) :
                                syncsAt l (h₀.set l v) (h₁.set l v)
                                theorem CatCrypt.Invariant.rem_lhs_intro (l : Core.Location) (h₀ h₁ : Core.Heap) :
                                rem_lhs l (h₀.get l) h₀ h₁
                                theorem CatCrypt.Invariant.rem_rhs_intro (l : Core.Location) (h₀ h₁ : Core.Heap) :
                                rem_rhs l (h₁.get l) h₀ h₁
                                theorem CatCrypt.Invariant.rem_sync {l : Core.Location} {v : l.ty} {s : Side} {h₀ h₁ : Core.Heap} (hrem : rem_inv s l v h₀ h₁) (hsync : syncsAt l h₀ h₁) :
                                rem_inv s.other l v h₀ h₁

                                If locations are synced and we remember on one side, we can remember the same on the other

                                Proof helpers #

                                Mark that a location coupling is proven by the precondition

                                • holds (h₀ h₁ : Core.Heap) : pre h₀ h₁coupling h₀ h₁
                                Instances
                                  instance CatCrypt.Invariant.ProvenBy_left (coupling inv : Relational.RPre) :
                                  ProvenBy coupling (coupling inv)

                                  If coupling is part of the precondition conjunction, it's proven

                                  instance CatCrypt.Invariant.ProvenBy_right (coupling other inv : Relational.RPre) [ProvenBy coupling inv] :
                                  ProvenBy coupling (other inv)
                                  theorem CatCrypt.Invariant.coupling_from_pre {coupling pre : Relational.RPre} [ProvenBy coupling pre] {h₀ h₁ : Core.Heap} (hpre : pre h₀ h₁) :
                                  coupling h₀ h₁

                                  Helper to extract proven coupling