introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.5 kB
import Mathlib
namespace OAI
section
noncomputable section
namespace LogConcaveSampling.OracleCompiler
open scoped Classical
inductive RoutineKind where
| mean | sample
deriving DecidableEq
structure RoutineLabel where
kind : RoutineKind
b : ℝ
p : ℝ
def RoutineLabel.terminal (L : RoutineLabel) : Prop := L.p≀L.b
inductive RoutineStep (t : ℝ) : RoutineLabel β†’ RoutineLabel β†’ Prop where
| meanFinal (b p : ℝ) : RoutineStep t ⟨.mean,b,p⟩ ⟨.mean,b+t,p⟩
| sampleFinal (b p : ℝ) : RoutineStep t ⟨.sample,b,p⟩ ⟨.mean,b,p⟩
| internal (k k' : RoutineKind) (b p : ℝ) :
RoutineStep t ⟨k,b,p⟩ ⟨k',b-10*t,p-1/4⟩
def RoutineLabel.rank (t : ℝ) (L : RoutineLabel) : β„• :=
2*⌈(L.p-L.b)/tβŒ‰β‚Š+(match L.kind with | .mean => 0 | .sample => 1)
lemma ceil_gap_drop {t x y : ℝ} (ht : 0<t) (hx : 0<x) (hy : y≀x-t) :
⌈y/tβŒ‰β‚Š<⌈x/tβŒ‰β‚Š := by
have hp : 0<x/t := div_pos hx ht
have hxy : y/t≀x/t-1 := by
simpa only [sub_div,div_self ht.ne'] using (div_le_div_of_nonneg_right hy ht.le)
have hn : 0<⌈x/tβŒ‰β‚Š := Nat.ceil_pos.mpr hp
have hc := Nat.le_ceil (x/t)
have hm : y/t≀(⌈x/tβŒ‰β‚Š-1:β„•) := by
rw [Nat.cast_sub (by omega : 1β‰€βŒˆx/tβŒ‰β‚Š),Nat.cast_one]
linarith
exact lt_of_le_of_lt (Nat.ceil_le.mpr hm) (Nat.sub_lt hn (by omega))
lemma RoutineStep.rank_lt {t : ℝ} (ht : 0<t) (hs : t≀1/44)
{P C : RoutineLabel} (hP : Β¬P.terminal) (h : RoutineStep t P C) :
C.rank t<P.rank t := by
cases h with
| meanFinal b p =>
have hd := ceil_gap_drop ht (show 0<p-b by simpa [RoutineLabel.terminal] using hP)
(y:=p-(b+t)) (by linarith)
simp only [RoutineLabel.rank]
omega
| sampleFinal b p => simp [RoutineLabel.rank]
| internal k k' b p =>
have hd := ceil_gap_drop ht (show 0<p-b by simpa [RoutineLabel.terminal] using hP)
(y:=p-1/4-(b-10*t)) (by linarith)
cases k <;> cases k' <;> simp only [RoutineLabel.rank] <;> omega
theorem routine_induction {t : ℝ} (ht : 0<t) (hs : t≀1/44)
(P : RoutineLabel β†’ Prop) (hbase : βˆ€L,L.terminal β†’ P L)
(hstep : βˆ€L,Β¬L.terminal β†’ (βˆ€C,RoutineStep t L C β†’ P C) β†’ P L) : βˆ€L,P L := by
intro L
induction hn : L.rank t using Nat.strong_induction_on generalizing L with
| h n ih =>
by_cases hL : L.terminal
Β· exact hbase L hL
Β· apply hstep L hL
intro C hc
exact ih _ (hn β–Έ hc.rank_lt ht hs hL) C rfl
end LogConcaveSampling.OracleCompiler
end
end
end OAI