File size: 5,693 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 | import OAI.Algorithms.SubexponentialSAT.LeanCompat
import OAI.Algorithms.SubexponentialSAT.SqrtLog.BucketProgramProducedRankFiber
import OAI.Algorithms.SubexponentialSAT.SqrtLog.BucketProgramProducedRankTables
import OAI.Algorithms.SubexponentialSAT.SqrtLog.LayoutProducedMatrixNatural
namespace OAI.Algorithms
/-! The native fiber relation realizes the literal owner-sum matrix. Signed
component mass bounds imply both safe shifting and a signature-height bound. -/
namespace SubexponentialSAT.SqrtLog.BucketProgram.ProducedRank
open scoped BigOperators
open SubexponentialSAT.MulticolorTypes SubexponentialSAT.Subexp.ConstructivePacking
variable {r Q D n : β}
def entryNat (P : PackingData (Fin D) (UniversalType r Q 1))
(A R : β) (t : Fin Q) (j i : β) : β€ :=
if hj : j < D then if hi : i < D then
LayoutProgram.localEntry P A R t β¨j,hjβ© β¨i,hiβ© else 0 else 0
def FiberRel (ps : List (β Γ β)) (value : β β β β β€) (H : β)
(j v : β) (p : LayoutMatrixProgram.Pair) : Prop :=
RowSelectionProgram.pairValue p=
((LayoutOwnerFiberProgram.fiberIndices v 0 ps).map (value j)).sum β§
RowSelectionProgram.pairTotal p.1 p.2 β€ H
theorem fiber_value_literal (P : PackingData (Fin D) (UniversalType r Q 1))
(owner : Fin D β Fin n) (A R : β) (t : Fin Q)
(ps : Fin D β β Γ β) (hp : β i,(ps i).1=(owner i).val)
(j : Fin D) (v : Fin n) :
((LayoutOwnerFiberProgram.fiberIndices v.val 0 (List.ofFn ps)).map
(entryNat P A R t j.val)).sum=LayoutProducedMatrix.literalNat P owner A R t j.val v.val := by
rw [LayoutProducedMatrix.literalNat_fin]
exact fiber_sum_eq_matrix owner ps hp (LayoutProgram.localEntry P A R t)
(entryNat P A R t) (by intro j i; simp [entryNat]) j v
theorem pair_abs_le_mass (p : LayoutMatrixProgram.Pair) (H : β)
(hp : RowSelectionProgram.pairTotal p.1 p.2 β€ H) :
|RowSelectionProgram.pairValue p| β€ (H:β€) := by
unfold RowSelectionProgram.pairTotal at hp
unfold RowSelectionProgram.pairValue RowSelectionProgram.signedValue
have hp' : (SubexponentialSAT.BinaryArithmetic.toNat p.1 : β€)+
(SubexponentialSAT.BinaryArithmetic.toNat p.2 : β€) β€ (H:β€) := by exact_mod_cast hp
have h1 := Int.natCast_nonneg (SubexponentialSAT.BinaryArithmetic.toNat p.1)
have h2 := Int.natCast_nonneg (SubexponentialSAT.BinaryArithmetic.toNat p.2)
rw [abs_le]
omega
theorem fiberRel_realizes (P : PackingData (Fin D) (UniversalType r Q 1))
(owner : Fin D β Fin n) (A R : β) (t : Fin Q)
(ps : Fin D β β Γ β) (hp : β i,(ps i).1=(owner i).val)
(H : β) (j v : β) (p : LayoutMatrixProgram.Pair) (hj : j < D) (hv : v < n)
(hr : FiberRel (List.ofFn ps) (entryNat P A R t) H j v p) :
RowSelectionProgram.pairValue p=LayoutProducedMatrix.literalNat P owner A R t j v β§
|LayoutProducedMatrix.literalNat P owner A R t j v| β€ (H:β€) := by
have he := hr.1.trans (fiber_value_literal P owner A R t ps hp β¨j,hjβ© β¨v,hvβ©)
exact β¨he,he βΈ pair_abs_le_mass p H hr.2β©
/-- A single physical head table is bounded by the rank of its literal
selected integer matrix, in exactly the emitted column order. -/
theorem producedHead_fiber_length {base : LeafHeadSetupProgram.Data} {N B z : β}
{rows : List (List Bool)} {low : List Bool}
(P : PackingData (Fin D) (UniversalType r Q 1))
(owner : Fin D β Fin n) (A R : β) (t : Fin Q)
(ps : Fin D β β Γ β) (hp : β i,(ps i).1=(owner i).val) (H : β)
{table : BucketTupleProgram.HeadTable}
(ht : LeafHeadSetupProgram.ProducedHead base n N D rows low
(FiberRel (List.ofFn ps) (entryNat P A R t) H) B z table)
(hW : H β€ SubexponentialSAT.BinaryArithmetic.toNat (base.stacks 141)) :
table.buckets.length β€ (commonBase n H)^
headRank (LayoutProducedMatrix.literalNat P owner A R t) D n rows low z := by
apply producedHead_length_le_rank ht (LayoutProducedMatrix.literalNat P owner A R t) H
Β· intro j v p hj hv hr
have he := fiberRel_realizes P owner A R t ps hp H j v p hj hv hr
refine β¨?_,he.1β©
have hm := hr.2
unfold RowSelectionProgram.pairTotal at hm
omega
Β· intro j v p hj hv hr
exact (fiberRel_realizes P owner A R t ps hp H j v p hj hv hr).2
/-- The actual r-table product, obtained from an original-address fiber
entry relation. No head-cardinality bounds are hypotheses. -/
theorem producedHeads_fiber_product {base : LeafHeadSetupProgram.Data} {N B : β}
{rows : List (List Bool)} {low : List Bool}
(P : PackingData (Fin D) (UniversalType r Q 1))
(owner : Fin D β Fin n) (A R : β) (t : Fin Q)
(ps : Fin D β β Γ β) (hp : β i,(ps i).1=(owner i).val) (H : β)
{tables : List BucketTupleProgram.HeadTable}
(ht : LeafHeadSetupProgram.ProducedHeads base n N D rows low
(FiberRel (List.ofFn ps) (entryNat P A R t) H) B (t.val*r) tables)
(hlen : tables.length=r) (hW : H β€ SubexponentialSAT.BinaryArithmetic.toNat (base.stacks 141)) :
(tables.map fun table=>table.buckets.length).prod β€ (commonBase n H)^
(β g : Fin r,headRank (LayoutProducedMatrix.literalNat P owner A R t)
D n rows low (t.val*r+g.val)) := by
subst r
have hh := producedHeads_product_le_rankSum ht
(LayoutProducedMatrix.literalNat P owner A R t) H
(fun j v p hj hv hr=>by
have he := fiberRel_realizes P owner A R t ps hp H j v p hj hv hr
refine β¨?_,he.1β©
have hm := hr.2
unfold RowSelectionProgram.pairTotal at hm
omega)
(fun j v p hj hv hr=>(fiberRel_realizes P owner A R t ps hp H j v p hj hv hr).2)
exact hh
end SubexponentialSAT.SqrtLog.BucketProgram.ProducedRank
end OAI.Algorithms
|