File size: 2,499 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 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
|