Documentation

CatCryptCore.Nominal.NomPackage

Nominal Packages #

This file defines nominal packages - packages equipped with nominal structure (atom support) enabling separated composition.

Main definitions #

Overview #

In nominal CatCrypt, packages are given a nominal structure where atoms represent abstract memory locations. The key insight is that:

  1. Each package has a finite support (the atoms/locations it uses)
  2. Packages with disjoint supports can be composed without interference
  3. The "move" operation can rename atoms to achieve disjoint supports

References #

A nominal package: a raw package together with its atom support. The support represents the abstract locations/names the package uses.

Instances For
    theorem CatCrypt.Nominal.NomPackage.ext {P₁ P₂ : NomPackage} (hRaw : P₁.raw = P₂.raw) (hSupp : P₁.support = P₂.support) :
    P₁ = P₂
    theorem CatCrypt.Nominal.NomPackage.ext_iff {P₁ P₂ : NomPackage} :
    P₁ = P₂ P₁.raw = P₂.raw P₁.support = P₂.support

    Empty nominal package with empty support

    Equations
    Instances For

      Get the support of a nominal package

      Equations
      Instances For

        An atom is fresh for a package if it's not in the support

        Equations
        Instances For

          Two nominal packages are disjoint if their supports are disjoint

          Equations
          Instances For
            noncomputable def CatCrypt.Nominal.NomPackage.sep (P₁ P₂ : NomPackage) (_hDisj : P₁.Disjoint P₂) (hIds : P₁.raw.Disjoint P₂.raw) :

            Separated composition: compose two packages with disjoint supports. This is the key operation for nominal reasoning - packages that use different atoms can be composed without interference.

            Equations
            Instances For
              theorem CatCrypt.Nominal.NomPackage.sep_support (P₁ P₂ : NomPackage) (hDisj : P₁.Disjoint P₂) (hIds : P₁.raw.Disjoint P₂.raw) :
              (P₁.sep P₂ hDisj hIds).support = P₁.support P₂.support
              noncomputable def CatCrypt.Nominal.NomPackage.par (P₁ P₂ : NomPackage) (hIds : P₁.raw.Disjoint P₂.raw) :

              Parallel composition without disjointness proof (using trivially empty supports). This is a fallback when support information isn't needed.

              Equations
              Instances For
                noncomputable def CatCrypt.Nominal.NomPackage.singleton (id : ) (S T : Type) (f : SCore.SPComp T) (support : Finset Atom := ) :

                Create a singleton nominal package with given support. S and T are restricted to Type (not Type*) to match the underlying RawPackage.singleton constraint.

                Equations
                Instances For

                  Rename atoms in a package using a finite permutation. This changes the support according to the permutation.

                  WARNING: This only renames the support, NOT the underlying code. The RawPackage stores S → SPComp T functions that have no notion of atom/location identity, so there is nothing to rename inside the code.

                  For actual code renaming, use the deep embedding layer where RawCode has explicit location references that can be permuted via RawCode.renameLocations.

                  Equations
                  Instances For

                    Separated composition properties #

                    theorem CatCrypt.Nominal.NomPackage.sep_comm (P₁ P₂ : NomPackage) (hDisj : P₁.Disjoint P₂) (hIds : P₁.raw.Disjoint P₂.raw) (hIds' : P₂.raw.Disjoint P₁.raw) :
                    (P₁.sep P₂ hDisj hIds).support = (P₂.sep P₁ hIds').support

                    Separated composition is commutative (up to raw package commutativity)

                    theorem CatCrypt.Nominal.NomPackage.rename_fresh (P : NomPackage) (a b : Atom) (ha : Fresh a P) (hb : Fresh b P) :

                    Fresh atoms don't affect packages under renaming

                    NominalAction and NomSet instances #

                    @[implicit_reducible]

                    NomPackage has a nominal action: permutations act on the support

                    Equations
                    • One or more equations did not get rendered due to their size.
                    @[implicit_reducible]

                    NomPackage is a nominal set

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

                    Alpha-equivalence for packages #

                    Alpha-equivalence for NomPackage: two packages are equivalent if they differ only by a permutation

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

                        Alpha-equivalence is reflexive

                        theorem CatCrypt.Nominal.NomPackage.AlphaEquiv.symm {P₁ P₂ : NomPackage} (h : P₁ ≡αP P₂) :
                        P₂ ≡αP P₁

                        Alpha-equivalence is symmetric

                        theorem CatCrypt.Nominal.NomPackage.AlphaEquiv.trans {P₁ P₂ P₃ : NomPackage} (h₁₂ : P₁ ≡αP P₂) (h₂₃ : P₂ ≡αP P₃) :
                        P₁ ≡αP P₃

                        Alpha-equivalence is transitive

                        Package algebra laws #

                        theorem CatCrypt.Nominal.NomPackage.RawPackage.par_comm (P₁ P₂ : Package.RawPackage) (hIds : P₁.Disjoint P₂) (hIds' : P₂.Disjoint P₁) :
                        (P₁.par P₂ hIds).entries = (P₂.par P₁ hIds').entries

                        Raw package parallel composition is commutative up to alpha-equivalence.

                        This theorem states that the underlying raw packages have the same entries (though possibly in different order in the union).

                        theorem CatCrypt.Nominal.NomPackage.sep_comm_eq (P₁ P₂ : NomPackage) (hDisj : P₁.Disjoint P₂) (hIds : P₁.raw.Disjoint P₂.raw) (hIds' : P₂.raw.Disjoint P₁.raw) :
                        P₁.sep P₂ hDisj hIds = P₂.sep P₁ hIds'

                        Commutativity of separated composition for NomPackage.

                        When two packages have disjoint supports, their separated composition is equal (not just alpha-equivalent) because:

                        • The raw packages combine with union (which is commutative)
                        • The supports combine with union (which is commutative)
                        theorem CatCrypt.Nominal.NomPackage.sep_comm_alpha (P₁ P₂ : NomPackage) (hDisj : P₁.Disjoint P₂) (hIds : P₁.raw.Disjoint P₂.raw) (hIds' : P₂.raw.Disjoint P₁.raw) :
                        P₁.sep P₂ hDisj hIds ≡αP P₂.sep P₁ hIds'

                        Commutativity of separated composition up to alpha-equivalence

                        theorem CatCrypt.Nominal.NomPackage.sep_assoc_eq (P₁ P₂ P₃ : NomPackage) (hDisj₁₂ : P₁.Disjoint P₂) (hDisj₂₃ : P₂.Disjoint P₃) (hDisj₁₃ : P₁.Disjoint P₃) (hIds₁₂ : P₁.raw.Disjoint P₂.raw) (hIds₂₃ : P₂.raw.Disjoint P₃.raw) (hIds₁₃ : P₁.raw.Disjoint P₃.raw) (hIds₁₂₃_left : (P₁.raw.par P₂.raw hIds₁₂).Disjoint P₃.raw) (hIds₁₂₃_right : P₁.raw.Disjoint (P₂.raw.par P₃.raw hIds₂₃)) (hDisj₁₂_₃ : (P₁.sep P₂ hDisj₁₂ hIds₁₂).Disjoint P₃) (hDisj₁_₂₃ : P₁.Disjoint (P₂.sep P₃ hDisj₂₃ hIds₂₃)) :
                        (P₁.sep P₂ hDisj₁₂ hIds₁₂).sep P₃ hDisj₁₂_₃ hIds₁₂₃_left = P₁.sep (P₂.sep P₃ hDisj₂₃ hIds₂₃) hDisj₁_₂₃ hIds₁₂₃_right

                        Associativity of separated composition (equality version).

                        For three packages with mutually disjoint supports, separated composition is associative.

                        theorem CatCrypt.Nominal.NomPackage.sep_assoc_alpha (P₁ P₂ P₃ : NomPackage) (hDisj₁₂ : P₁.Disjoint P₂) (hDisj₂₃ : P₂.Disjoint P₃) (hDisj₁₃ : P₁.Disjoint P₃) (hIds₁₂ : P₁.raw.Disjoint P₂.raw) (hIds₂₃ : P₂.raw.Disjoint P₃.raw) (hIds₁₃ : P₁.raw.Disjoint P₃.raw) (hIds₁₂₃_left : (P₁.raw.par P₂.raw hIds₁₂).Disjoint P₃.raw) (hIds₁₂₃_right : P₁.raw.Disjoint (P₂.raw.par P₃.raw hIds₂₃)) (hDisj₁₂_₃ : (P₁.sep P₂ hDisj₁₂ hIds₁₂).Disjoint P₃) (hDisj₁_₂₃ : P₁.Disjoint (P₂.sep P₃ hDisj₂₃ hIds₂₃)) :
                        (P₁.sep P₂ hDisj₁₂ hIds₁₂).sep P₃ hDisj₁₂_₃ hIds₁₂₃_left ≡αP P₁.sep (P₂.sep P₃ hDisj₂₃ hIds₂₃) hDisj₁_₂₃ hIds₁₂₃_right

                        Associativity of separated composition up to alpha-equivalence

                        Simplified versions with automatic disjointness #

                        theorem CatCrypt.Nominal.NomPackage.sep_disjoint_right (P₁ P₂ P₃ : NomPackage) (hDisj₁₂ : P₁.Disjoint P₂) (hIds₁₂ : P₁.raw.Disjoint P₂.raw) (hDisj₁₃ : P₁.Disjoint P₃) (hDisj₂₃ : P₂.Disjoint P₃) :
                        (P₁.sep P₂ hDisj₁₂ hIds₁₂).Disjoint P₃

                        Disjointness of sep's support with a third package

                        theorem CatCrypt.Nominal.NomPackage.disjoint_sep_left (P₁ P₂ P₃ : NomPackage) (hDisj₂₃ : P₂.Disjoint P₃) (hIds₂₃ : P₂.raw.Disjoint P₃.raw) (hDisj₁₂ : P₁.Disjoint P₂) (hDisj₁₃ : P₁.Disjoint P₃) :
                        P₁.Disjoint (P₂.sep P₃ hDisj₂₃ hIds₂₃)

                        Disjointness of a package with sep's support