File size: 5,420 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | import OAI.Combinatorics.ContingencyTables.Sampling.ExactGateCost
import OAI.Combinatorics.ContingencyTables.Sampling.ExactPrintCost
import OAI.Combinatorics.ContingencyTables.Sampling.FirstPaperInputWordBudget
namespace OAI
/-! # Exact-sampler parameters in the public binary input size -/
namespace ContingencyTables.SmallGraphProfiles
open MatchingFPRAS MatchingFPRAS.TreeTyped MatchingFPRAS.LiteralCodec
open ProfilePrograms DensePrograms Algorithms Polynomial
open scoped BigOperators Classical
noncomputable section
variable {m n : β} (r : Fin m β β) (c : Fin n β β)
local notation "S" => samplingSize n r 0
lemma exact_public_length (htotal : (β i,r i)=β j,c j) :
(encodeMargins r c).length β€ 5*S^2 := by
have h := encodeSamplingInput_length r c htotal 0
have he : (encodeMargins r c).length β€ (encodeSamplingInput r c 0).length := by
simp only [encodeSamplingInput,List.length_append]
omega
exact he.trans h
lemma exact_public_weight (htotal : (β i,r i)=β j,c j) :
weight (encodeMargins r c) β€ 91*S^2 := by
have h := exact_public_length r c htotal
have hS : 1 β€ S^2 := one_le_powβ (by unfold samplingSize; omega)
rw [weight_word]
omega
lemma exact_precision_bound : correctionPrecision r c β€ 245^8*S^16 := by
let dim := CompletionCounts.dimensionAllowance (I := Fin m) (J := Fin n)
have hi := sampling_internal_size_bound r c 0
have hd : dim β€ 245*S^2 := by dsimp only [dim]; omega
have hb : smallBinaryLength r c β€ 245*S^2 := by omega
change dim^6*(smallBinaryLength r c)^2 β€ _
calc
_ β€ (245*S^2)^6*(245*S^2)^2 :=
Nat.mul_le_mul (Nat.pow_le_pow_left hd _) (Nat.pow_le_pow_left hb _)
_ = 245^8*S^16 := by ring
lemma exact_margin_weight_polynomial : β p : Polynomial β,
β (m n : β) (r : Fin m β β) (c : Fin n β β),
(β i,r i)=β j,c j β weight (List.ofFn r,List.ofFn c) β€ p.eval (samplingSize n r 0) := by
obtain β¨p,hpβ© := polynomial_exactParsedMargins
refine β¨p.comp (91*X^2),?_β©
intro m n r c htotal
have h := (Nat.le_add_left _ _).trans (hp (encodeMargins r c))
rw [exactParsedMargins_spec] at h
exact h.trans (by
rw [eval_comp]
simp only [eval_mul,eval_ofNat,eval_pow,eval_X]
exact polynomial_eval_monotone p (exact_public_weight r c htotal))
lemma exact_parameter_polynomial : β p : Polynomial β,
β (m n : β) (r : Fin m β β) (c : Fin n β β),
(β i,r i)=β j,c j β exactParameterMeasure (List.ofFn r,List.ofFn c) β€
p.eval (samplingSize n r 0) := by
obtain β¨p,hpβ© := exact_margin_weight_polynomial
refine β¨C (245^8)*X^16+p,?_β©
intro m n r c htotal
simp only [exactParameterMeasure,exactPrecision_ofFn,eval_add,eval_mul,eval_C,eval_pow,eval_X]
exact Nat.add_le_add (exact_precision_bound r c) (hp m n r c htotal)
lemma exact_total_weight : weight (β i,r i) β€ 4*S+1 := by
have hs : (β i,r i).size β€ Nat.clog 2 ((β i,r i)+1) :=
Nat.size_le.mpr (Nat.lt_of_lt_of_le (Nat.lt_succ_self _)
(Nat.le_pow_clog (by decide) _))
have hw := weight_nat_le (β i,r i)
unfold samplingSize
omega
lemma exact_matrix_size : ExactPrintCost.matrixSize (n := n) r β€ 25*S^3 := by
have hS : 1 β€ S := by unfold samplingSize; omega
have hm : m β€ S := by unfold samplingSize; omega
have hn : n β€ S := by unfold samplingSize; omega
have hw : 4*weight (β i,r i)+2 β€ 22*S := by
have := exact_total_weight (n := n) r
omega
have hpow : S β€ S^3 := Nat.le_self_pow (by decide) _
calc
_ β€ S*(S*(22*S)+2)+1 := by unfold ExactPrintCost.matrixSize; gcongr
_ β€ 25*S^3 := by nlinarith
lemma exact_ordinary_bits_polynomial : β p : Polynomial β,
β (m n : β) (r : Fin m β β) (c : Fin n β β),
exactOrdinaryBits (List.ofFn r,List.ofFn c) β€ p.eval (samplingSize n r 0) := by
let q : Polynomial β := X+2*(C (245^8)*X^16)
refine β¨C (344^644)*q^1288,?_β©
intro m n r c
have hD := exact_precision_bound r c
have hS : samplingSize n r (2*correctionPrecision r c) β€ q.eval (samplingSize n r 0) := by
simp only [q,eval_add,eval_mul,eval_ofNat,eval_C,eval_pow,eval_X]
unfold samplingSize at *
omega
rw [exactOrdinaryBits_ofFn]
have hf : finiteSamplerBits r c (2*correctionPrecision r c) β€
344^644*(samplingSize n r (2*correctionPrecision r c))^1288 :=
sampling_word_budget_polynomial r c (2*correctionPrecision r c)
have hp (k : β) :
344^644*(samplingSize n r (2*correctionPrecision r c))^k β€
(C (344^644)*q^k).eval (samplingSize n r 0) := by
rw [eval_mul,eval_C,eval_pow]
exact Nat.mul_le_mul_left (344^644) (Nat.pow_le_pow_left hS k)
exact hf.trans (hp 1288)
lemma exact_gate_measure_polynomial : β p : Polynomial β,
β (m n : β) (r : Fin m β β) (c : Fin n β β),
(β i,r i)=β j,c j β ExactGateCost.measure (List.ofFn r,List.ofFn c) β€
p.eval (samplingSize n r 0) := by
obtain β¨p,hpβ© := exact_parameter_polynomial
obtain β¨q,hqβ© := exact_margin_weight_polynomial
obtain β¨u,huβ© := exact_ordinary_bits_polynomial
refine β¨p+q+u,?_β©
intro m n r c htotal
simpa only [ExactGateCost.measure,FiniteWordExecution.wordMeasure,eval_add,add_assoc]
using Nat.add_le_add (hp m n r c htotal)
(Nat.add_le_add (hq m n r c htotal) (hu m n r c))
end
end ContingencyTables.SmallGraphProfiles
end OAI
|