introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.46 kB
import OAI.Combinatorics.ContingencyTables.Sampling.ExactPrefixFeasibility
import OAI.Combinatorics.ContingencyTables.Sampling.GreedyPublicProgram
namespace OAI
/-! # Uniform printing cost for every feasible exact-sampling output -/
namespace ContingencyTables.ExactPrintCost
open MatchingFPRAS MatchingFPRAS.TreeTyped MatchingFPRAS.PhysicalStream
open DensePrograms SmallGraphProfiles Polynomial
open scoped BigOperators Classical
noncomputable section
lemma weight_ofFn {A : Type} [Codec A] {n B : β„•} (f : Fin n β†’ A)
(h : βˆ€ i,weight (f i) ≀ B) : weight (List.ofFn f) ≀ n*(B+1)+1 := by
have hb := weight_map_bound (f := f) (as := List.finRange n) (fun i _ => h i)
simpa only [←List.ofFn_eq_map,List.length_finRange] using hb
def matrixSize {m n : β„•} (r : Fin m β†’ β„•) : β„• :=
m*(n*(4*weight (βˆ‘ i,r i)+2)+2)+1
lemma matrix_weight {m n : β„•} (r : Fin m β†’ β„•) (c : Fin n β†’ β„•) (X : Table r c) :
weight (matrixCode X.val) ≀ matrixSize (n := n) r := by
have row (i : Fin m) : weight (List.ofFn (X.val i)) ≀ n*(4*weight (βˆ‘ i,r i)+2)+1 := by
apply weight_ofFn
intro j
exact weight_nat_small (entry_le_total X.property i j)
exact weight_ofFn (fun i => List.ofFn (X.val i)) row
/-- One fixed polynomial bounds both printing time and printed word length
uniformly over the feasible set. -/
theorem polynomial_print_bound : βˆƒ p : Polynomial β„•,
βˆ€ (m n : β„•) (r : Fin m β†’ β„•) (c : Fin n β†’ β„•) (X : Table r c),
GreedyFeasibleTable.printMatrixRealizer.cost (matrixCode X.val)+
weight (GreedyFeasibleTable.printMatrix (matrixCode X.val)) ≀ p.eval (matrixSize (n := n) r) := by
obtain ⟨p,hp⟩ := GreedyFeasibleTable.polynomial_printMatrix
exact ⟨p,fun _ _ r c X => (hp _).trans
(polynomial_eval_monotone p (matrix_weight r c X))⟩
lemma prefix_print_bound {m n : β„•} (r : Fin m β†’ β„•) (c : Fin n β†’ β„•)
(htotal : (βˆ‘ i,r i)=βˆ‘ j,c j) (B : β„•)
(hB : βˆ€ X : Table r c,GreedyFeasibleTable.printMatrixRealizer.cost (matrixCode X.val) ≀ B)
(N : β„•) :
(ExactCoreProgram.prefixExperiment (List.ofFn r,List.ofFn c) N).All
(fun o => o.elim 0 GreedyFeasibleTable.printMatrixRealizer.cost ≀ B) := by
exact (exactPrefix_feasible r c htotal N).mono (by
intro o ho
cases o with
| none => exact Nat.zero_le _
| some X =>
obtain ⟨T,rfl⟩ := ho
exact hB T)
end
end ContingencyTables.ExactPrintCost
end OAI