import Mathlib import OAI.Probability.LogConcave.OraclePrograms.RoutineKind import OAI.Probability.LogConcave.Numerics.CompileDeclaredRootShift import OAI.Probability.LogConcave.OraclePrograms.TerminalMeanProgram import OAI.Probability.LogConcave.Sampling.SampleCorrelation namespace OAI section noncomputable section namespace LogConcaveSampling.OracleCompiler open MeanTree Quadrature open scoped Classical structure CircuitParameters where n : ℕ m : ℕ N : ℕ nc : ℕ Nc : ℕ T : ℝ h : ℝ ψ : ℝ v : ℝ D : ℝ A : ℝ Af : ℝ T_lower : 1/2≤T T_upper : T<1 h_pos : 0 ℝ → ℝ → SeedProgram d | .sample => ℝ → ℝ → ReservedProgram d def constructRoutine (d : ℕ) (C : CircuitParameters) {t : ℝ} (ht : 0 terminalMeanProgram d | .sample => terminalReservedProgram d else match hk : L.kind with | .mean => C.meanFrom (constructRoutine d C ht hs ⟨.mean,L.b+t,L.p⟩) (constructRoutine d C ht hs ⟨.mean,L.b-10*t,L.p-1/4⟩) (constructRoutine d C ht hs ⟨.sample,L.b-10*t,L.p-1/4⟩) | .sample => C.sampleFrom (constructRoutine d C ht hs ⟨.mean,L.b,L.p⟩) (constructRoutine d C ht hs ⟨.mean,L.b-10*t,L.p-1/4⟩) termination_by L.rank t decreasing_by all_goals apply RoutineStep.rank_lt ht hs (by assumption) · simpa only [←hk] using (RoutineStep.meanFinal (t:=t) L.b L.p) · simpa only [←hk] using (RoutineStep.internal (t:=t) RoutineKind.mean RoutineKind.mean L.b L.p) · simpa only [←hk] using (RoutineStep.internal (t:=t) RoutineKind.mean RoutineKind.sample L.b L.p) · simpa only [←hk] using (RoutineStep.sampleFinal (t:=t) L.b L.p) · simpa only [←hk] using (RoutineStep.internal (t:=t) RoutineKind.sample RoutineKind.mean L.b L.p) end LogConcaveSampling.OracleCompiler end end end OAI