Skip to content

Commit 6bd8f34

Browse files
committed
cleanup legacy comments and restore CountingOracle support lemmas
1 parent 01e4f41 commit 6bd8f34

File tree

4 files changed

+284
-333
lines changed

4 files changed

+284
-333
lines changed

VCVio/CryptoFoundations/AsymmEncAlg.lean

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ def CorrectExp (msg : M) : m Bool := do
5353
def PerfectlyCorrect [HasEvalSPMF m] : Prop :=
5454
∀ (msg : M), Pr[= true | encAlg.exec (encAlg.CorrectExp msg)] = 1
5555

56-
-- Old definitions (used `guard` + `AlternativeMonad`, which is now `OptionT`):
57-
-- @[reducible, inline]
58-
-- def CorrectExp (encAlg : AsymmEncAlg m M PK SK C) (msg : M) :
59-
-- ProbComp Unit := encAlg.exec do
60-
-- let (pk, sk) ← encAlg.keygen
61-
-- guard (encAlg.decrypt sk (← encAlg.encrypt pk msg) = msg)
62-
--
63-
-- def PerfectlyCorrect (encAlg : AsymmEncAlg m M PK SK C) : Prop :=
64-
-- ∀ (msg : M), [⊥ | CorrectExp encAlg msg] = 0
65-
6656
end Correct
6757

6858
section IND_CPA_Oracle
@@ -112,25 +102,6 @@ noncomputable def IND_CPA_advantage {encAlg : AsymmEncAlg ProbComp M PK SK C}
112102
(adversary : encAlg.IND_CPA_adversary) : ℝ≥0∞ :=
113103
Pr[= true | IND_CPA_experiment adversary] - 1 / 2
114104

115-
-- Old lemma (uses guard-based experiment, needs rework for Bool-valued version):
116-
-- /-- The probability of the IND-CPA experiment is the average of the probability of the experiment
117-
-- with the challenge being true and the probability of the experiment with the challenge being false. -/
118-
-- lemma probOutput_IND_CPA_experiment_eq_add {encAlg : AsymmEncAlg ProbComp M PK SK C}
119-
-- (adversary : encAlg.IND_CPA_adversary) :
120-
-- [= () | IND_CPA_experiment adversary] =
121-
-- [= () | do
122-
-- let (pk, _sk) ← encAlg.keygen
123-
-- let b ← (simulateQ (encAlg.IND_CPA_queryImpl' pk true) (adversary pk)).run' ∅
124-
-- guard b] / 2 +
125-
-- [= () | do
126-
-- let (pk, _sk) ← encAlg.keygen
127-
-- let b ← (simulateQ (encAlg.IND_CPA_queryImpl' pk false) (adversary pk)).run' ∅
128-
-- guard ¬b] / 2 := by
129-
-- unfold IND_CPA_experiment
130-
-- rw [probOutput_bind_eq_sum_finSupport]
131-
-- have {x : ℝ≥0∞} : 2⁻¹ * x = x / 2 := by field_simp; rw [mul_comm, mul_div, mul_one]
132-
-- simp [this]
133-
134105
end IND_CPA_Oracle
135106

136107
section decryptionOracle

VCVio/CryptoFoundations/HardnessAssumptions/LWE.lean

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,3 @@ noncomputable def SearchAdvantage (n m p : ℕ) [NeZero p] (errSamp : ProbComp (
9292
(SearchExperiment n m p errSamp adv).advantage'
9393

9494
end LWE
95-
96-
/-! ## Old commented code (for reference)
97-
98-
-- variable (n m p : ℕ) [NeZero p] (errSamp : ProbComp (Fin p))
99-
100-
-- def LWE_Distr : ProbComp (Matrix (Fin n) (Fin m) (Fin p) × Vector (Fin p) m) := do
101-
-- let A ←$ᵗ Matrix (Fin n) (Fin m) (Fin p)
102-
-- let s ←$ᵗ Vector (Fin p) n
103-
-- let e ← (Vector.Range m).mapM (fun _ ↦ errSamp)
104-
-- let u := A.vecMul s.get + e.get
105-
-- return (A, Vector.ofFn u)
106-
107-
-- (... rest of old LWE code preserved in git history ...)
108-
-/

VCVio/OracleComp/OracleComp.lean

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ def isPure {α : Type _} : OracleComp spec α → Bool
195195
@[simp] lemma pure_ne_query : (pure u : OracleComp spec _) ≠ query t := by simp [query_def]
196196
@[simp] lemma query_ne_pure : (query t : OracleComp spec _) ≠ pure u := by simp [query_def]
197197

198-
-- @[simp] lemma pure_ne_query_bind : pure x ≠ (query t : OracleComp spec _) >>= ou := fun h => by
199-
-- simp [query_def, OracleComp.bind_def] at h
200-
-- @[simp] lemma query_bind_ne_pure : (query t : OracleComp spec _) >>= ou ≠ pure x := fun h => by
201-
-- simp [query_def, OracleComp.bind_def] at h
202-
203198
lemma pure_eq_query_iff_false : pure u = (query t : OracleComp spec _) ↔ False := by simp
204199
lemma query_eq_pure_iff_false : (query t : OracleComp spec _) = pure u ↔ False := by simp
205200

@@ -224,14 +219,6 @@ section inj
224219
@[simp] lemma pure_inj (x y : α) : pure (f := OracleComp spec) x = pure y ↔ x = y :=
225220
PFunctor.FreeM.pure_inj x y
226221

227-
-- /-- Doing something with a query result is equal iff they query the same oracle
228-
-- and perform identical computations on the output. -/
229-
-- @[simp] lemma queryBind_inj (t t' : spec.Domain) (ob : spec.Range t → OracleComp spec β)
230-
-- (ob' : spec.Range t' → OracleComp spec β) :
231-
-- (query t : OracleComp spec _) >>= ob = (query t' : OracleComp spec _) >>= ob' ↔
232-
-- ∃ h : t = t', h ▸ ob = ob' := by
233-
-- convert PFunctor.FreeM.roll_inj t t' ob ob'
234-
235222
/-- Binding two computations gives a pure operation iff the first computation is pure
236223
and the second computation does something pure with the result. -/
237224
@[simp] lemma bind_eq_pure_iff (oa : OracleComp spec α) (ob : α → OracleComp spec β) (y : β) :
@@ -252,34 +239,4 @@ alias ⟨_, pure_eq_bind⟩ := pure_eq_bind_iff
252239

253240
end inj
254241

255-
-- /-- If the oracle indexing-type `ι`, output type `α`, and domains of all oracles have
256-
-- `DecidableEq` then `OracleComp spec α` also has `DecidableEq`. -/
257-
-- protected instance instDecidableEq [spec.Fintype] [hd : DecidableEq (spec.Domain)]
258-
-- [hι : DecidableEq ι] [h : DecidableEq α] : DecidableEq (OracleComp spec α) := fun
259-
-- | _ => sorry
260-
-- | FreeMonad.pure (Option.some x), FreeMonad.pure (Option.some y) =>
261-
-- match h x y with
262-
-- | isTrue rfl => isTrue rfl
263-
-- | isFalse h => isFalse λ h' ↦ h (by rwa [FreeMonad.pure.injEq, Option.some_inj] at h')
264-
-- | FreeMonad.pure Option.none, FreeMonad.pure (Option.some y) => isFalse λ h ↦
265-
-- Option.some_ne_none y (by rwa [FreeMonad.pure.injEq, eq_comm] at h)
266-
-- | FreeMonad.pure (Option.some x), FreeMonad.pure Option.none => isFalse λ h ↦
267-
-- Option.some_ne_none x (by rwa [FreeMonad.pure.injEq] at h)
268-
-- | FreeMonad.pure Option.none, FreeMonad.pure Option.none => isTrue rfl
269-
-- | FreeMonad.pure x, FreeMonad.roll q r => isFalse <| by simp
270-
-- | FreeMonad.roll q r, FreeMonad.pure x => isFalse <| by simp
271-
-- | FreeMonad.roll (OracleQuery.query i t) r, FreeMonad.roll (OracleQuery.query i' t') s =>
272-
-- match hι i i' with
273-
-- | isTrue h => by
274-
-- induction h
275-
-- rw [FreeMonad.roll.injEq, heq_eq_eq, OracleQuery.query.injEq, eq_self, true_and, heq_eq_eq]
276-
-- refine @instDecidableAnd _ _ (hd i t t') ?_
277-
-- suffices Decidable (∀ u, r u = s u) from decidable_of_iff' _ funext_iff
278-
-- suffices ∀ u, Decidable (r u = s u) from Fintype.decidableForallFintype
279-
-- exact λ u ↦ OracleComp.instDecidableEq (r u) (s u)
280-
-- | isFalse h => isFalse λ h' ↦ h <|
281-
-- match FreeMonad.roll.inj h' with
282-
-- | ⟨h1, h2, _⟩ => @congr_heq _ _ ι OracleQuery.index OracleQuery.index
283-
-- (query i t) (query i' t') (h1 ▸ HEq.rfl) h2
284-
285242
end OracleComp

0 commit comments

Comments
 (0)