Concrete syntax for relational judgments (pRHL) #
EasyCrypt's equiv judgments, in the two forms of hoare[ … ] (Syntax/HoareSyntax.lean):
equiv[ P ==> Q ] { var x : X; … } ~ { var y : Y; … } -- prhlStmt, about two statements
equiv[ M₁ (x) ~ M₂ (y) : P ==> Q ] -- prhlProc, about two procedures
The conditions are about two states, and every read says which: §x{1} reads x in the
left state, §x{2} in the right one (EC's x{1}, x{2}); ={x, y} is §x{1} = §x{2} ∧ §y{1} = §y{2} (EC's ={x, y}). A read without a side (§x, $x) is an error in a relational
condition.
In the statement form, each side may declare its local variables; a condition sees those of both
sides (a name declared on both sides must have the same type there). In the procedure form, the
precondition sees each side's parameters and globals, the postcondition each side's result res
and globals: §res{1} = §res{2}, §x{1} for the left parameter x. As for hoare[ M (x) : … ],
the parameter names may be left out when they are recorded.
The sided reads are expanded when the condition is elaborated: §x{1} becomes
@eval _ _ _ (CurrentState.mk σ₁) x, a read at the left state σ₁ the condition is a function
of — the read §x of a hoare[ ] condition, at a given state. So the reads are what the
unary tactics already handle (simpReads, generalizeReads). (No printer yet: a relational
judgment prints as the plain term.)
§x{1}, §x{2}: the value of the program variable x in the left or the right state of a
relational condition (equiv[ … ]).
Equations
- One or more equations did not get rendered due to their size.
Instances For
={x, y}: x and y agree on the two sides of a relational condition (EC's ={x, y}).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The read of the program variable x at the state st: what §x means where st is the
current state.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Expand the sided reads of a relational condition: §x{i} ↦ a read at states i — of the
term param i x instead if that gives one (the parameters of a procedure judgment) — and
={x, y} ↦ the equations. Unsided reads are rejected.
The letI bindings of the local variables of the two sides: their union, a name declared on
both sides with the same type bound once. A name declared with one type on the left and another
on the right (as inlining leaves them) is not in the union: it is two variables, returned with
their sides, and a read §x{i} means the one of side i.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The local variables a var …; block declares.
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
Procedure judgments #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Printing #
prhlStmt A c₁ c₂ B prints as equiv[ P ==> Q ] { … } ~ { … } when both statements print as
statements and both conditions are functions of the two states that only read them: a read
§x at the left state (eval at CurrentState.mk σ₁, x.get σ₁, g.get σ₁.globals for a
global g) prints as §x{1}, at the right state as §x{2}. Otherwise the judgment prints as
the plain term. The reads are first replaced by relRead σ i x (the read, carrying its side),
which the unexpander prints as §x{i}; the variables are recovered over the two statements and
the two conditions together, each declared on the side whose statement uses it (the left one if
only the conditions do).
The read of x at the state σ of side i of a relational condition — §x{i}. Only the
printer builds it; it is the read Evaluatable.eval σ x.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The getter of the globals of the module A — glob A. Only the printer builds it.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
={x} for §x{1} = §x{2}, and ={x, y} for the conjunction of ={x} and ={y}: what
the parser reads ={x, y} as (the equations, joined to the right). Two globs are not put in
one ={…}: ={glob A, glob B} is read as one equation, on the two regions joined. On the
syntax of a printed condition, before it is parenthesized.
Replace the reads of the state σ in e by relRead σ i x: eval at CurrentState.mk σ,
x.get σ, g.get σ.globals for a global g, and σ.globals itself (§allGlobals).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A relational condition fun σ₁ σ₂ => P with its reads marked (markReads).
Equations
- One or more equations did not get rendered due to their size.
- GaudisCrypt.markCond c = failure
Instances For
The terms of a relational judgment prhlStmt A c₁ c₂ B by side, for
ProgramSyntax.frameVarsSided: all of them, then each side's program with what the conditions
read on that side.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Print a marked relational condition fun σ₁ σ₂ => P as P.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The procedure form #
prhlProc A p₁ p₂ B prints as equiv[ M₁ (x) ~ M₂ (y) : P ==> Q ] when both conditions have the
shape the elaborator builds: fun args₁ σ₁ args₂ σ₂ => let x_1 := …; …; P, one Getter.mk
let per parameter of each side (named x_1/x_2, res_1/res_2 in the postcondition), and
the reads at ⟨σᵢ, VariableAssignment.init⟩. The two sides' getters of a name print as the one
variable x, the side in the read (§x{1}).