import OAI.Combinatorics.ContingencyTables.Sampling.AllSamplingProgram import OAI.Combinatorics.ContingencyTables.Sampling.UnitTrialSemantics import OAI.Combinatorics.ContingencyTables.Sampling.ProfilePublicSemantics namespace OAI /-! # One executable program chooses the correct rectangle branch -/ namespace ContingencyTables.SmallGraphProfiles open ProfilePrograms DensePrograms CompletionCounts FirstPaperPhysicalMarginal open FirstSuccess FairBits SmallContextCoordinates open scoped BigOperators Classical noncomputable section attribute [local irreducible] unitProfileRetry unitCodeOuterDraw variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) local notation "d" => dimensionAllowance (I := Fin m) (J := Fin n) local notation "b" => smallBinaryLength r c local notation "s" => smallProposalBits (I := Fin m) (J := Fin n) lemma hasLargeRectangle_spec (k : ℕ) : hasLargeRectangle ((List.ofFn r,List.ofFn c),k)=true ↔ 0<(largeIndices (d^20,List.ofFn r)).length ∧ 0<(largeIndices (d^20,List.ofFn c)).length := by simp only [hasLargeRectangle,parameterLargeIndices,marginThreshold_ofFn, ite_true,Bool.false_eq_true,ite_false,Bool.and_eq_true,decide_eq_true_eq] lemma allSmall_of_no_large (k : ℕ) (h : hasLargeRectangle ((List.ofFn r,List.ofFn c),k)≠true) : ∀ i j,paperSmall r c i j=true := by intro i j apply Bool.eq_true_of_ne_false intro hij obtain ⟨hi,hj⟩ := (firstPaperSmall_false_iff r c (d^20) i j).mp hij have a := (largeIndexEquiv r (d^20)).symm ⟨i,hi⟩ have b' := (largeIndexEquiv c (d^20)).symm ⟨j,hj⟩ apply h apply (hasLargeRectangle_spec r c k).mpr exact ⟨Nat.zero_lt_of_lt a.isLt,Nat.zero_lt_of_lt b'.isLt⟩ lemma parameterUnitWords_ofFn (k : ℕ) : parameterUnitWords ((List.ofFn r,List.ofFn c),k)=outerTrials d k*(outerSteps d b k*s) := by rw [parameterUnitWords,parameterTrials_ofFn,parameterSteps_ofFn,parameterProposalWidth_ofFn] lemma unitCodeBits_le (k : ℕ) : outerTrials d k*(outerSteps d b k*s)≤finiteSamplerBits r c k := by apply Nat.mul_le_mul_left exact (Nat.mul_le_mul_left (outerSteps d b k) (Nat.le_add_right s (25*(d+b+outerAccuracy d b k+1)^62))).trans (Nat.le_add_right _ _) lemma scheduled_steps_pos (k : ℕ) : 0 List.ofFn (GreedyFeasibleTable.matrix r c i)) := rfl rw [hcode] at hdraw simpa only [Table] using hdraw end end ContingencyTables.SmallGraphProfiles end OAI