Commit c3d72bb2 by Rene Thiemann

### complexity of Gram_Schmidt_Int

parent 55a77d90af15
 ... ... @@ -15,8 +15,6 @@ theory Gram_Schmidt_Int More_IArray begin no_notation test_bit (infixl "!!" 100) context fixes fs :: "int vec iarray" and m :: nat begin ... ...
 ... ... @@ -32,7 +32,6 @@ context LLL_with_assms begin context fixes arith_cost :: nat assumes \_gt: "\ > 4/3" and m0: "m \ 0" begin ... ... @@ -375,6 +374,46 @@ function dmu_array_row_main_cost where termination by (relation "measure (\ (fi,i,dmus,j). i - j)", auto) declare dmu_array_row_main_cost.simps[simp del] lemma dmu_array_row_main_cost: assumes "j \ i" shows "result (dmu_array_row_main_cost fi i dmus j) = dmu_array_row_main fs fi i dmus j" "cost (dmu_array_row_main_cost fi i dmus j) \ (\ jj \ {j ..< i}. 2 * n + 2 + 4 * jj + 1)" using assms proof (atomize(full), induct "i - j" arbitrary: j dmus) case (0 j dmus) hence j: "j = i" by auto thus ?case unfolding dmu_array_row_main_cost.simps[of _ _ _ j] dmu_array_row_main.simps[of _ _ _ _ j] by (simp add: cost_simps) next case (Suc l j dmus) from Suc(2) have id: "(i \ j) = False" "(j = i) = False" by auto let ?sl = "Suc l" let ?dll = "dmus !! (Suc l - 1) !! (Suc l - 1)" obtain sig c_sig where sig_c: "sigma_array_cost dmus (dmus !! i) (dmus !! Suc j) (dmus !! j !! j) j = (sig,c_sig)" by force from sigma_array_cost[of dmus "dmus !! i" "dmus !! Suc j" "dmus !! j !! j" j, unfolded sig_c cost_simps] have sig: "sigma_array dmus (dmus !! i) (dmus !! Suc j) (dmus !! j !! j) j = sig" and c_sig: "c_sig \ 4 * j + 1" by auto obtain dmus' where dmus': "iarray_update dmus i (iarray_append (dmus !! i) (dmus !! j !! j * (fi \ fs !! Suc j) - sig)) = dmus'" by auto obtain res c_rec where rec_c: "dmu_array_row_main_cost fi i dmus' (Suc j) = (res, c_rec)" by force let ?c = "\ j. 2 * n + 2 + 4 * j + 1" from Suc(2-3) have "l = i - Suc j" "Suc j \ i" by auto from Suc(1)[OF this, of dmus', unfolded rec_c cost_simps] have rec: "dmu_array_row_main fs fi i dmus' (Suc j) = res" and c_rec: "c_rec \ (\jj = Suc j.. ?c j + (\jj = Suc j.. = (\jj = j.. (\jj = j.. fs !! 0 \ \2n arith. operations\; ... ... @@ -382,6 +421,29 @@ definition dmu_array_row_cost where (res, main_cost) = dmu_array_row_main_cost fi i (iarray_append dmus (IArray [sp])) 0 in (res, local_cost + main_cost))" lemma dmu_array_row_cost: "result (dmu_array_row_cost dmus i) = dmu_array_row fs dmus i" "cost (dmu_array_row_cost dmus i) \ 2 * n + (2 * n + 1 + 2 * i) * i" proof (atomize(full), goal_cases) case 1 let ?fi = "fs !! i" let ?arr = "iarray_append dmus (IArray [?fi \ fs !! 0])" obtain res c_main where res_c: "dmu_array_row_main_cost ?fi i ?arr 0 = (res, c_main)" by force from dmu_array_row_main_cost[of 0 i ?fi ?arr, unfolded res_c cost_simps] have res: "dmu_array_row_main fs ?fi i ?arr 0 = res" and c_main: "c_main \ (\jj = 0.. 2 * n + (\jj = 0.. = 2 * n + (2 * n + 3) * i + 2 * (\jj < i. 2 * jj)" unfolding sum.distrib by (auto simp: sum_distrib_left field_simps intro: sum.cong) also have "(\jj < i. 2 * jj) = i * (i - 1)" by (induct i, force, rename_tac i, case_tac i, auto) finally have "2 * n + c_main \ 2 * n + (2 * n + 3 + 2 * (i - 1)) * i" by (simp add: field_simps) also have "\ = 2 * n + (2 * n + 1 + 2 * i) * i" by (cases i, auto simp: field_simps) finally have "2 * n + c_main \ 2 * n + (2 * n + 1 + 2 * i) * i" . thus ?case unfolding dmu_array_row_cost_def Let_def dmu_array_row_def res_c res split cost_simps by auto qed function dmu_array_cost where "dmu_array_cost dmus i = (if i \ m then (dmus,0) else let (dmus', cost_row) = dmu_array_row_cost dmus i; ... ... @@ -391,7 +453,76 @@ function dmu_array_cost where termination by (relation "measure (\ (dmus, i). m - i)", auto) declare dmu_array_cost.simps[simp del] lemma dmu_array_cost: assumes "i \ m" shows "result (dmu_array_cost dmus i) = dmu_array fs m dmus i" "cost (dmu_array_cost dmus i) \ (\ ii \ {i ..< m}. 2 * n + (2 * n + 1 + 2 * ii) * ii)" using assms proof (atomize(full), induct "m - i" arbitrary: i dmus) case (0 i dmus) hence i: "i = m" by auto thus ?case unfolding dmu_array_cost.simps[of _ i] dmu_array.simps[of _ _ _ i] by (simp add: cost_simps) next case (Suc k i dmus) obtain dmus' c_row where row_c: "dmu_array_row_cost dmus i = (dmus',c_row)" by force from dmu_array_row_cost[of dmus i, unfolded row_c cost_simps] have row: "dmu_array_row fs dmus i = dmus'" and c_row: "c_row \ 2 * n + (2 * n + 1 + 2 * i) * i" (is "_ \ ?c i") by auto from Suc have "k = m - Suc i" "Suc i \ m" and id: "(m \ i) = False" "(i = m) = False" by auto note IH = Suc(1)[OF this(1-2), of dmus'] obtain res c_rec where rec_c: "dmu_array_cost dmus' (Suc i) = (res, c_rec)" by force from IH[unfolded rec_c cost_simps] have rec: "dmu_array fs m dmus' (Suc i) = res" and c_rec: "c_rec \ (\ii = Suc i.. ?c i + (\ii = Suc i.. = (\ii = i.._impl_cost :: "int vec list \ int iarray iarray cost" where "d\_impl_cost fs = dmu_array_cost (IArray fs) (IArray []) 0" lemma d\_impl_cost: "result (d\_impl_cost fs_init) = d\_impl fs_init" "cost (d\_impl_cost fs_init) \ m * (m * (m + n + 2) + 2 * n + 1)" proof (atomize(full), goal_cases) case 1 let ?fs = "IArray fs_init" let ?dmus = "IArray []" obtain res cost where res_c: "dmu_array_cost ?fs ?dmus 0 = (res, cost)" by force from dmu_array_cost[of 0 ?fs ?dmus, unfolded res_c cost_simps] have res: "dmu_array ?fs m ?dmus 0 = res" and cost: "cost \ (\ii = 0..ii = 0..ii = 0..ii = 0.. \ 2 * n * m + (2 * n + 2) * (\ii = 0..ii = 0..ii = 0..ii = 0..ii = 0..ii = 0..ii = 0..ii = 0.. 2 * n * m + (n + 1) * (m * (m - 1)) + (2 * (m - 1) * (m - 1) * (m - 1) + 3 * (m - 1) * (m - 1) + (m - 1)) div 3" . also have "\ \ 2 * n * m + (n + 1) * (m * m) + (3 * m * m * m + 3 * m * m + 3 * m) div 3" by (intro add_mono div_le_mono mult_mono, auto) also have "\ = 2 * n * m + (n + 1) * (m * m) + (m * m * m + m * m + m)" by simp also have "\ = m * (m * (m + n + 2) + 2 * n + 1)" by (simp add: algebra_simps) finally show ?case unfolding d\_impl_cost_def d\_impl_def len res res_c cost_simps by simp qed (* TODO: integrate cost for initial_state: below is the calculation for the GSO-based initial state ... ...
 ... ... @@ -23,6 +23,8 @@ theory Missing_Lemmas Berlekamp_Zassenhaus.Berlekamp_Hensel (* for unique_factorization_m_factor *) begin no_notation test_bit (infixl "!!" 100) hide_const(open) module.smult up_ring.monom up_ring.coeff (**** The following lemmas that could be moved to HOL/Finite_Set.thy ****) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!