Documentation

GaudisCrypt.Language.Semantics

General stuff #

@[reducible]
def GaudisCrypt.recursion {a : Type u_2} {b : a → Type u_1} [(x : a) → OmegaCompletePartialOrder (b x)] [(x : a) → OrderBot (b x)] (F : ((x : a) → b x) →𝒄 (x : a) → b x) (x : a) :
b x
Equations
Instances For

    Stateful programs #

    noncomputable def GaudisCrypt.SubProbability.uniformOfFinset {α : Type} (fs : Finset α) (hs : fs.Nonempty) :

    Uniform subprobability over a nonempty finset.

    Equations
    Instances For
      noncomputable def GaudisCrypt.ProgramDenotation.uniformOfFinset {s α : Type} (fs : Finset α) (hs : fs.Nonempty) :

      Uniform sampling over a nonempty finset (used e.g. for "sample without replacement" — uniform over the complement of the values seen so far).

      Equations
      Instances For
        def GaudisCrypt.ProgramDenotation.finalProb {s a : Type} (prog : ProgramDenotation s a) (st : s) (X : Set a) :
        Equations
        Instances For
          def GaudisCrypt.ProgramDenotation.finalProb1 {s a : Type} (prog : ProgramDenotation s a) (st : s) (x : a) :
          Equations
          Instances For
            @[implicit_reducible]
            Equations
            • One or more equations did not get rendered due to their size.
            @[implicit_reducible]
            Equations
            @[implicit_reducible]
            Equations
            • One or more equations did not get rendered due to their size.
            theorem GaudisCrypt.ProgramDenotation.bind_mono {i : Type u_1} {s a b : Type} [Preorder i] (f : i → ProgramDenotation s a) (g : i → a → ProgramDenotation s b) (hf : Monotone f) (hg : Monotone g) :
            Monotone fun (x : i) => f x >>= g x
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem GaudisCrypt.while_unroll {s : Type} (cond : ProgramDenotation s Bool) (body : ProgramDenotation s Unit) :
              while_loop cond body = do let __do_lift ← cond if __do_lift = true then do body while_loop cond body else pure ()

              ProgramDenotation.get/ProgramDenotation.set accept anything that forgets to a Getter/Setter — a Getter/Setter itself, or a full Lens/Variable. The value/state types are outParams recovered from the argument, which sidesteps the Lean 4.30 coercion that no longer fires when the value type is a metavariable.

              Instances
                Instances
                  @[implicit_reducible]
                  Equations
                  @[implicit_reducible]
                  instance GaudisCrypt.instAsGetterLens {a s : Type} :
                  AsGetter (Lens a s) a s
                  Equations
                  @[implicit_reducible]
                  Equations
                  @[implicit_reducible]
                  instance GaudisCrypt.instAsSetterLens {a s : Type} :
                  AsSetter (Lens a s) a s
                  Equations
                  noncomputable def GaudisCrypt.ProgramDenotation.set {T a s : Type} [AsSetter T a s] (v : T) (x : a) :
                  Equations
                  Instances For
                    noncomputable def GaudisCrypt.ProgramDenotation.get {T a s : Type} [AsGetter T a s] (v : T) :
                    Equations
                    Instances For
                      noncomputable def GaudisCrypt.ProgramDenotation.zoom {s t a : Type} (lens : Lens s t) (p : ProgramDenotation s a) :
                      Equations
                      Instances For

                        Monad laws for ProgramDenotation s #

                        theorem GaudisCrypt.ProgramDenotation.bind_assoc {s a b c : Type} (p : ProgramDenotation s a) (f : a → ProgramDenotation s b) (g : b → ProgramDenotation s c) :
                        p >>= f >>= g = p >>= fun (x : a) => f x >>= g
                        theorem GaudisCrypt.ProgramDenotation.pure_bind {s a b : Type} (x : a) (f : a → ProgramDenotation s b) :
                        pure x >>= f = f x
                        theorem GaudisCrypt.ProgramDenotation.bind_bot {s a b : Type} (m : ProgramDenotation s a) :
                        (do let _ ← m ⊥) = ⊥

                        zoom is a monad morphism #

                        theorem GaudisCrypt.ProgramDenotation.zoom_pure {s t a : Type} (lens : Lens s t) (x : a) :
                        zoom lens (pure x) = pure x
                        theorem GaudisCrypt.ProgramDenotation.zoom_bind {s t a b : Type} (lens : Lens s t) (p : ProgramDenotation s a) (k : a → ProgramDenotation s b) :
                        zoom lens (p >>= k) = do let a ← zoom lens p zoom lens (k a)