Documentation

GaudisCrypt.FV

fvP: the computed-footprint (free-variables) layer over Footprint #

The probabilistic re-incarnation of the old FV development (now quarantined as CounterExamples/FV.lean), rebased from the deterministic DetermFootprint/Function.End foundation onto Footprint and the Kleisli monoid of sub-probability kernels m → SubProbability m.

It instantiates the generic InductiveFunctionGettersSetters/ReducibleGettersSetters machinery (from Language.Modules.InductiveFunctions) at T := Footprint, giving a syntactic over-approximation fvP of the part of the state a Module/Procedure can read or modify, together with the soundness bound fvP (m.toModule) ≤ fvPMexpr m.

fvP_extend_sup #

theorem GaudisCrypt.kmul_prod_apply {a b : Type} (F G : a × b → SubProbability (a × b)) (x : a × b) :
(F * G) x = G x >>= F

Kleisli product of a × b-kernels in bind form.

instance GaudisCrypt.instNonemptyComplContent {s : Type u_1} {a : Type u_2} [Nonempty s] (lens : Lens a s) :
@[reducible]
def GaudisCrypt.Lens.instContentNonempty {s : Type u_1} {a : Type u_2} [Nonempty s] (lens : Lens a s) :
Equations
  • ⋯ = ⋯
Instances For
    theorem GaudisCrypt.Lens.liftFootprint_iSup {a b : Type} {ι : Sort u_1} (lens : Lens a b) (rs : ι → Footprint a) :
    lens.liftFootprint (⨆ (i : ι), rs i) = ⨆ (i : ι), lens.liftFootprint (rs i)

    Lens.liftFootprint distributes over arbitrary indexed suprema. Generalises Lens.liftFootprint_sup from binary joins to indexed families.

    End of fvP_extend_sup #

    Lens.reduceFootprint_sup #

    End of Lens.reduceFootprint_sup #

    noncomputable def GaudisCrypt.ProgramDenotation.footprint' {s a b : Type} (progs : a → ProgramDenotation s b) :

    Family version of ProgramDenotation.footprint: the supremum of the per-input ranges. Used to give a setter (which is a family a → ProgramDenotation s Unit, one program per written value) a single footprint.

    Equations
    Instances For

      Properties of Lens.reduceFootprint / Lens.liftFootprint needed for the framework instance. #

      lens.liftSubProbability is a monoid homomorphism, and the resulting closure algebra. #

      theorem GaudisCrypt.FVP.updateK_one {a b : Type} (lens : Lens a b) :

      lens.liftSubProbability preserves the identity kernel.

      A diracKer of a localized deterministic update is the updateK of the base diracKer (alias of Lens.liftSubProbability_diracKer, kept under the updateK naming of this file).

      Lens.reduceFootprint is a retraction of Lens.liftFootprint (reduce (extend r) ≤ r): pushing a footprint forward along a lens and pulling it back recovers at most it. Proven in full from updateK being a monoid homomorphism (centralizer_preimage_image_subset).

      theorem GaudisCrypt.FVP.Lens.reduceFootprint_extend {a b : Type} [Nonempty b] (lens : Lens a b) (r : Footprint a) :

      Lens.reduceFootprint is an exact left inverse of Lens.liftFootprint (strengthening Lens.reduceFootprint_extend to equality): every p ∈ r.updates is itself Lens.reduceSubProbability lens (lens.liftSubProbability p, i, o) for the trivial i () = pure β / o _ = pure (), hence lies in the generator set defining Lens.reduceFootprint.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[implicit_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem GaudisCrypt.FVP.fvP_app [ProgramSpec] {A B : Type 1} [IsModule A] [IsModule B] (a : Module.Arr A B) (b : A) :
          fvP (Module.app a b) ≤ fvP a ⊔ fvP b
          theorem GaudisCrypt.FVP.fvP_pair [ProgramSpec] {A B : Type 1} [IsModule A] [IsModule B] (a : A) (b : B) :
          fvP (Module.pair a b) = fvP a ⊔ fvP b

          EasyCrypt's glob A: the getter reading everything the procedure A may touch — the touched_getter of its computed footprint. ={glob A} between two states is (glob A).get σ₁ = (glob A).get σ₂: the states differ only by updates outside fvP_proc A.

          Equations
          Instances For

            Footprint/reduce/lift algebra #

            General footprint, Lens.reduceFootprint and Lens.liftFootprint facts, independent of any particular program spec.

            A chained lens's footprint is the liftFootprint of the inner lens's footprint through the outer lens (generator-level): diracKer ((L.chain v).liftFunction g) is exactly L.liftSubProbability (diracKer (v.liftFunction g)). The chained overwrite is the inner overwrite performed on the L-content and written back.

            theorem GaudisCrypt.liftSubProbability_comm_of_reduce_disj {t s c : Type} {L : Lens s c} {v : Lens t s} {R : Footprint c} (hred : L.reduceFootprint R ≤ v.footprintᶜ) {f : s → SubProbability s} (hf : f ∈ v.footprint.updates) {k : c → SubProbability c} (hk : k ∈ R.updates) :

            The lift of a v.footprint-update commutes with every R-update, when the L-reduction of R is disjoint from v.footprint — the lens-region instance of Footprint.liftSubProbability_comm_reduce_compl.

            theorem GaudisCrypt.reduce_chain_le_compl {t s c : Type} {L : Lens s c} {v : Lens t s} {R : Footprint c} (hred : L.reduceFootprint R ≤ v.footprintᶜ) :

            A chained lens's footprint lies in Rᶜ whenever the inner footprint's L-reduction does: from Lens.reduceFootprint L R ≤ (v.footprint)ᶜ conclude R ≤ ((L.chain v).footprint)ᶜ. Route: flip the goal via le_compl_comm to (L.chain v).footprint ≤ Rᶜ, then show each generator L.liftSubProbability (diracKer (v.liftFunction g)) commutes with every k ∈ R.updates via liftSubProbability_comm_of_reduce_disj.

            theorem GaudisCrypt.globalL_liftSubProbability_pad [ProgramSpec] {l : Type} (f : State → SubProbability State) (g : State) (loc : l) :
            ProcedureState.globalL.liftSubProbability f { global := g, locals := loc } = do let a ← f g pure { global := a, locals := loc }

            globalL.liftSubProbability f applied to a padded state applies f to the global.

            theorem GaudisCrypt.globalL_liftSubProbability_global [ProgramSpec] {l : Type} (f : State → SubProbability State) (w2 : ProcedureState l) {ρ : Type} (x : ρ) :
            (do let s'' ← ProcedureState.globalL.liftSubProbability f w2 pure (x, s''.global)) = do let a ← f w2.global pure (x, a)

            Reading the global out of globalL.liftSubProbability f recovers f on the global.

            A sampled value's footprint is trivial — μ.toProgramDenotation only draws its result, it touches no state, so it lies in ⊥ (mirrors inFootprint_uniform for an arbitrary μ).

            Chained and FromLens footprints #

            Moved here from Footprint.lean: the chain law's nontrivial inclusion — the intermediate bicommutant closure adds nothing — is exactly the Lens.liftFootprint_updates extraction.

            The complement of Lens.fst, as a footprint, is Lens.snd. (Lens.fst).compl has abstract ComplContent type, so this is a footprint equality (via the getter that identifies fst.compl.get with snd.get), not a lens equality.