Documentation

GaudisCrypt.Logic.ByPrEquiv

EasyCrypt's bypr, on equiv judgments #

EC's bypr (res{1}) (res{2}) proves that two procedures return the same result,

equiv[ p₁ ~ p₂ : P ==> ={res} ]

from the equality of the probabilities of each result,

∀ a₁ &1 a₂ &2 v, P → Pr[ p₁ (a₁) @ &1 : res = v ] = Pr[ p₂ (a₂) @ &2 : res = v ]

(prhlProc_res_of_Pr_eq). The coupling is not built by hand: two programs whose results have the same distribution are related by the wp-lifting for the relation "the same result" (ProgramDenotation.rel_fst_of_wp_eq), and the wp-lifting gives a coupling (discrete Strassen: ProgramDenotation.relE.to_prhl2).

theorem GaudisCrypt.SubProbability.expected_fst_eq_tsum {α : Type v} {S : Type (max u v)} (μ : SubProbability (α × S)) (k : α → ENNReal) :
(μ.expected fun (x : α × S) => k x.1) = ∑' (a : α), k a * μ.expected fun (x : α × S) => indicatorE (x.1 = a)

The expected value of a function of the result: the sum, over the results, of its value times the probability of the result.

theorem GaudisCrypt.ProgramDenotation.rel_fst_of_wp_eq {s₁ s₂ : Type (max u v)} {α : Type v} {A : s₁ → s₂ → Prop} {c : ProgramDenotation s₁ α} {d : ProgramDenotation s₂ α} (h : ∀ (σ₁ : s₁) (σ₂ : s₂), A σ₁ σ₂ → ∀ (a : α), ((c σ₁).expected fun (x : α × s₁) => indicatorE (x.1 = a)) = (d σ₂).expected fun (y : α × s₂) => indicatorE (y.1 = a)) :
c.rel d A fun (x : α × s₁) (y : α × s₂) => x.1 = y.1

Programs whose results have the same distribution are related, in the wp-lifting, by "the same result".

theorem GaudisCrypt.ProgramDenotation.prhl2_fst_of_wp_eq {s₁ s₂ : Type (max u v)} {α : Type v} {A : s₁ → s₂ → Prop} {c : ProgramDenotation s₁ α} {d : ProgramDenotation s₂ α} (h : ∀ (σ₁ : s₁) (σ₂ : s₂), A σ₁ σ₂ → ∀ (a : α), ((c σ₁).expected fun (x : α × s₁) => indicatorE (x.1 = a)) = (d σ₂).expected fun (y : α × s₂) => indicatorE (y.1 = a)) :
prhl2 A c d fun (x : α × s₁) (y : α × s₂) => x.1 = y.1

Programs whose results have the same distribution can be coupled on "the same result".

theorem GaudisCrypt.prhlProc_res_of_Pr_eq {ps₁ ps₂ : List Type} {α : Type} {A : (ProcedureSignature.mk ps₁ α).ParamType → VariableAssignment → (ProcedureSignature.mk ps₂ α).ParamType → VariableAssignment → Prop} {p₁ : Procedure (ProcedureSignature.mk ps₁ α)} {p₂ : Procedure (ProcedureSignature.mk ps₂ α)} (h : ∀ (a₁ : (ProcedureSignature.mk ps₁ α).ParamType) (σ₁ : VariableAssignment) (a₂ : (ProcedureSignature.mk ps₂ α).ParamType) (σ₂ : VariableAssignment) (v : α), A a₁ σ₁ a₂ σ₂ → ↑(p₁.Pr a₁ σ₁ fun (r : (ProcedureSignature.mk ps₁ α).ret) (x : VariableAssignment) => r = v) = ↑(p₂.Pr a₂ σ₂ fun (r : (ProcedureSignature.mk ps₂ α).ret) (x : VariableAssignment) => r = v)) :
prhlProc A p₁ p₂ fun (r₁ : (ProcedureSignature.mk ps₁ α).ret) (x : VariableAssignment) (r₂ : (ProcedureSignature.mk ps₂ α).ret) (x_1 : VariableAssignment) => r₁ = r₂

EC's bypr (res{1}) (res{2}): two procedures with the same result type return the same result (under a coupling) when each result has the same probability on the two sides.

EC's bypr (res{1}) (res{2}) on equiv[ p₁ ~ p₂ : P ==> ={res} ]: the goal becomes ∀ a₁ &1 a₂ &2 v, P → Pr[ p₁ (a₁) @ &1 : res = v ] = Pr[ p₂ (a₂) @ &2 : res = v ] (EC's goal after bypr … => &1 &2 v: the arguments, the memories and the value are introduced by intro).

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