Skip to content

Commit 0ac8507

Browse files
tmp
1 parent df20e66 commit 0ac8507

File tree

6 files changed

+102
-21
lines changed

6 files changed

+102
-21
lines changed

ArkLib/OracleReduction/Completeness.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ theorem unroll_n_message_reduction_perfectCompleteness
626626

627627
end GenericProtocol
628628

629-
630629
section OneMessageProtocol
631630

632631
variable {oSpec : OracleSpec ι} [oSpec.FiniteRange] {StmtIn WitIn StmtOut WitOut : Type}

ArkLib/OracleReduction/OracleInterface.lean

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,40 @@ def simOracle2 {ι : Type u} (oSpec : OracleSpec ι)
207207
| .inl i => answer (t₁ i)
208208
| .inr i => answer (t₂ i))
209209

210+
/-- simOracle never fails because it is a deterministic transcript lookup. -/
211+
theorem neverFails_simOracle {ι : Type u} (oSpec : OracleSpec ι)
212+
{ι' : Type v} {T : ι' → Type w} [∀ i, OracleInterface (T i)]
213+
(t : ∀ i, T i) :
214+
∀ {β} (q : (oSpec ++ₒ [T]ₒ).OracleQuery β),
215+
((simOracle oSpec t).impl q).neverFails := by
216+
intro β q
217+
unfold simOracle
218+
dsimp [SimOracle.append, fnOracle, idOracle]
219+
cases q with
220+
| query i t' =>
221+
cases i with
222+
| inl i => exact OracleComp.neverFails_query _
223+
| inr i => exact OracleComp.neverFails_pure _
224+
225+
/-- simOracle2 never fails because it is a deterministic transcript lookup. -/
226+
theorem neverFails_simOracle2 {ι : Type u} (oSpec : OracleSpec ι)
227+
{ι₁ : Type v} {T₁ : ι₁ → Type w} [∀ i, OracleInterface (T₁ i)]
228+
{ι₂ : Type v} {T₂ : ι₂ → Type w} [∀ i, OracleInterface (T₂ i)]
229+
(t₁ : ∀ i, T₁ i) (t₂ : ∀ i, T₂ i) :
230+
∀ {β} (q : (oSpec ++ₒ ([T₁]ₒ ++ₒ [T₂]ₒ)).OracleQuery β),
231+
((simOracle2 oSpec t₁ t₂).impl q).neverFails := by
232+
intro β q
233+
unfold simOracle2
234+
dsimp [SimOracle.append, fnOracle, idOracle]
235+
cases q with
236+
| query i t =>
237+
cases i with
238+
| inl i => exact OracleComp.neverFails_query _
239+
| inr i =>
240+
cases i with
241+
| inl i => exact OracleComp.neverFails_pure _
242+
| inr i => exact OracleComp.neverFails_pure _
243+
210244
open Finset in
211245
/-- A message type together with a `OracleInterface` instance is said to have **oracle distance**
212246
(at most) `d` if for any two distinct messages, there is at most `d` queries that distinguish

ArkLib/ProofSystem/Binius/BinaryBasefold/Basic.lean

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ def mkLastOracleIndex (i : Fin (ℓ + 1)) : Fin (toOutCodewordsCount ℓ ϑ i) :
355355
356356

357357
lemma mkLastOracleIndex_last : mkLastOracleIndex ℓ ϑ (Fin.last ℓ) = ℓ / ϑ - 1 := by
358-
dsimp only [mkLastOracleIndex, Fin.val_last, lt_self_iff_false, Lean.Elab.WF.paramLet,
359-
eq_mpr_eq_cast, cast_eq]
358+
dsimp only [mkLastOracleIndex, Fin.val_last, lt_self_iff_false, Lean.Elab.WF.paramLet]
360359
simp only [lt_self_iff_false, ↓reduceDIte]
360+
rfl
361361

362362
end OracleStatementIndex
363363

@@ -773,7 +773,6 @@ lemma take_snoc_oracle_eq_oStmtIn (i : Fin ℓ)
773773
(newOracleFn : OracleFunction 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) i.succ) :
774774
(take_snoc_oracle 𝔽q β i oStmtIn newOracleFn) = oStmtIn := by
775775
unfold take_snoc_oracle snoc_oracle
776-
simp only [eq_mpr_eq_cast, id_eq]
777776
if hi: isCommitmentRound ℓ ϑ i then
778777
simp only [Fin.is_lt, ↓reduceDIte, Fin.eta]
779778
else
@@ -1047,9 +1046,9 @@ lemma oracleWitnessConsistency_relay_preserved
10471046
(stmt : Statement (L := L) Context i.succ)
10481047
(wit : Witness (L := L) 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) i.succ)
10491048
(oStmt : ∀ j, OracleStatement 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ϑ i.castSucc j) :
1050-
oracleWitnessConsistency (mp := mp) (𝓑 := 𝓑) 𝔽q β i.succ i.castSucc
1049+
oracleWitnessConsistency (mp := mp) 𝔽q β i.succ i.castSucc
10511050
(le_succ ↑i.castSucc) stmt wit oStmt =
1052-
oracleWitnessConsistency (mp := mp) (𝓑 := 𝓑) 𝔽q β i.succ i.succ (by rfl) stmt wit
1051+
oracleWitnessConsistency (mp := mp) 𝔽q β i.succ i.succ (by rfl) stmt wit
10531052
(mapOStmtOutRelayStep 𝔽q β i hNCR oStmt) := by
10541053
unfold oracleWitnessConsistency
10551054
-- All four components (witnessStructuralInvariant, sumCheckConsistency,
@@ -1109,13 +1108,12 @@ def masterKStateProp (stmtIdx : Fin (ℓ + 1))
11091108
(wit : Witness (L := L) 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) stmtIdx)
11101109
(oStmt : ∀ j, (OracleStatement 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ϑ (i := oracleIdx) j))
11111110
(localChecks : Prop := True) : Prop :=
1112-
let oracleWitnessConsistency: Prop := oracleWitnessConsistency (mp := mp) (𝓑 := 𝓑) 𝔽q β
1111+
let oracleWitnessConsistency: Prop := oracleWitnessConsistency (mp := mp) 𝔽q β
11131112
stmtIdx oracleIdx h_le stmt wit oStmt
11141113
let badEventExists := badEventExistsProp (ϑ := ϑ) 𝔽q β oracleIdx
11151114
(challenges := Fin.take (m := oracleIdx) (v := stmt.challenges) (h := by omega))
11161115
(oStmt := oStmt)
1117-
let sumCheckConsistency: Prop := sumcheckConsistencyProp (𝓑 := 𝓑) stmt.sumcheck_target wit.H
1118-
localChecks ∧ sumCheckConsistency ∧ (badEventExists ∨ oracleWitnessConsistency)
1116+
localChecks ∧ (badEventExists ∨ oracleWitnessConsistency)
11191117

11201118
def roundRelationProp (i : Fin (ℓ + 1))
11211119
(input : (Statement (L := L) Context i ×
@@ -1124,8 +1122,10 @@ def roundRelationProp (i : Fin (ℓ + 1))
11241122
let stmt := input.1.1
11251123
let oStmt := input.1.2
11261124
let wit := input.2
1127-
masterKStateProp (mp := mp) (𝓑 := 𝓑) 𝔽q β
1128-
(stmtIdx := i) (oracleIdx := i) (h_le := le_refl i) stmt wit oStmt (localChecks := True)
1125+
let sumCheckConsistency: Prop := sumcheckConsistencyProp (𝓑 := 𝓑) stmt.sumcheck_target wit.H
1126+
masterKStateProp 𝔽q β (mp := mp)
1127+
(stmtIdx := i) (oracleIdx := i) (h_le := le_refl i) stmt wit oStmt
1128+
(localChecks := sumCheckConsistency)
11291129

11301130
/-- A modified version of roundRelationProp (i+1) -/
11311131
def foldStepRelOutProp (i : Fin ℓ)
@@ -1135,12 +1135,15 @@ def foldStepRelOutProp (i : Fin ℓ)
11351135
let stmt := input.1.1
11361136
let oStmt := input.1.2
11371137
let wit := input.2
1138-
masterKStateProp (mp := mp) (𝓑 := 𝓑) 𝔽q β
1138+
let sumCheckConsistency: Prop := sumcheckConsistencyProp (𝓑 := 𝓑) stmt.sumcheck_target wit.H
1139+
masterKStateProp 𝔽q β (mp := mp)
11391140
(stmtIdx := i.succ) (oracleIdx := i.castSucc)
1140-
(h_le := Nat.le_of_lt (Fin.castSucc_lt_succ i)) stmt wit oStmt (localChecks := True)
1141+
(h_le := Nat.le_of_lt (Fin.castSucc_lt_succ i)) stmt wit oStmt
1142+
(localChecks := sumCheckConsistency)
11411143

11421144
/-- This is a special case of nonDoomedFoldingProp for `i = ℓ`, where we support
1143-
the consistency between the last oracle `ℓ - ϑ` and the final constant `c` -/
1145+
the consistency between the last oracle `ℓ - ϑ` and the final constant `c`.
1146+
This definition has form similar to masterKState where there is no localChecks. -/
11441147
def finalNonDoomedFoldingProp {h_le : ϑ ≤ ℓ}
11451148
(input : (FinalSumcheckStatementOut (L := L) (ℓ := ℓ) ×
11461149
(∀ j, OracleStatement 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ϑ (Fin.last ℓ) j))) :
@@ -1152,8 +1155,8 @@ def finalNonDoomedFoldingProp {h_le : ϑ ≤ ℓ}
11521155
let k := j.val * ϑ
11531156
have h_k: k = ℓ - ϑ := by
11541157
dsimp only [mkLastOracleIndex, Fin.val_last, lt_self_iff_false, Lean.Elab.WF.paramLet,
1155-
eq_mpr_eq_cast, cast_eq, k, j]
1156-
simp only [lt_self_iff_false, ↓reduceDIte]
1158+
k, j]
1159+
simp only [lt_self_iff_false, ↓reduceDIte, eq_mpr_eq_cast, cast_eq]
11571160
rw [Nat.sub_mul, Nat.one_mul]
11581161
rw [Nat.div_mul_cancel (hdiv.out)]
11591162
let f_k := oStmt j
@@ -1193,7 +1196,7 @@ def foldStepRelOut (i : Fin ℓ) :
11931196
Set ((Statement (L := L) Context i.succ ×
11941197
(∀ j, OracleStatement 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ϑ i.castSucc j)) ×
11951198
Witness (L := L) 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) i.succ) :=
1196-
{ input | foldStepRelOutProp (mp := mp) (𝓑 := 𝓑) 𝔽q β i input}
1199+
{ input | foldStepRelOutProp 𝔽q β (𝓑 := 𝓑) (mp := mp) i input}
11971200

11981201
/-- Relation at step `i` of the CoreInteraction. `∀ i < ℓ, R_i` must hold at the
11991202
beginning of ITERATION `i`. `R_ℓ` must hold after the last iteration and before sending
@@ -1202,7 +1205,7 @@ def roundRelation (i : Fin (ℓ + 1)) :
12021205
Set ((Statement (L := L) Context i ×
12031206
(∀ j, OracleStatement 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ϑ i j)) ×
12041207
Witness (L := L) 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) i) :=
1205-
{ input | roundRelationProp (mp := mp) (𝓑 := 𝓑) 𝔽q β i input}
1208+
{ input | roundRelationProp 𝔽q β (𝓑 := 𝓑) (mp := mp) i input}
12061209

12071210
/-- Relation for final sumcheck step -/
12081211
def finalSumcheckRelOutProp

ArkLib/ProofSystem/Binius/BinaryBasefold/Steps.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ For fold step: sumcheck condition must hold. -/
200200
def foldVerifierCheck (i : Fin ℓ)
201201
(stmtIn : Statement (L := L) Context i.castSucc)
202202
(msg0 : Message (pSpecFold (L := L)) ⟨0, rfl⟩) : Prop :=
203-
msg0.val.eval 0 + msg0.val.eval 1 = stmtIn.sumcheck_target
203+
msg0.val.eval (𝓑 0) + msg0.val.eval (𝓑 1) = stmtIn.sumcheck_target
204204

205205
/-- Pure verifier output computation extracted from foldOracleVerifier.verify (lines 180-184).
206206
What verifier returns after checks pass. -/
@@ -240,7 +240,7 @@ def foldStepLogic (i : Fin ℓ) :
240240

241241
-- 2. Verifier Logic (Using extracted kernels)
242242
verifierCheck := fun s t =>
243-
foldVerifierCheck i s (t.messages ⟨0, rfl⟩)
243+
foldVerifierCheck i s (𝓑 := 𝓑) (t.messages ⟨0, rfl⟩)
244244

245245
verifierOut := fun s t =>
246246
foldVerifierStmtOut i s (t ⟨0, by omega⟩) (t ⟨1, by omega⟩)
@@ -490,7 +490,7 @@ lemma foldStep_is_logic_complete (i : Fin ℓ) :
490490
-- verifierStmtOut.sumcheck_target = msg0.val.eval chal1 (by definition of foldVerifierStmtOut)
491491
-- proverWitOut.H = projectToNextSumcheckPoly witIn.H chal1 (by definition of getFoldProverFinalOutput)
492492
unfold sumcheckConsistencyProp
493-
rw [verifierStmtOut, proverWitOut, proverOutput]
493+
dsimp only [verifierStmtOut, proverWitOut, proverOutput]
494494
simp only [step, foldStepLogic, foldVerifierStmtOut, getFoldProverFinalOutput, transcript]
495495
-- Now we need: msg0.val.eval chal1 = ∑ x, projectedH.val.eval x
496496
-- This follows from projectToNextSumcheckPoly_sum_eq

ArkLib/ToVCVio/Execution.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import VCVio.OracleComp.SimSemantics.SimulateQ
1212
import Mathlib.Data.ENNReal.Basic
1313
import VCVio.OracleComp.DistSemantics.EvalDist
1414
import ArkLib.OracleReduction.OracleInterface
15+
import ArkLib.ToVCVio.StateTLemmas
1516

1617
/-!
1718
## Monad-to-Logic Bridge Lemmas

ArkLib/ToVCVio/StateTLemmas.lean

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/-
2+
Copyright (c) 2025 ArkLib Contributors. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: ArkLib Contributors
5+
-/
6+
7+
import VCVio.OracleComp.OracleComp
8+
9+
/-!
10+
# StateT Helper Lemmas
11+
12+
This file contains simple helper lemmas for `StateT` operations that simplify
13+
reasoning about `run`, `run'`, and monadic operations in the probability monad.
14+
15+
These lemmas are used throughout the execution semantics to unfold stateful
16+
computations into their underlying probability distributions.
17+
-/
18+
19+
universe u v w
20+
21+
namespace StateT
22+
23+
variable {m : Type u → Type v} {σ α β : Type u}
24+
25+
/-- Unfolding lemma for `run'` on `pure`. -/
26+
@[simp]
27+
theorem run'_pure_lib [Monad m] [LawfulMonad m] (x : α) (s : σ) :
28+
(pure x : StateT σ m α).run' s = (pure x : m α) := by
29+
simp only [run', pure, StateT.pure, map_pure]
30+
31+
/-- Unfolding lemma for `run'` on `bind`. -/
32+
@[simp]
33+
theorem run'_bind_lib [Monad m] [LawfulMonad m] (ma : StateT σ m α) (f : α → StateT σ m β) (s : σ) :
34+
(ma >>= f).run' s = ((ma.run s) >>= fun (a, s') => (f a).run' s') := by
35+
simp only [run', bind, StateT.bind, map_bind, run]
36+
37+
/-- Unfolding lemma for `run` on `liftM`. -/
38+
@[simp]
39+
theorem run_liftM_lib [Monad m] [LawfulMonad m] (ma : m α) (s : σ) :
40+
(liftM ma : StateT σ m α).run s = (ma >>= fun a => pure (a, s)) := by
41+
simp only [run, liftM, bind_pure_comp]
42+
rw [map_eq_pure_bind]; rfl
43+
44+
end StateT

0 commit comments

Comments
 (0)