Documentation

GaudisCrypt.Syntax.PHoareSyntax

Concrete syntax for probabilistic Hoare judgments #

The two forms of hoare[ … ] (Syntax/HoareSyntax.lean), with a relation and a bound after the bracket:

phoare[ P ==> Q ] = r { … }             -- phoareStmt, about a statement
phoare[ M (x, y) : P ==> Q ] <= r       -- phoareProc, about a procedure

The relation is =, <=/≤ or >=/≥. The bound r is parsed at term:max, so anything but an atom needs parentheses (= (1/2)), as in EasyCrypt; it is an ENNReal expression read like the precondition (it may mention the parameters and the globals, or for the statement form the program state).

The postcondition Q is either an event or an expectation: a Prop is the event, and the judgment is about its indicator indicatorE Q (EC's phoare); an ENNReal expression is the expectation itself. The elaborator tries the event first. An indicator indicatorE Q prints as Q, so both round-trip.

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

    The relation a phoare_rel token stands for, at ENNReal.

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

      Statement judgments #

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

        Elaborate mk post, the judgment with the postcondition read as an event (indicatorE); if that fails, with the postcondition read as an expectation.

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

          Procedure judgments #

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

            Printing #

            The relation token for ρ, if it is one of the three.

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

              A postcondition indicatorE Q prints as the event Q.

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

                The bound, parenthesized unless it is an atom (it is parsed at term:max).

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

                  From a procedure judgment to a statement judgment #

                  phoareProc_as_phoareStmt as a conversion, exactly as hoareProcToStmt does it for Hoare triples: one local variable per parameter, one for the result, so that the goal prints as

                  phoare[ P ==> Q ] ⋈ r { var res : R, x : X; res <- call p (§x); }
                  

                  phoareProc A p G ρ r ↦ the phoareStmt about res <- call p (x₁, …, xₙ);, and the proof of the equation (see hoareProcToStmt).

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

                    Rewrite a goal phoareProc A p G ρ r to the phoareStmt about res <- call p (x₁, …, xₙ);, one local variable per parameter.

                    Equations
                    Instances For