Download data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLog/BucketProgramCost.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.57 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLog/BucketProgramCost.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLog/BucketProgramCost.lean
-
curl -L -o BucketProgramCost.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algorithms/SubexponentialSAT/SqrtLog/BucketProgramCost.lean
5.57 kB
| import OAI.Algorithms.SubexponentialSAT.LeanCompat | |
| import OAI.Algorithms.SubexponentialSAT.SqrtLog.BucketProgramController | |
| import OAI.Algorithms.SubexponentialSAT.SqrtLog.BucketProgramLabelBounds | |
| namespace OAI.Algorithms | |
| /-! Fully explicit bit-operation budget. Dependence on the number of | |
| assignments is quadratic, and that number is exactly 2^h. -/ | |
| namespace SubexponentialSAT.SqrtLog.BucketProgram | |
| theorem encoded_words_length_bound (xs : List (List Bool)) (K : β) | |
| (hk : β xβxs,x.length β€ K) : | |
| (ProgramEncoding.encodeRecords xs).length β€ xs.length*(2*K+2)+1 := by | |
| induction xs with | |
| | nil => simp [ProgramEncoding.encodeRecords,Encoding.encodeList] | |
| | cons x xs ih => | |
| have hx := hk x (by simp) | |
| have ht := ih (fun y hy => hk y (by simp [hy])) | |
| simp only [ProgramEncoding.encodeRecords,Encoding.encodeList,Encoding.length_frame, | |
| List.length_cons,List.length_append,id_eq] | |
| change 2*x.length+1+(ProgramEncoding.encodeRecords xs).length+1 β€ _ | |
| nlinarith | |
| theorem encoded_records_length_bound (rs : List Record) (K P : β) | |
| (hk : β rβrs,r.1.length β€ K) (hp : β rβrs,r.2.length β€ P) : | |
| (SubexponentialSAT.Subexp.BucketProgram.encodeRecords rs).length β€ rs.length*(2*K+2*P+2) := by | |
| induction rs with | |
| | nil => simp [SubexponentialSAT.Subexp.BucketProgram.encodeRecords] | |
| | cons r rs ih => | |
| rcases r with β¨k,pβ© | |
| have hx := hk (k,p) (by simp) | |
| have hy := hp (k,p) (by simp) | |
| have ht := ih (fun q hq => hk q (by simp [hq])) (fun q hq => hp q (by simp [hq])) | |
| simp only [SubexponentialSAT.Subexp.BucketProgram.encodeRecords,List.length_append, | |
| Encoding.length_frame,List.length_cons] | |
| simp only at hx hy | |
| nlinarith | |
| namespace Cost | |
| def recordsBound (N K n : β) : β := N*(2*K+2*n+2) | |
| def groupBound (N K n : β) : β := | |
| 9+N*(6*K+100*(recordsBound N K n+1)*(K+1)+7)+ | |
| 3*(1+(2*(2*K+1+recordsBound N K n)+2)*N) | |
| def total (W : List Bool) (h m B n : β) : β := | |
| let N := 2^h | |
| let K := Label.keyBound W h m B | |
| enumerationCost h+48 + (N*(Label.stepBound W h m B n+2)+1)+2 + | |
| 120*(N*(2*K+2)+2)^2 + groupBound N K n + | |
| (2*recordsBound N K n+8)+1 | |
| theorem controller_cost_bound (W : List Bool) (rows : List (List (List Bool))) | |
| (js : List β) (n h B : β) (hrows : β rowβrows,row.length=h) | |
| (hb : β rowβrows,β xβrow,x.length β€ B) (hlen : js.length=h) (hjs : β jβjs,j < n) : | |
| Controller.cost W rows js n h β€ total W h rows.length B n := by | |
| let rs := Controller.labelledRecords W rows js n h | |
| let K := Label.keyBound W h rows.length B | |
| have hn : rs.length=2^h := by simp [rs,Controller.labelledRecords,Label.labelled] | |
| have hk : β rβrs,r.1.length β€ K := by | |
| intro r hr | |
| obtain β¨bits,hbits,rflβ© := List.mem_map.mp hr | |
| have hbitslen := assignment_width hbits | |
| have hi := signatureValue_length_bound W bits rows B | |
| (by intro row hr; rw [hrows row hr,hbitslen]) hb | |
| simpa [K,Label.keyBound,Label.key,hbitslen] using hi | |
| have hp : β rβrs,r.2.length β€ n := by | |
| intro r hr | |
| obtain β¨bits,hbits,rflβ© := List.mem_map.mp hr | |
| exact (HeadScatterProgram.mask_length n js bits hjs).le | |
| have hraw := encoded_records_length_bound rs K n hk hp | |
| have hrev := encoded_records_length_bound rs.reverse K n | |
| (fun r hr => hk r (List.mem_reverse.mp hr)) | |
| (fun r hr => hp r (List.mem_reverse.mp hr)) | |
| rw [List.length_reverse,hn] at hrev | |
| rw [hn] at hraw | |
| have hkeylen : (Controller.keys rs).length β€ 2^h := by | |
| have he := attainedKeys_length_le rs.reverse | |
| simpa [Controller.keys,hn] using he | |
| have hkeys : β keyβController.keys rs,key.length β€ K := by | |
| intro key hkey | |
| obtain β¨p,hpβ© := (mem_attainedKeys rs.reverse key).mp hkey | |
| exact hk (key,p) (List.mem_reverse.mp hp) | |
| have hgroup := SubexponentialSAT.Subexp.PackingBucketTable.budget_bound rs (Controller.keys rs) K hkeys | |
| have hgroup' : SubexponentialSAT.Subexp.PackingBucketTable.budget rs (Controller.keys rs) β€ | |
| groupBound (2^h) K n := by | |
| apply hgroup.trans | |
| unfold groupBound recordsBound | |
| gcongr | |
| have henc := encoded_words_length_bound (rs.map Prod.fst).reverse K (by | |
| intro key hkey | |
| obtain β¨r,hr,rflβ© := List.mem_map.mp (List.mem_reverse.mp hkey) | |
| exact hk r hr) | |
| simp only [List.length_reverse,List.length_map,hn] at henc | |
| have hdup : Controller.dedupCost rs β€ 120*(2^h*(2*K+2)+2)^2 := by | |
| unfold Controller.dedupCost | |
| have hbase : (ProgramEncoding.encodeRecords (rs.map Prod.fst).reverse).length+1 β€ | |
| 2^h*(2*K+2)+2 := by | |
| simpa only [Nat.add_assoc, Nat.reduceAdd] using Nat.add_le_add_right henc 1 | |
| exact Nat.mul_le_mul_left 120 (Nat.pow_le_pow_left hbase 2) | |
| have hlabel := Label.cost_bound W rows js n h B (assignments h) hrows hb hlen hjs | |
| (fun bits hbits => assignment_width hbits) | |
| rw [assignments_length] at hlabel | |
| have hclean : Controller.cleanupCost rs β€ 2*recordsBound (2^h) K n+8 := by | |
| unfold Controller.cleanupCost recordsBound | |
| omega | |
| unfold Controller.cost Controller.groupCost Controller.enumerateCost total | |
| change enumerationCost h+48 + (Label.cost W rows js n (assignments h)+2+ | |
| Controller.dedupCost rs+SubexponentialSAT.Subexp.PackingBucketTable.budget rs (Controller.keys rs)+ | |
| Controller.cleanupCost rs)+1 β€ _ | |
| change _ β€ enumerationCost h+48 + (2^h*(Label.stepBound W h rows.length B n+2)+1)+2+ | |
| 120*(2^h*(2*K+2)+2)^2+groupBound (2^h) K n+(2*recordsBound (2^h) K n+8)+1 | |
| omega | |
| end Cost | |
| end SubexponentialSAT.SqrtLog.BucketProgram | |
| end OAI.Algorithms | |